blob: 439a56b08aacddab1f9248019b8f57fb192b8729 [file] [log] [blame]
Alexander Afanasyevafe47fe2015-01-06 18:29:39 -08001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/**
3 * Copyright (c) 2011-2015 Regents of the University of California.
4 *
5 * This file is part of ndnSIM. See AUTHORS for complete list of ndnSIM authors and
6 * contributors.
7 *
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.
11 *
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.
15 *
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 **/
19
20// ndn-grid-topo-plugin-loss.cpp
21
22#include "ns3/core-module.h"
23#include "ns3/network-module.h"
24#include "ns3/ndnSIM-module.h"
25
26namespace ns3 {
27
28/**
29 * This scenario simulates a grid topology (using topology reader module)
30 *
31 * (consumer) -- ( ) ----- ( )
32 * | | |
33 * ( ) ------ ( ) ----- ( )
34 * | | |
35 * ( ) ------ ( ) -- (producer)
36 *
37 * All links are 1Mbps with propagation 10ms delay.
38 *
39 * FIB is populated using NdnGlobalRoutingHelper.
40 *
41 * Consumer requests data from producer with frequency 10 interests per second
42 * (interests contain constantly increasing sequence number).
43 *
44 * For every received interest, producer replies with a data packet, containing
45 * 1024 bytes of virtual payload.
46 *
47 * To run scenario and see what is happening, use the following command:
48 *
49 * NS_LOG=ndn.Consumer:ndn.Producer ./waf --run=ndn-grid-topo-plugin
50 */
51
52int
53main(int argc, char* argv[])
54{
55 CommandLine cmd;
56 cmd.Parse(argc, argv);
57
58 AnnotatedTopologyReader topologyReader("", 25);
59 topologyReader.SetFileName("src/ndnSIM/examples/topologies/topo-grid-3x3-loss.txt");
60 topologyReader.Read();
61
62 // Install NDN stack on all nodes
63 ndn::StackHelper ndnHelper;
64 ndnHelper.InstallAll();
65
66 ndn::StrategyChoiceHelper::InstallAll("/", "ndn:/localhost/nfd/strategy/best-route");
67
68 // Installing global routing interface on all nodes
69 ndn::GlobalRoutingHelper ndnGlobalRoutingHelper;
70 ndnGlobalRoutingHelper.InstallAll();
71
72 // Getting containers for the consumer/producer
73 Ptr<Node> producer = Names::Find<Node>("Node8");
74 NodeContainer consumerNodes;
75 consumerNodes.Add(Names::Find<Node>("Node0"));
76
77 // Install NDN applications
78 std::string prefix = "/prefix";
79
80 ndn::AppHelper consumerHelper("ns3::ndn::ConsumerCbr");
81 consumerHelper.SetPrefix(prefix);
82 consumerHelper.SetAttribute("Frequency", StringValue("100")); // 100 interests a second
83 consumerHelper.Install(consumerNodes);
84
85 ndn::AppHelper producerHelper("ns3::ndn::Producer");
86 producerHelper.SetPrefix(prefix);
87 producerHelper.SetAttribute("PayloadSize", StringValue("1024"));
88 producerHelper.Install(producer);
89
90 // Add /prefix origins to ndn::GlobalRouter
91 ndnGlobalRoutingHelper.AddOrigins(prefix, producer);
92
93 // Calculate and install FIBs
94 ndn::GlobalRoutingHelper::CalculateRoutes();
95
96 Simulator::Stop(Seconds(20.0));
97
98 Simulator::Run();
99 Simulator::Destroy();
100
101 return 0;
102}
103} // namespace ns3
104
105int
106main(int argc, char* argv[])
107{
108 return ns3::main(argc, argv);
109}