examples/simple-point-to-point-olsr.cc
changeset 2887 9a637e6daee0
parent 2860 9105a5cf6535
child 2888 872dc8466352
equal deleted inserted replaced
2886:8226157800a8 2887:9a637e6daee0
    85   NodeContainer n12 = NodeContainer (c.Get(1), c.Get (2));
    85   NodeContainer n12 = NodeContainer (c.Get(1), c.Get (2));
    86   NodeContainer n32 = NodeContainer (c.Get(3), c.Get (2));
    86   NodeContainer n32 = NodeContainer (c.Get(3), c.Get (2));
    87   NodeContainer n34 = NodeContainer (c.Get (3), c.Get (4));
    87   NodeContainer n34 = NodeContainer (c.Get (3), c.Get (4));
    88 
    88 
    89   InternetStackHelper internet;
    89   InternetStackHelper internet;
    90   internet.Build (c);
    90   internet.Install (c);
    91 
    91 
    92   // We create the channels first without any IP addressing information
    92   // We create the channels first without any IP addressing information
    93   NS_LOG_INFO ("Create channels.");
    93   NS_LOG_INFO ("Create channels.");
    94   PointToPointHelper p2p;
    94   PointToPointHelper p2p;
    95   p2p.SetChannelParameter ("BitRate", DataRate (5000000));
    95   p2p.SetChannelParameter ("BitRate", DataRate (5000000));
    96   p2p.SetChannelParameter ("Delay", MilliSeconds (2));
    96   p2p.SetChannelParameter ("Delay", MilliSeconds (2));
    97   NetDeviceContainer nd02 = p2p.Build (n02);
    97   NetDeviceContainer nd02 = p2p.Install (n02);
    98   NetDeviceContainer nd12 = p2p.Build (n12);
    98   NetDeviceContainer nd12 = p2p.Install (n12);
    99   p2p.SetChannelParameter ("BitRate", DataRate (1500000));
    99   p2p.SetChannelParameter ("BitRate", DataRate (1500000));
   100   p2p.SetChannelParameter ("Delay", MilliSeconds (10));
   100   p2p.SetChannelParameter ("Delay", MilliSeconds (10));
   101   NetDeviceContainer nd32 = p2p.Build (n32);
   101   NetDeviceContainer nd32 = p2p.Install (n32);
   102   NetDeviceContainer nd34 = p2p.Build (n34);
   102   NetDeviceContainer nd34 = p2p.Install (n34);
   103   
   103   
   104   // Later, we add IP addresses.  
   104   // Later, we add IP addresses.  
   105   NS_LOG_INFO ("Assign IP Addresses.");
   105   NS_LOG_INFO ("Assign IP Addresses.");
   106   Ipv4AddressHelper ipv4;
   106   Ipv4AddressHelper ipv4;
   107   ipv4.SetBase ("10.1.1.0", "255.255.255.0");
   107   ipv4.SetBase ("10.1.1.0", "255.255.255.0");
   127   uint16_t port = 9;   // Discard port (RFC 863)
   127   uint16_t port = 9;   // Discard port (RFC 863)
   128   OnOffHelper onoff;
   128   OnOffHelper onoff;
   129   onoff.SetAppAttribute ("OnTime", ConstantVariable (1));
   129   onoff.SetAppAttribute ("OnTime", ConstantVariable (1));
   130   onoff.SetAppAttribute ("OffTime", ConstantVariable (0));
   130   onoff.SetAppAttribute ("OffTime", ConstantVariable (0));
   131   onoff.SetUdpRemote (i34.GetAddress (1), port);
   131   onoff.SetUdpRemote (i34.GetAddress (1), port);
   132   ApplicationContainer apps = onoff.Build (c.Get (0));
   132   ApplicationContainer apps = onoff.Install (c.Get (0));
   133   apps.Start (Seconds (1.0));
   133   apps.Start (Seconds (1.0));
   134   apps.Stop (Seconds (10.0));
   134   apps.Stop (Seconds (10.0));
   135 
   135 
   136   // Create a packet sink to receive these packets
   136   // Create a packet sink to receive these packets
   137   PacketSinkHelper sink;
   137   PacketSinkHelper sink;
   138   sink.SetupUdp (Ipv4Address::GetAny (), port);
   138   sink.SetupUdp (Ipv4Address::GetAny (), port);
   139   apps = sink.Build (c.Get (3));
   139   apps = sink.Install (c.Get (3));
   140   apps.Start (Seconds (1.0));
   140   apps.Start (Seconds (1.0));
   141   apps.Stop (Seconds (10.0));
   141   apps.Stop (Seconds (10.0));
   142 
   142 
   143   // Create a similar flow from n3 to n1, starting at time 1.1 seconds
   143   // Create a similar flow from n3 to n1, starting at time 1.1 seconds
   144   onoff.SetUdpRemote (i12.GetAddress (0), port);
   144   onoff.SetUdpRemote (i12.GetAddress (0), port);
   145   apps = onoff.Build (c.Get (3));
   145   apps = onoff.Install (c.Get (3));
   146   apps.Start (Seconds (1.1));
   146   apps.Start (Seconds (1.1));
   147   apps.Stop (Seconds (10.0));
   147   apps.Stop (Seconds (10.0));
   148 
   148 
   149   // Create a packet sink to receive these packets
   149   // Create a packet sink to receive these packets
   150   apps = sink.Build (c.Get (1));
   150   apps = sink.Install (c.Get (1));
   151   apps.Start (Seconds (1.1));
   151   apps.Start (Seconds (1.1));
   152   apps.Stop (Seconds (10.0));
   152   apps.Stop (Seconds (10.0));
   153 
   153 
   154   std::ofstream ascii;
   154   std::ofstream ascii;
   155   ascii.open ("simple-point-to-point-olsr.tr");
   155   ascii.open ("simple-point-to-point-olsr.tr");