examples/mixed-global-routing.cc
changeset 2965 4b28e9740e3b
parent 2890 172baa5960ff
child 2974 30ed185e0364
equal deleted inserted replaced
2964:4e8cb1577144 2965:4b28e9740e3b
    49 NS_LOG_COMPONENT_DEFINE ("MixedGlobalRoutingExample");
    49 NS_LOG_COMPONENT_DEFINE ("MixedGlobalRoutingExample");
    50 
    50 
    51 int 
    51 int 
    52 main (int argc, char *argv[])
    52 main (int argc, char *argv[])
    53 {
    53 {
    54   Config::SetDefault ("ns3::OnOffApplication::PacketSize", Uinteger (210));
    54   Config::SetDefault ("ns3::OnOffApplication::PacketSize", UintegerValue (210));
    55   Config::SetDefault ("ns3::OnOffApplication::DataRate", DataRate ("448kb/s"));
    55   Config::SetDefault ("ns3::OnOffApplication::DataRate", StringValue ("448kb/s"));
    56 
    56 
    57   // Allow the user to override any of the defaults and the above
    57   // Allow the user to override any of the defaults and the above
    58   // Bind ()s at run-time, via command-line arguments
    58   // Bind ()s at run-time, via command-line arguments
    59   CommandLine cmd;
    59   CommandLine cmd;
    60   cmd.Parse (argc, argv);
    60   cmd.Parse (argc, argv);
    71   internet.Install (c);
    71   internet.Install (c);
    72 
    72 
    73   // We create the channels first without any IP addressing information
    73   // We create the channels first without any IP addressing information
    74   NS_LOG_INFO ("Create channels.");
    74   NS_LOG_INFO ("Create channels.");
    75   PointToPointHelper p2p;
    75   PointToPointHelper p2p;
    76   p2p.SetChannelParameter ("BitRate", DataRate (5000000));
    76   p2p.SetChannelParameter ("BitRate", StringValue ("5Mbps"));
    77   p2p.SetChannelParameter ("Delay", MilliSeconds (2));
    77   p2p.SetChannelParameter ("Delay", StringValue ("2ms"));
    78   NetDeviceContainer d0d2 = p2p.Install (n0n2);
    78   NetDeviceContainer d0d2 = p2p.Install (n0n2);
    79 
    79 
    80   NetDeviceContainer d1d2 = p2p.Install (n1n2);
    80   NetDeviceContainer d1d2 = p2p.Install (n1n2);
    81 
    81 
    82   p2p.SetChannelParameter ("BitRate", DataRate (1500000));
    82   p2p.SetChannelParameter ("BitRate", StringValue ("1500Kbps"));
    83   p2p.SetChannelParameter ("Delay", MilliSeconds (10));
    83   p2p.SetChannelParameter ("Delay", StringValue ("10ms"));
    84   NetDeviceContainer d5d6 = p2p.Install (n5n6);
    84   NetDeviceContainer d5d6 = p2p.Install (n5n6);
    85 
    85 
    86   // We create the channels first without any IP addressing information
    86   // We create the channels first without any IP addressing information
    87   CsmaHelper csma;
    87   CsmaHelper csma;
    88   csma.SetChannelParameter ("BitRate", DataRate (5000000));
    88   csma.SetChannelParameter ("BitRate", StringValue ("5Mbps"));
    89   csma.SetChannelParameter ("Delay", MilliSeconds (2));
    89   csma.SetChannelParameter ("Delay", StringValue ("2ms"));
    90   NetDeviceContainer d2345 = csma.Install (n2345);
    90   NetDeviceContainer d2345 = csma.Install (n2345);
    91   
    91   
    92   // Later, we add IP addresses.  
    92   // Later, we add IP addresses.  
    93   NS_LOG_INFO ("Assign IP Addresses.");
    93   NS_LOG_INFO ("Assign IP Addresses.");
    94   Ipv4AddressHelper ipv4;
    94   Ipv4AddressHelper ipv4;
   111   // Create the OnOff application to send UDP datagrams of size
   111   // Create the OnOff application to send UDP datagrams of size
   112   // 210 bytes at a rate of 448 Kb/s
   112   // 210 bytes at a rate of 448 Kb/s
   113   NS_LOG_INFO ("Create Applications.");
   113   NS_LOG_INFO ("Create Applications.");
   114   uint16_t port = 9;   // Discard port (RFC 863)
   114   uint16_t port = 9;   // Discard port (RFC 863)
   115   OnOffHelper onoff ("ns3::Udp",
   115   OnOffHelper onoff ("ns3::Udp",
   116     Address (InetSocketAddress (i5i6.GetAddress (1), port)));
   116                      InetSocketAddress (i5i6.GetAddress (1), port));
   117   onoff.SetAttribute ("OnTime", ConstantVariable (1));
   117   onoff.SetAttribute ("OnTime", RandomVariableValue (ConstantVariable (1)));
   118   onoff.SetAttribute ("OffTime", ConstantVariable (0));
   118   onoff.SetAttribute ("OffTime", RandomVariableValue (ConstantVariable (0)));
   119   onoff.SetAttribute ("DataRate", DataRate("300bps"));
   119   onoff.SetAttribute ("DataRate", StringValue ("300bps"));
   120   onoff.SetAttribute ("PacketSize", Uinteger (50));
   120   onoff.SetAttribute ("PacketSize", UintegerValue (50));
   121 
   121 
   122   ApplicationContainer apps = onoff.Install (c.Get (0));
   122   ApplicationContainer apps = onoff.Install (c.Get (0));
   123   apps.Start (Seconds (1.0));
   123   apps.Start (Seconds (1.0));
   124   apps.Stop (Seconds (10.0));
   124   apps.Stop (Seconds (10.0));
   125 
   125