examples/csma-multicast.cc
changeset 2887 9a637e6daee0
parent 2860 9105a5cf6535
child 2888 872dc8466352
equal deleted inserted replaced
2886:8226157800a8 2887:9a637e6daee0
    76   CsmaHelper csma;
    76   CsmaHelper csma;
    77   csma.SetChannelParameter ("BitRate", DataRate (5000000));
    77   csma.SetChannelParameter ("BitRate", DataRate (5000000));
    78   csma.SetChannelParameter ("Delay", MilliSeconds (2));
    78   csma.SetChannelParameter ("Delay", MilliSeconds (2));
    79  
    79  
    80   // We will use these NetDevice containers later, for IP addressing
    80   // We will use these NetDevice containers later, for IP addressing
    81   NetDeviceContainer nd0 = csma.Build (c0);  // First LAN
    81   NetDeviceContainer nd0 = csma.Install (c0);  // First LAN
    82   NetDeviceContainer nd1 = csma.Build (c1);  // Second LAN
    82   NetDeviceContainer nd1 = csma.Install (c1);  // Second LAN
    83 
    83 
    84   NS_LOG_INFO ("Add IP Stack.");
    84   NS_LOG_INFO ("Add IP Stack.");
    85   InternetStackHelper internet;
    85   InternetStackHelper internet;
    86   internet.Build (c0);
    86   internet.Install (c0);
    87   internet.Build (c1);
    87   internet.Install (c1);
    88 
    88 
    89   NS_LOG_INFO ("Assign IP Addresses.");
    89   NS_LOG_INFO ("Assign IP Addresses.");
    90   Ipv4AddressHelper ipv4Addr;
    90   Ipv4AddressHelper ipv4Addr;
    91   ipv4Addr.SetBase ("10.1.1.0", "255.255.255.0");
    91   ipv4Addr.SetBase ("10.1.1.0", "255.255.255.0");
    92   ipv4Addr.Allocate (nd0);
    92   ipv4Addr.Allocate (nd0);
   145   onoff.SetAppAttribute ("OnTime", ConstantVariable (1));
   145   onoff.SetAppAttribute ("OnTime", ConstantVariable (1));
   146   onoff.SetAppAttribute ("OffTime", ConstantVariable (0));
   146   onoff.SetAppAttribute ("OffTime", ConstantVariable (0));
   147   onoff.SetAppAttribute ("DataRate", DataRate ("255b/s"));
   147   onoff.SetAppAttribute ("DataRate", DataRate ("255b/s"));
   148   onoff.SetAppAttribute ("PacketSize", Uinteger (128));
   148   onoff.SetAppAttribute ("PacketSize", Uinteger (128));
   149 
   149 
   150   ApplicationContainer srcC = onoff.Build (c0.Get (0));
   150   ApplicationContainer srcC = onoff.Install (c0.Get (0));
   151 
   151 
   152   //
   152   //
   153   // Tell the application when to start and stop.
   153   // Tell the application when to start and stop.
   154   //
   154   //
   155   srcC.Start(Seconds(1.));
   155   srcC.Start(Seconds(1.));
   156   srcC.Stop (Seconds(10.));
   156   srcC.Stop (Seconds(10.));
   157 
   157 
   158   // Create an optional packet sink to receive these packets
   158   // Create an optional packet sink to receive these packets
   159   PacketSinkHelper sink;
   159   PacketSinkHelper sink;
   160   sink.SetupUdp (Ipv4Address::GetAny(), multicastPort);
   160   sink.SetupUdp (Ipv4Address::GetAny(), multicastPort);
   161   ApplicationContainer sinkC = sink.Build (c1.Get (2)); // Node n4 
   161   ApplicationContainer sinkC = sink.Install (c1.Get (2)); // Node n4 
   162   // Start the sink
   162   // Start the sink
   163   sinkC.Start (Seconds (1.0));
   163   sinkC.Start (Seconds (1.0));
   164   sinkC.Stop (Seconds (10.0));
   164   sinkC.Stop (Seconds (10.0));
   165 
   165 
   166   //
   166   //