blob: eeac1731d76e3d4575039cb9a5fae396072bac44 [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 Afanasyev60a7b622014-12-20 17:04:07 -080020// ndn-simple-with-custom-app.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 *
Spyridon Mastorakisdb8280f2014-11-21 20:00:17 -080031 * +------+ <-----> (CustomApp1)
32 * | Node |
33 * +------+ <-----> (CustomApp2)
Alexander Afanasyev68de7952012-12-12 18:02:29 -080034 *
35 * NS_LOG=CustomApp ./waf --run=ndn-simple-with-custom-app
36 */
37
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080038int
39main(int argc, char* argv[])
Alexander Afanasyev68de7952012-12-12 18:02:29 -080040{
41 // Read optional command-line parameters (e.g., enable visualizer with ./waf --run=<> --visualize
42 CommandLine cmd;
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080043 cmd.Parse(argc, argv);
Alexander Afanasyev68de7952012-12-12 18:02:29 -080044
45 // Creating nodes
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080046 Ptr<Node> node = CreateObject<Node>();
Alexander Afanasyev68de7952012-12-12 18:02:29 -080047
48 // Install CCNx stack on all nodes
Spyridon Mastorakisdb8280f2014-11-21 20:00:17 -080049 ndn::StackHelper ndnHelper;
50 ndnHelper.InstallAll();
Alexander Afanasyev68de7952012-12-12 18:02:29 -080051
52 // Installing applications
53
54 // Consumer
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080055 ndn::AppHelper consumerHelper("CustomApp");
56 ApplicationContainer app1 = consumerHelper.Install(node);
57 ApplicationContainer app2 = consumerHelper.Install(node);
Alexander Afanasyev68de7952012-12-12 18:02:29 -080058
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080059 app1.Start(Seconds(1.0)); // will send out Interest, which nobody will receive (Interests
60 // generated by an app will not got back to the app)
61 app2.Start(
62 Seconds(2.0)); // will send out an Interests, which will be received and satisfied by app1
Alexander Afanasyev68de7952012-12-12 18:02:29 -080063
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080064 Simulator::Stop(Seconds(3.0));
65
66 Simulator::Run();
67 Simulator::Destroy();
Alexander Afanasyev68de7952012-12-12 18:02:29 -080068
69 return 0;
70}
Spyridon Mastorakisdb8280f2014-11-21 20:00:17 -080071
72} // namespace ns3
73
74int
75main(int argc, char* argv[])
76{
77 return ns3::main(argc, argv);
78}