|
30 |
clock_t finish; |
30 |
clock_t finish; |
31 |
double diff; |
31 |
double diff; |
32 |
|
32 |
|
33 |
double simtime=2.0; |
33 |
double simtime=12.0; |
34 |
uint16_t port = 200; |
34 |
uint16_t port = 200; |
35 |
//uint32_t nPackets = 1; |
35 |
//uint32_t nPackets = 1; |
36 |
uint32_t nNodes = 3; |
36 |
uint32_t nNodes = 3; |
|
125 |
|
125 |
|
126 |
Ipv4AddressHelper address; |
126 |
Ipv4AddressHelper address; |
127 |
|
127 |
|
128 |
address.SetBase("192.168.0.0","255.255.255.0"); |
128 |
address.SetBase("192.168.0.0","255.255.255.255"); |
129 |
Ipv4InterfaceContainer wifiInterfaces; |
129 |
Ipv4InterfaceContainer wifiInterfaces; |
130 |
wifiInterfaces = address.Assign (wifiDevices); |
130 |
wifiInterfaces = address.Assign (wifiDevices); |
131 |
|
131 |
|
|
137 |
NS_LOG_INFO ("Enabling OLSR routing on all backbone nodes"); |
137 |
NS_LOG_INFO ("Enabling OLSR routing on all backbone nodes"); |
138 |
OlsrHelper olsr; |
138 |
OlsrHelper olsr; |
139 |
olsr.Install(meshNodes); |
139 |
olsr.Install(meshNodes); |
|
|
140 |
olsr.Install(internetNodes); |
140 |
|
141 |
|
141 |
GlobalRouteManager::PopulateRoutingTables (); |
|
|
142 |
|
143 |
OnOffHelper onoff ("ns3::UdpSocketFactory",InetSocketAddress(csmaInterfaces.GetAddress (0),port)); |
142 |
OnOffHelper onoff ("ns3::UdpSocketFactory",InetSocketAddress(csmaInterfaces.GetAddress (0),port)); |
144 |
onoff.SetAttribute ("OnTime", RandomVariableValue (ConstantVariable (simtime))); |
143 |
onoff.SetAttribute ("OnTime", RandomVariableValue (ConstantVariable (simtime))); |
145 |
onoff.SetAttribute ("OffTime", RandomVariableValue (ConstantVariable (0))); |
144 |
onoff.SetAttribute ("OffTime", RandomVariableValue (ConstantVariable (0))); |
|
157 |
|
156 |
|
158 |
|
157 |
|
159 |
ApplicationContainer internetApps = sink.Install(internetNodes); |
158 |
ApplicationContainer internetApps = sink.Install(internetNodes); |
160 |
internetApps.Start (Seconds (0)); |
159 |
internetApps.Start (Seconds (10)); |
161 |
internetApps.Stop (Seconds (simtime)); |
160 |
internetApps.Stop (Seconds (simtime)); |
162 |
|
161 |
|
163 |
Simulator::Stop (Seconds (simtime)); |
162 |
Simulator::Stop (Seconds (simtime)); |