examples/simple-error-model.cc
changeset 2602 d9262bff6df2
parent 2600 6c389d0c717d
child 2613 0e1267814e1c
equal deleted inserted replaced
2601:4297e8c61615 2602:d9262bff6df2
   142   // 210 bytes at a rate of 448 Kb/s
   142   // 210 bytes at a rate of 448 Kb/s
   143   NS_LOG_INFO ("Create Applications.");
   143   NS_LOG_INFO ("Create Applications.");
   144   uint16_t port = 9;   // Discard port (RFC 863)
   144   uint16_t port = 9;   // Discard port (RFC 863)
   145   Ptr<OnOffApplication> ooff = 
   145   Ptr<OnOffApplication> ooff = 
   146     CreateObject<OnOffApplication> ("Remote", Address (InetSocketAddress ("10.1.3.2", port)), 
   146     CreateObject<OnOffApplication> ("Remote", Address (InetSocketAddress ("10.1.3.2", port)), 
   147                                     "Protocol", TypeId::LookupByName ("Udp"),
   147                                     "Protocol", TypeId::LookupByName ("ns3::Udp"),
   148                                     "OnTime", ConstantVariable(1), 
   148                                     "OnTime", ConstantVariable(1), 
   149                                     "OffTime", ConstantVariable(0));
   149                                     "OffTime", ConstantVariable(0));
   150   n0->AddApplication (ooff);
   150   n0->AddApplication (ooff);
   151   // Start the application
   151   // Start the application
   152   ooff->Start(Seconds(1.0));
   152   ooff->Start(Seconds(1.0));
   153   ooff->Stop (Seconds(10.0));
   153   ooff->Stop (Seconds(10.0));
   154 
   154 
   155   // Create an optional packet sink to receive these packets
   155   // Create an optional packet sink to receive these packets
   156   Ptr<PacketSink> sink = CreateObject<PacketSink> ("Local", Address (InetSocketAddress (Ipv4Address::GetAny (), port)),
   156   Ptr<PacketSink> sink = CreateObject<PacketSink> ("Local", Address (InetSocketAddress (Ipv4Address::GetAny (), port)),
   157                                                    "Protocol", TypeId::LookupByName ("Udp"));
   157                                                    "Protocol", TypeId::LookupByName ("ns3::Udp"));
   158   n3->AddApplication (sink);
   158   n3->AddApplication (sink);
   159   // Start the sink
   159   // Start the sink
   160   sink->Start (Seconds (1.0));
   160   sink->Start (Seconds (1.0));
   161   sink->Stop (Seconds (10.0));
   161   sink->Stop (Seconds (10.0));
   162 
   162 
   163   // Create a similar flow from n3 to n1, starting at time 1.1 seconds
   163   // Create a similar flow from n3 to n1, starting at time 1.1 seconds
   164   ooff = CreateObject<OnOffApplication> ("Remote", Address (InetSocketAddress ("10.1.2.1", port)), 
   164   ooff = CreateObject<OnOffApplication> ("Remote", Address (InetSocketAddress ("10.1.2.1", port)), 
   165                                          "Protocol", TypeId::LookupByName ("Udp"),
   165                                          "Protocol", TypeId::LookupByName ("ns3::Udp"),
   166                                          "OnTime", ConstantVariable(1), 
   166                                          "OnTime", ConstantVariable(1), 
   167                                          "OffTime", ConstantVariable(0));
   167                                          "OffTime", ConstantVariable(0));
   168   n3->AddApplication (ooff);
   168   n3->AddApplication (ooff);
   169   // Start the application
   169   // Start the application
   170   ooff->Start(Seconds(1.1));
   170   ooff->Start(Seconds(1.1));
   171   ooff->Stop (Seconds(10.0));
   171   ooff->Stop (Seconds(10.0));
   172 
   172 
   173   // Create a packet sink to receive these packets
   173   // Create a packet sink to receive these packets
   174   sink = CreateObject<PacketSink> ("Local", Address (InetSocketAddress (Ipv4Address::GetAny (), port)),
   174   sink = CreateObject<PacketSink> ("Local", Address (InetSocketAddress (Ipv4Address::GetAny (), port)),
   175                                    "Protocol", TypeId::LookupByName ("Udp"));
   175                                    "Protocol", TypeId::LookupByName ("ns3::Udp"));
   176   n1->AddApplication (sink);
   176   n1->AddApplication (sink);
   177   // Start the sink
   177   // Start the sink
   178   sink->Start (Seconds (1.1));
   178   sink->Start (Seconds (1.1));
   179   sink->Stop (Seconds (10.0));
   179   sink->Stop (Seconds (10.0));
   180 
   180