165 // Create the OnOff application to send UDP datagrams of size |
165 // Create the OnOff application to send UDP datagrams of size |
166 // 210 bytes at a rate of 448 Kb/s |
166 // 210 bytes at a rate of 448 Kb/s |
167 NS_LOG_INFO ("Create Applications."); |
167 NS_LOG_INFO ("Create Applications."); |
168 uint16_t port = 9; // Discard port (RFC 863) |
168 uint16_t port = 9; // Discard port (RFC 863) |
169 Ptr<OnOffApplication> ooff = |
169 Ptr<OnOffApplication> ooff = |
170 CreateObject<OnOffApplication> ( |
170 CreateObject<OnOffApplication> ("Remote", Address (InetSocketAddress ("10.1.4.2", port)), |
171 "Node", n0, |
171 "Protocol", TypeId::LookupByName ("Udp"), |
172 "Remote", Address (InetSocketAddress ("10.1.4.2", port)), |
172 "OnTime", ConstantVariable(1), |
173 "Protocol", TypeId::LookupByName ("Udp"), |
173 "OffTime", ConstantVariable(0)); |
174 "OnTime", ConstantVariable(1), |
|
175 "OffTime", ConstantVariable(0)); |
|
176 n0->AddApplication (ooff); |
174 n0->AddApplication (ooff); |
177 // Start the application |
175 // Start the application |
178 ooff->Start(Seconds(1.0)); |
176 ooff->Start(Seconds(1.0)); |
179 |
177 |
180 // Create an optional packet sink to receive these packets |
178 // Create an optional packet sink to receive these packets |
181 Ptr<PacketSink> sink = |
179 Ptr<PacketSink> sink = |
182 CreateObject<PacketSink> ( |
180 CreateObject<PacketSink> ("Local", Address (InetSocketAddress (Ipv4Address::GetAny (), port)), |
183 "Node", n4, |
181 "Protocol", TypeId::LookupByName ("Udp")); |
184 "Local", Address (InetSocketAddress (Ipv4Address::GetAny (), port)), |
|
185 "Protocol", TypeId::LookupByName ("Udp")); |
|
186 n3->AddApplication (sink); |
182 n3->AddApplication (sink); |
187 // Start the sink |
183 // Start the sink |
188 sink->Start (Seconds (1.0)); |
184 sink->Start (Seconds (1.0)); |
189 |
185 |
190 // Create a similar flow from n3 to n1, starting at time 1.1 seconds |
186 // Create a similar flow from n3 to n1, starting at time 1.1 seconds |
191 ooff = CreateObject<OnOffApplication> ( |
187 ooff = CreateObject<OnOffApplication> ("Remote", Address (InetSocketAddress ("10.1.2.1", port)), |
192 "Node", n4, |
188 "Protocol", TypeId::LookupByName ("Udp"), |
193 "Remote", Address (InetSocketAddress ("10.1.2.1", port)), |
189 "OnTime", ConstantVariable(1), |
194 "Protocol", TypeId::LookupByName ("Udp"), |
190 "OffTime", ConstantVariable(0)); |
195 "OnTime", ConstantVariable(1), |
|
196 "OffTime", ConstantVariable(0)); |
|
197 n3->AddApplication (ooff); |
191 n3->AddApplication (ooff); |
198 // Start the application |
192 // Start the application |
199 ooff->Start (Seconds(1.1)); |
193 ooff->Start (Seconds(1.1)); |
200 |
194 |
201 // Create a packet sink to receive these packets |
195 // Create a packet sink to receive these packets |
202 sink = CreateObject<PacketSink> ( |
196 sink = CreateObject<PacketSink> ("Local", Address (InetSocketAddress (Ipv4Address::GetAny (), port)), |
203 "Node", n1, |
197 "Protocol", TypeId::LookupByName ("Udp")); |
204 "Local", Address (InetSocketAddress (Ipv4Address::GetAny (), port)), |
|
205 "Protocol", TypeId::LookupByName ("Udp")); |
|
206 n1->AddApplication (sink); |
198 n1->AddApplication (sink); |
207 // Start the sink |
199 // Start the sink |
208 sink->Start (Seconds (1.1)); |
200 sink->Start (Seconds (1.1)); |
209 |
201 |
210 // Configure tracing of all enqueue, dequeue, and NetDevice receive events |
202 // Configure tracing of all enqueue, dequeue, and NetDevice receive events |