blob: 7ea32f84a84a3a7c51c44f4a56c6fb56161e4c7c [file] [log] [blame]
Alexander Afanasyev60a7b622014-12-20 17:04:07 -08001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/**
3 * Copyright (c) 2011-2015 Regents of the University of California.
Alexander Afanasyev68de7952012-12-12 18:02:29 -08004 *
Alexander Afanasyev60a7b622014-12-20 17:04:07 -08005 * This file is part of ndnSIM. See AUTHORS for complete list of ndnSIM authors and
6 * contributors.
Alexander Afanasyev68de7952012-12-12 18:02:29 -08007 *
Alexander Afanasyev60a7b622014-12-20 17:04:07 -08008 * 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 Afanasyev68de7952012-12-12 18:02:29 -080011 *
Alexander Afanasyev60a7b622014-12-20 17:04:07 -080012 * 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 Afanasyev68de7952012-12-12 18:02:29 -080015 *
Alexander Afanasyev60a7b622014-12-20 17:04:07 -080016 * 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 Afanasyev68de7952012-12-12 18:02:29 -080019
Alexander Afanasyevafe47fe2015-01-06 18:29:39 -080020// ndn-custom-apps.cpp
Alexander Afanasyev68de7952012-12-12 18:02:29 -080021
22#include "ns3/core-module.h"
23#include "ns3/network-module.h"
24#include "ns3/ndnSIM-module.h"
25
Spyridon Mastorakisdb8280f2014-11-21 20:00:17 -080026namespace ns3 {
Alexander Afanasyev68de7952012-12-12 18:02:29 -080027
28/**
Spyridon Mastorakisdb8280f2014-11-21 20:00:17 -080029 * This scenario simulates a one-node two-custom-app scenario:
Alexander Afanasyev68de7952012-12-12 18:02:29 -080030 *
Alexander Afanasyevafe47fe2015-01-06 18:29:39 -080031 * +------+ <-----> (CustomApp)
Spyridon Mastorakisdb8280f2014-11-21 20:00:17 -080032 * | Node |
Alexander Afanasyevafe47fe2015-01-06 18:29:39 -080033 * +------+ <-----> (Hijacker)
Alexander Afanasyev68de7952012-12-12 18:02:29 -080034 *
Alexander Afanasyevafe47fe2015-01-06 18:29:39 -080035 * NS_LOG=CustomApp ./waf --run=ndn-custom-apps
Alexander Afanasyev68de7952012-12-12 18:02:29 -080036 */
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080037int
38main(int argc, char* argv[])
Alexander Afanasyev68de7952012-12-12 18:02:29 -080039{
40 // Read optional command-line parameters (e.g., enable visualizer with ./waf --run=<> --visualize
41 CommandLine cmd;
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080042 cmd.Parse(argc, argv);
Alexander Afanasyev68de7952012-12-12 18:02:29 -080043
44 // Creating nodes
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080045 Ptr<Node> node = CreateObject<Node>();
Alexander Afanasyev68de7952012-12-12 18:02:29 -080046
Alexander Afanasyevafe47fe2015-01-06 18:29:39 -080047 // Install NDN stack on all nodes
Spyridon Mastorakisdb8280f2014-11-21 20:00:17 -080048 ndn::StackHelper ndnHelper;
Alexander Afanasyevafe47fe2015-01-06 18:29:39 -080049 ndnHelper.SetDefaultRoutes(true);
Spyridon Mastorakisdb8280f2014-11-21 20:00:17 -080050 ndnHelper.InstallAll();
Alexander Afanasyev68de7952012-12-12 18:02:29 -080051
Alexander Afanasyevafe47fe2015-01-06 18:29:39 -080052 // App1
53 ndn::AppHelper app1("CustomApp");
54 app1.Install(node);
Alexander Afanasyev68de7952012-12-12 18:02:29 -080055
Alexander Afanasyevafe47fe2015-01-06 18:29:39 -080056 // App2
57 ndn::AppHelper app2("Hijacker");
58 app2.Install(node); // last node
Alexander Afanasyev68de7952012-12-12 18:02:29 -080059
Alexander Afanasyevafe47fe2015-01-06 18:29:39 -080060 Simulator::Stop(Seconds(20.0));
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080061
62 Simulator::Run();
63 Simulator::Destroy();
Alexander Afanasyev68de7952012-12-12 18:02:29 -080064
65 return 0;
66}
Spyridon Mastorakisdb8280f2014-11-21 20:00:17 -080067
68} // namespace ns3
69
70int
71main(int argc, char* argv[])
72{
73 return ns3::main(argc, argv);
74}