src/csma/examples/csma-packet-socket.cc
changeset 8966 060dba23e9bb
parent 7256 b04ba6772f8c
child 9000 3ec20a64fd08
equal deleted inserted replaced
8965:cfed4f87e003 8966:060dba23e9bb
    86   PacketSocketAddress socket;
    86   PacketSocketAddress socket;
    87   socket.SetSingleDevice (devs.Get (0)->GetIfIndex ());
    87   socket.SetSingleDevice (devs.Get (0)->GetIfIndex ());
    88   socket.SetPhysicalAddress (devs.Get (1)->GetAddress ());
    88   socket.SetPhysicalAddress (devs.Get (1)->GetAddress ());
    89   socket.SetProtocol (2);
    89   socket.SetProtocol (2);
    90   OnOffHelper onoff ("ns3::PacketSocketFactory", Address (socket));
    90   OnOffHelper onoff ("ns3::PacketSocketFactory", Address (socket));
    91   onoff.SetAttribute ("OnTime", RandomVariableValue (ConstantVariable (1.0)));
    91   onoff.SetAttribute ("OnTime", StringValue ("ns3::ConstantRandomVariable[Constant=1]"));
    92   onoff.SetAttribute ("OffTime", RandomVariableValue (ConstantVariable (0.0)));
    92   onoff.SetAttribute ("OffTime", StringValue ("ns3::ConstantRandomVariable[Constant=0]"));
    93   ApplicationContainer apps = onoff.Install (nodes.Get (0));
    93   ApplicationContainer apps = onoff.Install (nodes.Get (0));
    94   apps.Start (Seconds (1.0));
    94   apps.Start (Seconds (1.0));
    95   apps.Stop (Seconds (10.0));
    95   apps.Stop (Seconds (10.0));
    96 
    96 
    97   socket.SetSingleDevice (devs.Get (3)->GetIfIndex ());
    97   socket.SetSingleDevice (devs.Get (3)->GetIfIndex ());
    98   socket.SetPhysicalAddress (devs.Get (0)->GetAddress ());
    98   socket.SetPhysicalAddress (devs.Get (0)->GetAddress ());
    99   socket.SetProtocol (3);
    99   socket.SetProtocol (3);
   100   onoff.SetAttribute ("Remote", AddressValue (socket));
   100   onoff.SetAttribute ("Remote", AddressValue (socket));
   101   onoff.SetAttribute ("OffTime", RandomVariableValue (ConstantVariable (0.0)));
       
   102   apps = onoff.Install (nodes.Get (3));
   101   apps = onoff.Install (nodes.Get (3));
   103   apps.Start (Seconds (1.0));
   102   apps.Start (Seconds (1.0));
   104   apps.Stop (Seconds (10.0));
   103   apps.Stop (Seconds (10.0));
   105 
   104 
   106   // Install packet sink on node 0 to receive packets from node 1
   105   // Install packet sink on node 0 to receive packets from node 1