181 NS_LOG_INFO ("Create Application."); |
181 NS_LOG_INFO ("Create Application."); |
182 uint16_t port = 9; // Discard port (RFC 863) |
182 uint16_t port = 9; // Discard port (RFC 863) |
183 |
183 |
184 // Create a flow from n3 to n1, starting at time 1.1 seconds |
184 // Create a flow from n3 to n1, starting at time 1.1 seconds |
185 Ptr<OnOffApplication> ooff = |
185 Ptr<OnOffApplication> ooff = |
186 CreateObject<OnOffApplication> ( |
186 CreateObject<OnOffApplication> ("Remote", Address (InetSocketAddress ("10.1.1.1", port)), |
187 "Node", n3, |
187 "Protocol", TypeId::LookupByName ("Udp"), |
188 "Remote", Address (InetSocketAddress ("10.1.1.1", port)), |
188 "OnTime", ConstantVariable (1), |
189 "Protocol", TypeId::LookupByName ("Udp"), |
189 "OffTime", ConstantVariable (0)); |
190 "OnTime", ConstantVariable (1), |
|
191 "OffTime", ConstantVariable (0)); |
|
192 n3->AddApplication (ooff); |
190 n3->AddApplication (ooff); |
193 // Start the application |
191 // Start the application |
194 ooff->Start (Seconds (1.1)); |
192 ooff->Start (Seconds (1.1)); |
195 ooff->Stop (Seconds (10.0)); |
193 ooff->Stop (Seconds (10.0)); |
196 |
194 |
197 // Create a packet sink to receive these packets |
195 // Create a packet sink to receive these packets |
198 Ptr<PacketSink> sink = |
196 Ptr<PacketSink> sink = |
199 CreateObject<PacketSink> ( |
197 CreateObject<PacketSink> ("Remote", Address (InetSocketAddress (Ipv4Address::GetAny (), port)), |
200 "Node", n1, |
198 "Protocol", TypeId::LookupByName ("Udp")); |
201 "Remote", Address (InetSocketAddress (Ipv4Address::GetAny (), port)), |
|
202 "Protocol", TypeId::LookupByName ("Udp")); |
|
203 n1->AddApplication (sink); |
199 n1->AddApplication (sink); |
204 // Start the sink |
200 // Start the sink |
205 sink->Start (Seconds (1.1)); |
201 sink->Start (Seconds (1.1)); |
206 sink->Stop (Seconds (10.0)); |
202 sink->Stop (Seconds (10.0)); |
207 |
203 |