Left: | ||
Right: |
OLD | NEW |
---|---|
(Empty) | |
1 #include "ns3/core-module.h" | |
2 #include "ns3/network-module.h" | |
3 #include "ns3/applications-module.h" | |
4 #include "ns3/mobility-module.h" | |
5 #include "ns3/config-store-module.h" | |
Tom Henderson
2013/12/08 22:24:26
Is config-store-module.h needed?
mjf.alenazi
2013/12/30 23:11:11
Done.
| |
6 #include "ns3/wifi-module.h" | |
7 #include "ns3/internet-module.h" | |
8 #include <iostream> | |
9 | |
10 #include "ns3/dsdv-module.h" | |
11 #include "ns3/epidemic-helper.h" | |
12 #include "ns3/aodv-module.h" | |
13 #include "ns3/dsr-module.h" | |
14 #include "ns3/olsr-module.h" | |
Tom Henderson
2013/12/08 22:24:26
are all of these headers needed? Strip out unneed
mjf.alenazi
2013/12/30 23:11:11
Done.
| |
15 #include <cmath> | |
16 #include <time.h> | |
Tom Henderson
2013/12/08 22:24:26
I don't see usage of cmath or time.h below.
mjf.alenazi
2013/12/30 23:11:11
Done.
| |
17 using namespace ns3; | |
18 | |
19 /** | |
20 This example creates an N-node wireless network, which is set by default to 10 nodes. | |
21 The mobility model can be either static Grid or Randomwaypoint, which by defau lt is selected to be Grid. | |
Tom Henderson
2013/12/08 22:24:26
Why selected to be Grid? There is no intermittent
mjf.alenazi
2013/12/30 23:11:11
The user can use either Grid or RandomWaypoint. Gr
| |
22 The data traffic is generated using OnOff application and received by PacketSi nk. There is one source and | |
23 one sink in this configuration. | |
24 */ | |
25 | |
26 | |
27 NS_LOG_COMPONENT_DEFINE ("EpidemicScript"); | |
Peter Barnes
2013/12/10 00:02:33
Perhaps "EpidemicExample"
mjf.alenazi
2013/12/30 23:11:11
Done.
| |
28 int main (int argc, char *argv[]) | |
29 { | |
30 // General parameters | |
31 std::string mobility_model = "Grid"; // Grid or RandomWaypoint | |
32 uint32_t nWifis = 10; | |
33 NodeContainer nodeContainer; | |
34 NetDeviceContainer devices; | |
35 double txpDistance = 120.0; | |
36 double nodeSpeed = 50.0; | |
37 bool app_logging = true; | |
38 | |
Tom Henderson
2013/12/08 22:24:26
These could all be made command-line configurable
mjf.alenazi
2013/12/30 23:11:11
Done.
| |
39 | |
40 /* | |
41 * Enabling OnOffApplication and PacketSink logging | |
42 * */ | |
43 if (app_logging) | |
44 { | |
45 LogComponentEnable ("OnOffApplication", LOG_LEVEL_INFO); | |
46 LogComponentEnable ("PacketSink", LOG_LEVEL_INFO); | |
47 LogComponentEnableAll (LOG_PREFIX_TIME); | |
48 LogComponentEnableAll (LOG_PREFIX_NODE); | |
49 LogComponentEnableAll (LOG_PREFIX_FUNC); | |
50 } | |
51 | |
52 SeedManager::SetSeed (7); | |
Tom Henderson
2013/12/08 22:24:26
Why is seed set to 7 and not the default?
mjf.alenazi
2013/12/30 23:11:11
Done.
| |
53 | |
54 | |
55 LogComponentEnable ("EpidemicScript", LOG_LEVEL_ALL); | |
56 nodeContainer.Create (nWifis); | |
57 | |
58 | |
59 /* | |
60 * Mobility model Setup | |
61 * */ | |
62 MobilityHelper mobility; | |
63 if (mobility_model == "Grid") | |
64 { | |
65 int internode_distance = 100; | |
66 Ptr<GridPositionAllocator> positionAlloc; | |
67 positionAlloc = CreateObject<GridPositionAllocator> (); | |
68 positionAlloc->SetDeltaX (internode_distance); | |
69 mobility.SetPositionAllocator (positionAlloc); | |
70 | |
71 } | |
72 else if (mobility_model == "RandomWaypoint") | |
73 { | |
74 ObjectFactory pos; | |
75 mobility.SetPositionAllocator ("ns3::RandomDiscPositionAllocator", | |
76 "X", StringValue ("100.0"), | |
77 "Y", StringValue ("100.0"), | |
78 "Rho", StringValue ("ns3::UniformRandomVari able[Min=0|Max=30]")); | |
Tom Henderson
2013/12/08 22:24:26
Perhaps add a comment on the initial distribution
mjf.alenazi
2013/12/30 23:11:11
Done.
| |
79 | |
80 mobility.SetMobilityModel ("ns3::SteadyStateRandomWaypointMobilityModel", | |
81 "MinSpeed", DoubleValue (0.01), | |
82 "MaxSpeed", DoubleValue (nodeSpeed), | |
83 "MinX", DoubleValue (0.0), | |
84 "MaxX", DoubleValue (300.0), | |
85 "MinPause", DoubleValue (10), | |
86 "MaxPause", DoubleValue (20), | |
87 "MinY", DoubleValue (0.0), | |
88 "MaxY", DoubleValue (1500.0) | |
89 ); | |
Tom Henderson
2013/12/08 22:24:26
Perhaps add a comment on the mobility model of thi
mjf.alenazi
2013/12/30 23:11:11
Done.
mjf.alenazi
2013/12/30 23:11:11
Yes
On 2013/12/08 22:24:26, Tom Henderson wrote:
| |
90 } | |
91 mobility.Install (nodeContainer); | |
92 | |
93 | |
94 /* | |
95 * Physical and link Layers Setup | |
96 * */ | |
97 | |
98 NqosWifiMacHelper wifiMac = NqosWifiMacHelper::Default (); | |
99 wifiMac.SetType ("ns3::AdhocWifiMac"); | |
100 YansWifiPhyHelper wifiPhy = YansWifiPhyHelper::Default (); | |
101 YansWifiChannelHelper wifiChannel = YansWifiChannelHelper::Default (); | |
102 | |
103 wifiChannel.AddPropagationLoss ("ns3::RangePropagationLossModel","MaxRange",Do ubleValue (txpDistance)); | |
104 wifiPhy.SetChannel (wifiChannel.Create ()); | |
Tom Henderson
2013/12/08 22:24:26
Perhaps add a comment to the documentation of this
| |
105 WifiHelper wifi = WifiHelper::Default (); | |
106 wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager", "DataMode", Stri ngValue ("OfdmRate6Mbps"), "RtsCtsThreshold", UintegerValue (0)); | |
107 devices = wifi.Install (wifiPhy, wifiMac, nodeContainer); | |
108 | |
109 | |
110 | |
111 | |
112 /* | |
113 * Epidemic Routing Setup | |
114 * */ | |
115 EpidemicHelper epidemic; | |
116 epidemic.Set ("HopCount", UintegerValue (50)); | |
117 epidemic.Set ("QueueLength", UintegerValue (50)); | |
118 epidemic.Set ("QueueEntryExpireTime", TimeValue (Seconds (100))); | |
119 epidemic.Set ("BeaconInterval", TimeValue (Seconds (1))); | |
Tom Henderson
2013/12/08 22:24:26
The top two Set()s are changing from the defaults.
| |
120 | |
Tom Henderson
2013/12/08 22:24:26
The top two Set() statements change from default v
| |
121 /* | |
122 * Internet Stack Setup | |
123 * */ | |
124 Ipv4ListRoutingHelper list; | |
125 InternetStackHelper internet; | |
126 internet.SetRoutingHelper (epidemic); | |
127 internet.Install (nodeContainer); | |
128 Ipv4AddressHelper ipv4; | |
129 ipv4.SetBase ("10.1.1.0", "255.255.255.0"); | |
130 Ipv4InterfaceContainer interfaces = ipv4.Assign (devices); | |
131 | |
132 | |
133 /* | |
134 * Application Setup | |
135 * */ | |
136 | |
137 // Application parameters | |
138 double TotalTime = 100.0; | |
139 double dataStart = 10.0; | |
140 double dataEnd = 15; | |
141 uint32_t source_num = 0; | |
142 uint32_t sink_num = 9; | |
Tom Henderson
2013/12/08 22:24:26
Should this be hardcoded to nine (if user changes
mjf.alenazi
2013/12/30 23:11:11
Done.
| |
143 | |
144 // Sink or server setup | |
145 PacketSinkHelper sink ("ns3::UdpSocketFactory", InetSocketAddress (Ipv4Address ::GetAny (), 80)); | |
146 ApplicationContainer apps_sink = sink.Install (nodeContainer.Get (sink_num)); | |
147 apps_sink.Start (Seconds (0.0)); | |
148 apps_sink.Stop (Seconds (TotalTime)); | |
149 | |
150 | |
151 // Client setup | |
152 OnOffHelper onoff1 ("ns3::UdpSocketFactory", Address (InetSocketAddress (inter faces.GetAddress (sink_num), 80))); | |
153 onoff1.SetConstantRate (DataRate ("512B/s")); | |
154 onoff1.SetAttribute ("PacketSize",UintegerValue (500)); | |
155 ApplicationContainer apps1 = onoff1.Install (nodeContainer.Get (source_num)); | |
156 apps1.Start (Seconds (dataStart)); | |
157 apps1.Stop (Seconds (dataEnd)); | |
158 | |
159 | |
160 Simulator::Stop (Seconds (TotalTime)); | |
161 Simulator::Run (); | |
162 Simulator::Destroy (); | |
163 return 0; | |
164 } | |
165 | |
OLD | NEW |