examples/simple-point-to-point-olsr.cc
changeset 2965 4b28e9740e3b
parent 2890 172baa5960ff
child 2974 30ed185e0364
equal deleted inserted replaced
2964:4e8cb1577144 2965:4b28e9740e3b
    65   //
    65   //
    66   RandomVariable::UseGlobalSeed (1, 1, 2, 3, 5, 8);
    66   RandomVariable::UseGlobalSeed (1, 1, 2, 3, 5, 8);
    67 
    67 
    68   // Set up some default values for the simulation.  Use the 
    68   // Set up some default values for the simulation.  Use the 
    69 
    69 
    70   Config::SetDefault ("ns3::OnOffApplication::PacketSize", Uinteger (210));
    70   Config::SetDefault ("ns3::OnOffApplication::PacketSize", UintegerValue (210));
    71   Config::SetDefault ("ns3::OnOffApplication::DataRate", DataRate ("448kb/s"));
    71   Config::SetDefault ("ns3::OnOffApplication::DataRate", StringValue ("448kb/s"));
    72 
    72 
    73   //DefaultValue::Bind ("DropTailQueue::m_maxPackets", 30);   
    73   //DefaultValue::Bind ("DropTailQueue::m_maxPackets", 30);   
    74 
    74 
    75   // Allow the user to override any of the defaults and the above
    75   // Allow the user to override any of the defaults and the above
    76   // DefaultValue::Bind ()s at run-time, via command-line arguments
    76   // DefaultValue::Bind ()s at run-time, via command-line arguments
    91   internet.Install (c);
    91   internet.Install (c);
    92 
    92 
    93   // We create the channels first without any IP addressing information
    93   // We create the channels first without any IP addressing information
    94   NS_LOG_INFO ("Create channels.");
    94   NS_LOG_INFO ("Create channels.");
    95   PointToPointHelper p2p;
    95   PointToPointHelper p2p;
    96   p2p.SetChannelParameter ("BitRate", DataRate (5000000));
    96   p2p.SetChannelParameter ("BitRate", StringValue ("5Mbps"));
    97   p2p.SetChannelParameter ("Delay", MilliSeconds (2));
    97   p2p.SetChannelParameter ("Delay", StringValue ("2ms"));
    98   NetDeviceContainer nd02 = p2p.Install (n02);
    98   NetDeviceContainer nd02 = p2p.Install (n02);
    99   NetDeviceContainer nd12 = p2p.Install (n12);
    99   NetDeviceContainer nd12 = p2p.Install (n12);
   100   p2p.SetChannelParameter ("BitRate", DataRate (1500000));
   100   p2p.SetChannelParameter ("BitRate", StringValue ("1500Kbps"));
   101   p2p.SetChannelParameter ("Delay", MilliSeconds (10));
   101   p2p.SetChannelParameter ("Delay", StringValue ("10ms"));
   102   NetDeviceContainer nd32 = p2p.Install (n32);
   102   NetDeviceContainer nd32 = p2p.Install (n32);
   103   NetDeviceContainer nd34 = p2p.Install (n34);
   103   NetDeviceContainer nd34 = p2p.Install (n34);
   104   
   104   
   105   // Later, we add IP addresses.  
   105   // Later, we add IP addresses.  
   106   NS_LOG_INFO ("Assign IP Addresses.");
   106   NS_LOG_INFO ("Assign IP Addresses.");
   126   // 210 bytes at a rate of 448 Kb/s
   126   // 210 bytes at a rate of 448 Kb/s
   127   NS_LOG_INFO ("Create Applications.");
   127   NS_LOG_INFO ("Create Applications.");
   128   uint16_t port = 9;   // Discard port (RFC 863)
   128   uint16_t port = 9;   // Discard port (RFC 863)
   129 
   129 
   130   OnOffHelper onoff ("ns3::Udp", 
   130   OnOffHelper onoff ("ns3::Udp", 
   131     Address (InetSocketAddress (i34.GetAddress (1), port)));
   131                      InetSocketAddress (i34.GetAddress (1), port));
   132   onoff.SetAttribute ("OnTime", ConstantVariable (1));
   132   onoff.SetAttribute ("OnTime", RandomVariableValue (ConstantVariable (1)));
   133   onoff.SetAttribute ("OffTime", ConstantVariable (0));
   133   onoff.SetAttribute ("OffTime", RandomVariableValue (ConstantVariable (0)));
   134 
   134 
   135   ApplicationContainer apps = onoff.Install (c.Get (0));
   135   ApplicationContainer apps = onoff.Install (c.Get (0));
   136   apps.Start (Seconds (1.0));
   136   apps.Start (Seconds (1.0));
   137   apps.Stop (Seconds (10.0));
   137   apps.Stop (Seconds (10.0));
   138 
   138 
   139   // Create a packet sink to receive these packets
   139   // Create a packet sink to receive these packets
   140   PacketSinkHelper sink ("ns3::Udp",
   140   PacketSinkHelper sink ("ns3::Udp",
   141     Address (InetSocketAddress (Ipv4Address::GetAny (), port)));
   141                          InetSocketAddress (Ipv4Address::GetAny (), port));
   142 
   142 
   143   apps = sink.Install (c.Get (3));
   143   apps = sink.Install (c.Get (3));
   144   apps.Start (Seconds (1.0));
   144   apps.Start (Seconds (1.0));
   145   apps.Stop (Seconds (10.0));
   145   apps.Stop (Seconds (10.0));
   146 
   146 
   147   // Create a similar flow from n3 to n1, starting at time 1.1 seconds
   147   // Create a similar flow from n3 to n1, starting at time 1.1 seconds
   148   onoff.SetAttribute ("Remote",
   148   onoff.SetAttribute ("Remote",
   149     Address (InetSocketAddress (i12.GetAddress (0), port)));
   149                       AddressValue (InetSocketAddress (i12.GetAddress (0), port)));
   150   apps = onoff.Install (c.Get (3));
   150   apps = onoff.Install (c.Get (3));
   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   // Create a packet sink to receive these packets
   154   // Create a packet sink to receive these packets