Alexander Afanasyev | 60a7b62 | 2014-12-20 17:04:07 -0800 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
| 2 | /** |
| 3 | * Copyright (c) 2011-2015 Regents of the University of California. |
Alexander Afanasyev | 68de795 | 2012-12-12 18:02:29 -0800 | [diff] [blame] | 4 | * |
Alexander Afanasyev | 60a7b62 | 2014-12-20 17:04:07 -0800 | [diff] [blame] | 5 | * This file is part of ndnSIM. See AUTHORS for complete list of ndnSIM authors and |
| 6 | * contributors. |
Alexander Afanasyev | 68de795 | 2012-12-12 18:02:29 -0800 | [diff] [blame] | 7 | * |
Alexander Afanasyev | 60a7b62 | 2014-12-20 17:04:07 -0800 | [diff] [blame] | 8 | * ndnSIM is free software: you can redistribute it and/or modify it under the terms |
| 9 | * of the GNU General Public License as published by the Free Software Foundation, |
| 10 | * either version 3 of the License, or (at your option) any later version. |
Alexander Afanasyev | 68de795 | 2012-12-12 18:02:29 -0800 | [diff] [blame] | 11 | * |
Alexander Afanasyev | 60a7b62 | 2014-12-20 17:04:07 -0800 | [diff] [blame] | 12 | * ndnSIM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; |
| 13 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR |
| 14 | * PURPOSE. See the GNU General Public License for more details. |
Alexander Afanasyev | 68de795 | 2012-12-12 18:02:29 -0800 | [diff] [blame] | 15 | * |
Alexander Afanasyev | 60a7b62 | 2014-12-20 17:04:07 -0800 | [diff] [blame] | 16 | * You should have received a copy of the GNU General Public License along with |
| 17 | * ndnSIM, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>. |
| 18 | **/ |
Alexander Afanasyev | 68de795 | 2012-12-12 18:02:29 -0800 | [diff] [blame] | 19 | |
Alexander Afanasyev | afe47fe | 2015-01-06 18:29:39 -0800 | [diff] [blame] | 20 | // ndn-custom-apps.cpp |
Alexander Afanasyev | 68de795 | 2012-12-12 18:02:29 -0800 | [diff] [blame] | 21 | |
| 22 | #include "ns3/core-module.h" |
| 23 | #include "ns3/network-module.h" |
| 24 | #include "ns3/ndnSIM-module.h" |
| 25 | |
Spyridon Mastorakis | db8280f | 2014-11-21 20:00:17 -0800 | [diff] [blame] | 26 | namespace ns3 { |
Alexander Afanasyev | 68de795 | 2012-12-12 18:02:29 -0800 | [diff] [blame] | 27 | |
| 28 | /** |
Spyridon Mastorakis | db8280f | 2014-11-21 20:00:17 -0800 | [diff] [blame] | 29 | * This scenario simulates a one-node two-custom-app scenario: |
Alexander Afanasyev | 68de795 | 2012-12-12 18:02:29 -0800 | [diff] [blame] | 30 | * |
Alexander Afanasyev | afe47fe | 2015-01-06 18:29:39 -0800 | [diff] [blame] | 31 | * +------+ <-----> (CustomApp) |
Spyridon Mastorakis | db8280f | 2014-11-21 20:00:17 -0800 | [diff] [blame] | 32 | * | Node | |
Alexander Afanasyev | afe47fe | 2015-01-06 18:29:39 -0800 | [diff] [blame] | 33 | * +------+ <-----> (Hijacker) |
Alexander Afanasyev | 68de795 | 2012-12-12 18:02:29 -0800 | [diff] [blame] | 34 | * |
Alexander Afanasyev | afe47fe | 2015-01-06 18:29:39 -0800 | [diff] [blame] | 35 | * NS_LOG=CustomApp ./waf --run=ndn-custom-apps |
Alexander Afanasyev | 68de795 | 2012-12-12 18:02:29 -0800 | [diff] [blame] | 36 | */ |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 37 | int |
| 38 | main(int argc, char* argv[]) |
Alexander Afanasyev | 68de795 | 2012-12-12 18:02:29 -0800 | [diff] [blame] | 39 | { |
| 40 | // Read optional command-line parameters (e.g., enable visualizer with ./waf --run=<> --visualize |
| 41 | CommandLine cmd; |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 42 | cmd.Parse(argc, argv); |
Alexander Afanasyev | 68de795 | 2012-12-12 18:02:29 -0800 | [diff] [blame] | 43 | |
| 44 | // Creating nodes |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 45 | Ptr<Node> node = CreateObject<Node>(); |
Alexander Afanasyev | 68de795 | 2012-12-12 18:02:29 -0800 | [diff] [blame] | 46 | |
Alexander Afanasyev | afe47fe | 2015-01-06 18:29:39 -0800 | [diff] [blame] | 47 | // Install NDN stack on all nodes |
Spyridon Mastorakis | db8280f | 2014-11-21 20:00:17 -0800 | [diff] [blame] | 48 | ndn::StackHelper ndnHelper; |
Alexander Afanasyev | afe47fe | 2015-01-06 18:29:39 -0800 | [diff] [blame] | 49 | ndnHelper.SetDefaultRoutes(true); |
Spyridon Mastorakis | db8280f | 2014-11-21 20:00:17 -0800 | [diff] [blame] | 50 | ndnHelper.InstallAll(); |
Alexander Afanasyev | 68de795 | 2012-12-12 18:02:29 -0800 | [diff] [blame] | 51 | |
Alexander Afanasyev | afe47fe | 2015-01-06 18:29:39 -0800 | [diff] [blame] | 52 | // App1 |
| 53 | ndn::AppHelper app1("CustomApp"); |
| 54 | app1.Install(node); |
Alexander Afanasyev | 68de795 | 2012-12-12 18:02:29 -0800 | [diff] [blame] | 55 | |
Alexander Afanasyev | afe47fe | 2015-01-06 18:29:39 -0800 | [diff] [blame] | 56 | // App2 |
| 57 | ndn::AppHelper app2("Hijacker"); |
| 58 | app2.Install(node); // last node |
Alexander Afanasyev | 68de795 | 2012-12-12 18:02:29 -0800 | [diff] [blame] | 59 | |
Alexander Afanasyev | afe47fe | 2015-01-06 18:29:39 -0800 | [diff] [blame] | 60 | Simulator::Stop(Seconds(20.0)); |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 61 | |
| 62 | Simulator::Run(); |
| 63 | Simulator::Destroy(); |
Alexander Afanasyev | 68de795 | 2012-12-12 18:02:29 -0800 | [diff] [blame] | 64 | |
| 65 | return 0; |
| 66 | } |
Spyridon Mastorakis | db8280f | 2014-11-21 20:00:17 -0800 | [diff] [blame] | 67 | |
| 68 | } // namespace ns3 |
| 69 | |
| 70 | int |
| 71 | main(int argc, char* argv[]) |
| 72 | { |
| 73 | return ns3::main(argc, argv); |
| 74 | } |