src/csma/examples/csma-multicast.cc
changeset 7256 b04ba6772f8c
parent 7170 8417cff6e353
child 8966 060dba23e9bb
equal deleted inserted replaced
7255:193b2ac517a0 7256:b04ba6772f8c
   117   multicast.AddMulticastRoute (multicastRouter, multicastSource, 
   117   multicast.AddMulticastRoute (multicastRouter, multicastSource, 
   118                                multicastGroup, inputIf, outputDevices);
   118                                multicastGroup, inputIf, outputDevices);
   119 
   119 
   120   // 2) Set up a default multicast route on the sender n0 
   120   // 2) Set up a default multicast route on the sender n0 
   121   Ptr<Node> sender = c.Get (0);
   121   Ptr<Node> sender = c.Get (0);
   122   Ptr<NetDevice> senderIf = nd0.Get(0);
   122   Ptr<NetDevice> senderIf = nd0.Get (0);
   123   multicast.SetDefaultMulticastRoute (sender, senderIf);
   123   multicast.SetDefaultMulticastRoute (sender, senderIf);
   124 
   124 
   125   //
   125   //
   126   // Create an OnOff application to send UDP datagrams from node zero to the
   126   // Create an OnOff application to send UDP datagrams from node zero to the
   127   // multicast group (node four will be listening).
   127   // multicast group (node four will be listening).
   142   ApplicationContainer srcC = onoff.Install (c0.Get (0));
   142   ApplicationContainer srcC = onoff.Install (c0.Get (0));
   143 
   143 
   144   //
   144   //
   145   // Tell the application when to start and stop.
   145   // Tell the application when to start and stop.
   146   //
   146   //
   147   srcC.Start(Seconds(1.));
   147   srcC.Start (Seconds (1.));
   148   srcC.Stop (Seconds(10.));
   148   srcC.Stop (Seconds (10.));
   149 
   149 
   150   // Create an optional packet sink to receive these packets
   150   // Create an optional packet sink to receive these packets
   151   PacketSinkHelper sink ("ns3::UdpSocketFactory",
   151   PacketSinkHelper sink ("ns3::UdpSocketFactory",
   152                          InetSocketAddress (Ipv4Address::GetAny(), multicastPort));
   152                          InetSocketAddress (Ipv4Address::GetAny (), multicastPort));
   153 
   153 
   154   ApplicationContainer sinkC = sink.Install (c1.Get (2)); // Node n4 
   154   ApplicationContainer sinkC = sink.Install (c1.Get (2)); // Node n4 
   155   // Start the sink
   155   // Start the sink
   156   sinkC.Start (Seconds (1.0));
   156   sinkC.Start (Seconds (1.0));
   157   sinkC.Stop (Seconds (10.0));
   157   sinkC.Stop (Seconds (10.0));