examples/csma-broadcast.cc
changeset 2602 d9262bff6df2
parent 2600 6c389d0c717d
child 2732 4229b69af295
equal deleted inserted replaced
2601:4297e8c61615 2602:d9262bff6df2
   148   // Create the OnOff application to send UDP datagrams of size
   148   // Create the OnOff application to send UDP datagrams of size
   149   // 512 bytes (default) at a rate of 500 Kb/s (default) from n0
   149   // 512 bytes (default) at a rate of 500 Kb/s (default) from n0
   150   NS_LOG_INFO ("Create Applications.");
   150   NS_LOG_INFO ("Create Applications.");
   151   Ptr<OnOffApplication> ooff = 
   151   Ptr<OnOffApplication> ooff = 
   152     CreateObject<OnOffApplication> ("Remote", Address (InetSocketAddress ("255.255.255.255", port)), 
   152     CreateObject<OnOffApplication> ("Remote", Address (InetSocketAddress ("255.255.255.255", port)), 
   153                                     "Protocol", TypeId::LookupByName ("Udp"),
   153                                     "Protocol", TypeId::LookupByName ("ns3::Udp"),
   154                                     "OnTime", ConstantVariable(1), 
   154                                     "OnTime", ConstantVariable(1), 
   155                                     "OffTime", ConstantVariable(0));
   155                                     "OffTime", ConstantVariable(0));
   156   n0->AddApplication (ooff);
   156   n0->AddApplication (ooff);
   157   // Start the application
   157   // Start the application
   158   ooff->Start(Seconds(1.0));
   158   ooff->Start(Seconds(1.0));
   159   ooff->Stop (Seconds(10.0));
   159   ooff->Stop (Seconds(10.0));
   160   
   160   
   161   // Create an optional packet sink to receive these packets
   161   // Create an optional packet sink to receive these packets
   162   Ptr<PacketSink> sink = 
   162   Ptr<PacketSink> sink = 
   163     CreateObject<PacketSink> ("Local", Address (InetSocketAddress (Ipv4Address::GetAny (), port)),
   163     CreateObject<PacketSink> ("Local", Address (InetSocketAddress (Ipv4Address::GetAny (), port)),
   164                               "Protocol", TypeId::LookupByName ("Udp"));
   164                               "Protocol", TypeId::LookupByName ("ns3::Udp"));
   165   n1->AddApplication (sink);
   165   n1->AddApplication (sink);
   166   // Start the sink
   166   // Start the sink
   167   sink->Start (Seconds (1.0));
   167   sink->Start (Seconds (1.0));
   168   sink->Stop (Seconds (10.0));
   168   sink->Stop (Seconds (10.0));
   169 
   169 
   170   // Create an optional packet sink to receive these packets
   170   // Create an optional packet sink to receive these packets
   171   sink = CreateObject<PacketSink> ("Local", Address (InetSocketAddress (Ipv4Address::GetAny (), port)),
   171   sink = CreateObject<PacketSink> ("Local", Address (InetSocketAddress (Ipv4Address::GetAny (), port)),
   172                                    "Protocol", TypeId::LookupByName ("Udp"));
   172                                    "Protocol", TypeId::LookupByName ("ns3::Udp"));
   173   n2->AddApplication (sink);
   173   n2->AddApplication (sink);
   174 
   174 
   175   // Start the sink
   175   // Start the sink
   176   sink->Start (Seconds (1.0));
   176   sink->Start (Seconds (1.0));
   177   sink->Stop (Seconds (10.0));
   177   sink->Stop (Seconds (10.0));