examples/global-routing-slash32.cc
changeset 4375 db81fdcb06e7
parent 4225 f1d873a81159
child 4435 54cb46af8003
equal deleted inserted replaced
4374:2aae35f2287f 4375:db81fdcb06e7
    85   Ptr<Ipv4> ipv4C = nC->GetObject<Ipv4> ();
    85   Ptr<Ipv4> ipv4C = nC->GetObject<Ipv4> ();
    86   
    86   
    87   int32_t ifIndexA = ipv4A->AddInterface (deviceA);
    87   int32_t ifIndexA = ipv4A->AddInterface (deviceA);
    88   int32_t ifIndexC = ipv4C->AddInterface (deviceC);
    88   int32_t ifIndexC = ipv4C->AddInterface (deviceC);
    89     
    89     
    90   ipv4A->SetAddress (ifIndexA, Ipv4Address ("172.16.1.1"));
    90   Ipv4InterfaceAddress ifInAddrA = Ipv4InterfaceAddress (Ipv4Address ("172.16.1.1"), Ipv4Mask ("255.255.255.255"));
    91   ipv4A->SetNetworkMask (ifIndexA, Ipv4Mask ("255.255.255.255"));
    91   ipv4A->AddAddress (ifIndexA, ifInAddrA);
    92   ipv4A->SetMetric (ifIndexA, 1);
    92   ipv4A->SetMetric (ifIndexA, 1);
    93   ipv4A->SetUp (ifIndexA);
    93   ipv4A->SetUp (ifIndexA);
    94 
    94 
    95   ipv4C->SetAddress (ifIndexC, Ipv4Address ("192.168.1.1"));
    95   Ipv4InterfaceAddress ifInAddrC = Ipv4InterfaceAddress (Ipv4Address ("192.168.1.1"), Ipv4Mask ("255.255.255.255"));
    96   ipv4C->SetNetworkMask (ifIndexC, Ipv4Mask ("255.255.255.255"));
    96   ipv4C->AddAddress (ifIndexC, ifInAddrC);
    97   ipv4C->SetMetric (ifIndexC, 1);
    97   ipv4C->SetMetric (ifIndexC, 1);
    98   ipv4C->SetUp (ifIndexC);
    98   ipv4C->SetUp (ifIndexC);
    99  
    99  
   100   // Create router nodes, initialize routing database and set up the routing
   100   // Create router nodes, initialize routing database and set up the routing
   101   // tables in the nodes.
   101   // tables in the nodes.
   103 
   103 
   104   // Create the OnOff application to send UDP datagrams of size
   104   // Create the OnOff application to send UDP datagrams of size
   105   // 210 bytes at a rate of 448 Kb/s
   105   // 210 bytes at a rate of 448 Kb/s
   106   uint16_t port = 9;   // Discard port (RFC 863)
   106   uint16_t port = 9;   // Discard port (RFC 863)
   107   OnOffHelper onoff ("ns3::UdpSocketFactory", 
   107   OnOffHelper onoff ("ns3::UdpSocketFactory", 
   108     Address (InetSocketAddress (Ipv4Address("192.168.1.1"), port)));
   108     Address (InetSocketAddress (ifInAddrC.GetLocal(), port)));
   109   onoff.SetAttribute ("OnTime", RandomVariableValue (ConstantVariable (1)));
   109   onoff.SetAttribute ("OnTime", RandomVariableValue (ConstantVariable (1)));
   110   onoff.SetAttribute ("OffTime", RandomVariableValue (ConstantVariable (0)));
   110   onoff.SetAttribute ("OffTime", RandomVariableValue (ConstantVariable (0)));
   111   onoff.SetAttribute ("DataRate", DataRateValue (DataRate (6000)));
   111   onoff.SetAttribute ("DataRate", DataRateValue (DataRate (6000)));
   112   ApplicationContainer apps = onoff.Install (nA);
   112   ApplicationContainer apps = onoff.Install (nA);
   113   apps.Start (Seconds (1.0));
   113   apps.Start (Seconds (1.0));