Merge
This commit is contained in:
1
AUTHORS
1
AUTHORS
@@ -13,4 +13,5 @@ Sebastien Vincent (vincent@lsiit.u-strasbg.fr)
|
||||
David Gross (gdavid.devel@gmail.com)
|
||||
Mehdi Benamor (mehdi.benamor@telecom-bretagne.eu)
|
||||
Angelos Chatzipapas (chatzipa@ceid.upatras.gr)
|
||||
Luis Cortes (cortes@gatech.edu)
|
||||
|
||||
|
||||
230
examples/dynamic-global-routing.cc
Normal file
230
examples/dynamic-global-routing.cc
Normal file
@@ -0,0 +1,230 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation;
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
* Contributed by: Luis Cortes (cortes@gatech.edu)
|
||||
*/
|
||||
|
||||
|
||||
// This script exercises global routing code in a mixed point-to-point
|
||||
// and csma/cd environment
|
||||
//
|
||||
// Network topology
|
||||
//
|
||||
// n0
|
||||
// \ p-p
|
||||
// \ (shared csma/cd)
|
||||
// n2 -------------------------n3
|
||||
// / | |
|
||||
// / p-p n4 n5 ---------- n6
|
||||
// n1 p-p
|
||||
// | |
|
||||
// ----------------------------------------
|
||||
// p-p
|
||||
//
|
||||
// - at time 1 CBR/UDP flow from n1 to n6's IP address on the n5/n6 link
|
||||
// - at time 10, start similar flow from n1 to n6's address on the n1/n6 link
|
||||
//
|
||||
// Order of events
|
||||
// At pre-simulation time, configure global routes. Shortest path from
|
||||
// n1 to n6 is via the direct point-to-point link
|
||||
// At time 1s, start CBR traffic flow from n1 to n6
|
||||
// At time 2s, set the n1 point-to-point interface to down. Packets
|
||||
// will start to be dropped
|
||||
// At time 3s, call RecomputeGlobalRoutes() and traffic will
|
||||
// start flowing again on the alternate path
|
||||
// At time 4s, re-enable the n1/n6 interface to up. Will not change routing
|
||||
// At time 5s, call RecomputeGlobalRoutes() and traffic will start flowing
|
||||
// again on the original path
|
||||
// At time 6s, set the n6-n1 point-to-point Ipv4 interface to down (note, this
|
||||
// keeps the point-to-point link "up" from n1's perspective). Packets
|
||||
// will traverse the link and be dropped at n6 upon receipt. These drops
|
||||
// are not visible in the pcap trace but in the ascii trace.
|
||||
// At time 7s, call RecomputeGlobalRoutes() and traffic will flow again
|
||||
// through the path n1-n2-n5-n6
|
||||
// At time 8s, bring the interface back up.
|
||||
// At time 9s, call RecomputeGlobalRoutes() and traffic will flow again
|
||||
// through the path n1-n6
|
||||
// At time 10s, stop the first flow.
|
||||
// At time 11s, start a new flow, but to n6's other IP address (the one
|
||||
// on the n1/n6 p2p link)
|
||||
// At time 12s, bring the n1 interface down between n1 and n6. Packets
|
||||
// will start to be dropped
|
||||
// At time 13s, call RecomputeGlobalRoutes() and traffic will
|
||||
// start flowing again on the alternate path
|
||||
// At time 14s, re-enable the n1/n6 interface to up. Will not change routing
|
||||
// At time 15s, call RecomputeGlobalRoutes() and traffic will start flowing
|
||||
// again on the original path
|
||||
// At time 16s, stop the second flow.
|
||||
|
||||
// - Tracing of queues and packet receptions to file "dynamic-global-routing.tr"
|
||||
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <string>
|
||||
#include <cassert>
|
||||
|
||||
#include "ns3/core-module.h"
|
||||
#include "ns3/simulator-module.h"
|
||||
#include "ns3/node-module.h"
|
||||
#include "ns3/helper-module.h"
|
||||
#include "ns3/global-route-manager.h"
|
||||
|
||||
using namespace ns3;
|
||||
|
||||
NS_LOG_COMPONENT_DEFINE ("DynamicGlobalRoutingExample");
|
||||
|
||||
int
|
||||
main (int argc, char *argv[])
|
||||
{
|
||||
// Allow the user to override any of the defaults and the above
|
||||
// Bind ()s at run-time, via command-line arguments
|
||||
CommandLine cmd;
|
||||
cmd.Parse (argc, argv);
|
||||
|
||||
NS_LOG_INFO ("Create nodes.");
|
||||
NodeContainer c;
|
||||
c.Create (7);
|
||||
NodeContainer n0n2 = NodeContainer (c.Get (0), c.Get (2));
|
||||
NodeContainer n1n2 = NodeContainer (c.Get (1), c.Get (2));
|
||||
NodeContainer n5n6 = NodeContainer (c.Get (5), c.Get (6));
|
||||
NodeContainer n1n6 = NodeContainer (c.Get (1), c.Get (6));
|
||||
NodeContainer n2345 = NodeContainer (c.Get (2), c.Get (3), c.Get (4), c.Get (5));
|
||||
|
||||
InternetStackHelper internet;
|
||||
internet.Install (c);
|
||||
|
||||
// We create the channels first without any IP addressing information
|
||||
NS_LOG_INFO ("Create channels.");
|
||||
PointToPointHelper p2p;
|
||||
p2p.SetDeviceAttribute ("DataRate", StringValue ("5Mbps"));
|
||||
p2p.SetChannelAttribute ("Delay", StringValue ("2ms"));
|
||||
NetDeviceContainer d0d2 = p2p.Install (n0n2);
|
||||
NetDeviceContainer d1d6 = p2p.Install (n1n6);
|
||||
|
||||
NetDeviceContainer d1d2 = p2p.Install (n1n2);
|
||||
|
||||
p2p.SetDeviceAttribute ("DataRate", StringValue ("1500kbps"));
|
||||
p2p.SetChannelAttribute ("Delay", StringValue ("10ms"));
|
||||
NetDeviceContainer d5d6 = p2p.Install (n5n6);
|
||||
|
||||
// We create the channels first without any IP addressing information
|
||||
CsmaHelper csma;
|
||||
csma.SetChannelAttribute ("DataRate", StringValue ("5Mbps"));
|
||||
csma.SetChannelAttribute ("Delay", StringValue ("2ms"));
|
||||
NetDeviceContainer d2345 = csma.Install (n2345);
|
||||
|
||||
// Later, we add IP addresses.
|
||||
NS_LOG_INFO ("Assign IP Addresses.");
|
||||
Ipv4AddressHelper ipv4;
|
||||
ipv4.SetBase ("10.1.1.0", "255.255.255.0");
|
||||
ipv4.Assign (d0d2);
|
||||
|
||||
ipv4.SetBase ("10.1.2.0", "255.255.255.0");
|
||||
ipv4.Assign (d1d2);
|
||||
|
||||
ipv4.SetBase ("10.1.3.0", "255.255.255.0");
|
||||
Ipv4InterfaceContainer i5i6 = ipv4.Assign (d5d6);
|
||||
|
||||
ipv4.SetBase ("10.250.1.0", "255.255.255.0");
|
||||
ipv4.Assign (d2345);
|
||||
|
||||
ipv4.SetBase ("172.16.1.0", "255.255.255.0");
|
||||
Ipv4InterfaceContainer i1i6 = ipv4.Assign (d1d6);
|
||||
|
||||
// Create router nodes, initialize routing database and set up the routing
|
||||
// tables in the nodes.
|
||||
GlobalRouteManager::PopulateRoutingTables ();
|
||||
|
||||
// Create the OnOff application to send UDP datagrams of size
|
||||
// 210 bytes at a rate of 448 Kb/s
|
||||
NS_LOG_INFO ("Create Applications.");
|
||||
uint16_t port = 9; // Discard port (RFC 863)
|
||||
OnOffHelper onoff ("ns3::UdpSocketFactory",
|
||||
InetSocketAddress (i5i6.GetAddress (1), port));
|
||||
onoff.SetAttribute ("OnTime", RandomVariableValue (ConstantVariable (1)));
|
||||
onoff.SetAttribute ("OffTime", RandomVariableValue (ConstantVariable (0)));
|
||||
onoff.SetAttribute ("DataRate", StringValue ("2kbps"));
|
||||
onoff.SetAttribute ("PacketSize", UintegerValue (50));
|
||||
|
||||
ApplicationContainer apps = onoff.Install (c.Get (1));
|
||||
apps.Start (Seconds (1.0));
|
||||
apps.Stop (Seconds (10.0));
|
||||
|
||||
// Create a second OnOff application to send UDP datagrams of size
|
||||
// 210 bytes at a rate of 448 Kb/s
|
||||
OnOffHelper onoff2 ("ns3::UdpSocketFactory",
|
||||
InetSocketAddress (i1i6.GetAddress (1), port));
|
||||
onoff2.SetAttribute ("OnTime", RandomVariableValue (ConstantVariable (1)));
|
||||
onoff2.SetAttribute ("OffTime", RandomVariableValue (ConstantVariable (0)));
|
||||
onoff2.SetAttribute ("DataRate", StringValue ("2kbps"));
|
||||
onoff2.SetAttribute ("PacketSize", UintegerValue (50));
|
||||
|
||||
ApplicationContainer apps2 = onoff2.Install (c.Get (1));
|
||||
apps2.Start (Seconds (11.0));
|
||||
apps2.Stop (Seconds (16.0));
|
||||
|
||||
// Create an optional packet sink to receive these packets
|
||||
PacketSinkHelper sink ("ns3::UdpSocketFactory",
|
||||
Address (InetSocketAddress (Ipv4Address::GetAny (), port)));
|
||||
apps = sink.Install (c.Get (6));
|
||||
apps.Start (Seconds (1.0));
|
||||
apps.Stop (Seconds (10.0));
|
||||
|
||||
PacketSinkHelper sink2 ("ns3::UdpSocketFactory",
|
||||
Address (InetSocketAddress (Ipv4Address::GetAny (), port)));
|
||||
apps2 = sink2.Install (c.Get (6));
|
||||
apps2.Start (Seconds (11.0));
|
||||
apps2.Stop (Seconds (16.0));
|
||||
|
||||
|
||||
std::ofstream ascii;
|
||||
ascii.open ("dynamic-global-routing.tr");
|
||||
PointToPointHelper::EnablePcapAll ("dynamic-global-routing");
|
||||
PointToPointHelper::EnableAsciiAll (ascii);
|
||||
CsmaHelper::EnablePcapAll ("dynamic-global-routing");
|
||||
CsmaHelper::EnableAsciiAll (ascii);
|
||||
InternetStackHelper::EnableAsciiAll (ascii);
|
||||
|
||||
Ptr<Node> n1 = c.Get (1);
|
||||
Ptr<Ipv4> ipv41 = n1->GetObject<Ipv4> ();
|
||||
// The first ifIndex is 0 for loopback, then the first p2p is numbered 1,
|
||||
// then the next p2p is numbered 2
|
||||
uint32_t ipv4ifIndex1 = 2;
|
||||
|
||||
Simulator::Schedule (Seconds (2),&Ipv4::SetDown,ipv41, ipv4ifIndex1);
|
||||
Simulator::Schedule (Seconds (3),&GlobalRouteManager::RecomputeRoutingTables);
|
||||
Simulator::Schedule (Seconds (4),&Ipv4::SetUp,ipv41, ipv4ifIndex1);
|
||||
Simulator::Schedule (Seconds (5),&GlobalRouteManager::RecomputeRoutingTables);
|
||||
|
||||
Ptr<Node> n6 = c.Get (6);
|
||||
Ptr<Ipv4> ipv46 = n6->GetObject<Ipv4> ();
|
||||
// The first ifIndex is 0 for loopback, then the first p2p is numbered 1,
|
||||
// then the next p2p is numbered 2
|
||||
uint32_t ipv4ifIndex6 = 2;
|
||||
Simulator::Schedule (Seconds (6),&Ipv4::SetDown,ipv46, ipv4ifIndex6);
|
||||
Simulator::Schedule (Seconds (7),&GlobalRouteManager::RecomputeRoutingTables);
|
||||
Simulator::Schedule (Seconds (8),&Ipv4::SetUp,ipv46, ipv4ifIndex6);
|
||||
Simulator::Schedule (Seconds (9),&GlobalRouteManager::RecomputeRoutingTables);
|
||||
|
||||
Simulator::Schedule (Seconds (12),&Ipv4::SetDown,ipv41, ipv4ifIndex1);
|
||||
Simulator::Schedule (Seconds (13),&GlobalRouteManager::RecomputeRoutingTables);
|
||||
Simulator::Schedule (Seconds (14),&Ipv4::SetUp,ipv41, ipv4ifIndex1);
|
||||
Simulator::Schedule (Seconds (15),&GlobalRouteManager::RecomputeRoutingTables);
|
||||
|
||||
NS_LOG_INFO ("Run Simulation.");
|
||||
Simulator::Run ();
|
||||
Simulator::Destroy ();
|
||||
NS_LOG_INFO ("Done.");
|
||||
}
|
||||
135
examples/global-routing-slash32.cc
Normal file
135
examples/global-routing-slash32.cc
Normal file
@@ -0,0 +1,135 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation;
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
|
||||
// Test program for this 3-router scenario, using global routing
|
||||
//
|
||||
// (a.a.a.a/32)A<--x.x.x.0/30-->B<--y.y.y.0/30-->C(c.c.c.c/32)
|
||||
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <string>
|
||||
#include <cassert>
|
||||
|
||||
#include "ns3/csma-net-device.h"
|
||||
#include "ns3/core-module.h"
|
||||
#include "ns3/simulator-module.h"
|
||||
#include "ns3/node-module.h"
|
||||
#include "ns3/helper-module.h"
|
||||
#include "ns3/global-route-manager.h"
|
||||
|
||||
using namespace ns3;
|
||||
|
||||
NS_LOG_COMPONENT_DEFINE ("GlobalRouterSlash32Test");
|
||||
|
||||
int
|
||||
main (int argc, char *argv[])
|
||||
{
|
||||
// Make the random number generators generate reproducible results.
|
||||
//
|
||||
RandomVariable::UseGlobalSeed (1, 1, 2, 3, 5, 8);
|
||||
|
||||
// Allow the user to override any of the defaults and the above
|
||||
// DefaultValue::Bind ()s at run-time, via command-line arguments
|
||||
CommandLine cmd;
|
||||
cmd.Parse (argc, argv);
|
||||
|
||||
Ptr<Node> nA = CreateObject<Node> ();
|
||||
Ptr<Node> nB = CreateObject<Node> ();
|
||||
Ptr<Node> nC = CreateObject<Node> ();
|
||||
|
||||
NodeContainer c = NodeContainer (nA, nB, nC);
|
||||
|
||||
InternetStackHelper internet;
|
||||
internet.Install (c);
|
||||
|
||||
// Point-to-point links
|
||||
NodeContainer nAnB = NodeContainer (nA, nB);
|
||||
NodeContainer nBnC = NodeContainer (nB, nC);
|
||||
|
||||
// We create the channels first without any IP addressing information
|
||||
PointToPointHelper p2p;
|
||||
p2p.SetDeviceAttribute ("DataRate", StringValue ("5Mbps"));
|
||||
p2p.SetChannelAttribute ("Delay", StringValue ("2ms"));
|
||||
NetDeviceContainer dAdB = p2p.Install (nAnB);
|
||||
|
||||
NetDeviceContainer dBdC = p2p.Install (nBnC);;
|
||||
|
||||
Ptr<CsmaNetDevice> deviceA = CreateObject<CsmaNetDevice> ();
|
||||
deviceA->SetAddress (Mac48Address::Allocate ());
|
||||
nA->AddDevice (deviceA);
|
||||
|
||||
Ptr<CsmaNetDevice> deviceC = CreateObject<CsmaNetDevice> ();
|
||||
deviceC->SetAddress (Mac48Address::Allocate ());
|
||||
nC->AddDevice (deviceC);
|
||||
|
||||
// Later, we add IP addresses.
|
||||
Ipv4AddressHelper ipv4;
|
||||
ipv4.SetBase ("10.1.1.0", "255.255.255.252");
|
||||
Ipv4InterfaceContainer iAiB = ipv4.Assign (dAdB);
|
||||
|
||||
ipv4.SetBase ("10.1.1.4", "255.255.255.252");
|
||||
Ipv4InterfaceContainer iBiC = ipv4.Assign (dBdC);
|
||||
|
||||
Ptr<Ipv4> ipv4A = nA->GetObject<Ipv4> ();
|
||||
Ptr<Ipv4> ipv4C = nC->GetObject<Ipv4> ();
|
||||
|
||||
int32_t ifIndexA = ipv4A->AddInterface (deviceA);
|
||||
int32_t ifIndexC = ipv4C->AddInterface (deviceC);
|
||||
|
||||
ipv4A->SetAddress (ifIndexA, Ipv4Address ("172.16.1.1"));
|
||||
ipv4A->SetNetworkMask (ifIndexA, Ipv4Mask ("255.255.255.255"));
|
||||
ipv4A->SetMetric (ifIndexA, 1);
|
||||
ipv4A->SetUp (ifIndexA);
|
||||
|
||||
ipv4C->SetAddress (ifIndexC, Ipv4Address ("192.168.1.1"));
|
||||
ipv4C->SetNetworkMask (ifIndexC, Ipv4Mask ("255.255.255.255"));
|
||||
ipv4C->SetMetric (ifIndexC, 1);
|
||||
ipv4C->SetUp (ifIndexC);
|
||||
|
||||
// Create router nodes, initialize routing database and set up the routing
|
||||
// tables in the nodes.
|
||||
GlobalRouteManager::PopulateRoutingTables ();
|
||||
|
||||
// Create the OnOff application to send UDP datagrams of size
|
||||
// 210 bytes at a rate of 448 Kb/s
|
||||
uint16_t port = 9; // Discard port (RFC 863)
|
||||
OnOffHelper onoff ("ns3::UdpSocketFactory",
|
||||
Address (InetSocketAddress (Ipv4Address("192.168.1.1"), port)));
|
||||
onoff.SetAttribute ("OnTime", RandomVariableValue (ConstantVariable (1)));
|
||||
onoff.SetAttribute ("OffTime", RandomVariableValue (ConstantVariable (0)));
|
||||
onoff.SetAttribute ("DataRate", DataRateValue (DataRate (6000)));
|
||||
ApplicationContainer apps = onoff.Install (nA);
|
||||
apps.Start (Seconds (1.0));
|
||||
apps.Stop (Seconds (10.0));
|
||||
|
||||
// Create a packet sink to receive these packets
|
||||
PacketSinkHelper sink ("ns3::UdpSocketFactory",
|
||||
Address (InetSocketAddress (Ipv4Address::GetAny (), port)));
|
||||
apps = sink.Install (nC);
|
||||
apps.Start (Seconds (1.0));
|
||||
apps.Stop (Seconds (10.0));
|
||||
|
||||
std::ofstream ascii;
|
||||
ascii.open ("global-routing-slash32.tr");
|
||||
PointToPointHelper::EnablePcapAll ("global-routing-slash32");
|
||||
PointToPointHelper::EnableAsciiAll (ascii);
|
||||
|
||||
Simulator::Run ();
|
||||
Simulator::Destroy ();
|
||||
|
||||
return 0;
|
||||
}
|
||||
137
examples/static-routing-slash32.cc
Normal file
137
examples/static-routing-slash32.cc
Normal file
@@ -0,0 +1,137 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation;
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
|
||||
// Test program for this 3-router scenario, using static routing
|
||||
//
|
||||
// (a.a.a.a/32)A<--x.x.x.0/30-->B<--y.y.y.0/30-->C(c.c.c.c/32)
|
||||
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <string>
|
||||
#include <cassert>
|
||||
|
||||
#include "ns3/csma-net-device.h"
|
||||
#include "ns3/core-module.h"
|
||||
#include "ns3/simulator-module.h"
|
||||
#include "ns3/node-module.h"
|
||||
#include "ns3/helper-module.h"
|
||||
|
||||
using namespace ns3;
|
||||
|
||||
NS_LOG_COMPONENT_DEFINE ("StaticRoutingSlash32Test");
|
||||
|
||||
int
|
||||
main (int argc, char *argv[])
|
||||
{
|
||||
// Make the random number generators generate reproducible results.
|
||||
//
|
||||
RandomVariable::UseGlobalSeed (1, 1, 2, 3, 5, 8);
|
||||
|
||||
// Allow the user to override any of the defaults and the above
|
||||
// DefaultValue::Bind ()s at run-time, via command-line arguments
|
||||
CommandLine cmd;
|
||||
cmd.Parse (argc, argv);
|
||||
|
||||
Ptr<Node> nA = CreateObject<Node> ();
|
||||
Ptr<Node> nB = CreateObject<Node> ();
|
||||
Ptr<Node> nC = CreateObject<Node> ();
|
||||
|
||||
NodeContainer c = NodeContainer (nA, nB, nC);
|
||||
|
||||
InternetStackHelper internet;
|
||||
internet.Install (c);
|
||||
|
||||
// Point-to-point links
|
||||
NodeContainer nAnB = NodeContainer (nA, nB);
|
||||
NodeContainer nBnC = NodeContainer (nB, nC);
|
||||
|
||||
// We create the channels first without any IP addressing information
|
||||
PointToPointHelper p2p;
|
||||
p2p.SetDeviceAttribute ("DataRate", StringValue ("5Mbps"));
|
||||
p2p.SetChannelAttribute ("Delay", StringValue ("2ms"));
|
||||
NetDeviceContainer dAdB = p2p.Install (nAnB);
|
||||
|
||||
NetDeviceContainer dBdC = p2p.Install (nBnC);;
|
||||
|
||||
Ptr<CsmaNetDevice> deviceA = CreateObject<CsmaNetDevice> ();
|
||||
deviceA->SetAddress (Mac48Address::Allocate ());
|
||||
nA->AddDevice (deviceA);
|
||||
|
||||
Ptr<CsmaNetDevice> deviceC = CreateObject<CsmaNetDevice> ();
|
||||
deviceC->SetAddress (Mac48Address::Allocate ());
|
||||
nC->AddDevice (deviceC);
|
||||
|
||||
// Later, we add IP addresses.
|
||||
Ipv4AddressHelper ipv4;
|
||||
ipv4.SetBase ("10.1.1.0", "255.255.255.252");
|
||||
Ipv4InterfaceContainer iAiB = ipv4.Assign (dAdB);
|
||||
|
||||
ipv4.SetBase ("10.1.1.4", "255.255.255.252");
|
||||
Ipv4InterfaceContainer iBiC = ipv4.Assign (dBdC);
|
||||
|
||||
Ptr<Ipv4> ipv4A = nA->GetObject<Ipv4> ();
|
||||
Ptr<Ipv4> ipv4B = nB->GetObject<Ipv4> ();
|
||||
Ptr<Ipv4> ipv4C = nC->GetObject<Ipv4> ();
|
||||
|
||||
int32_t ifIndexA = ipv4A->AddInterface (deviceA);
|
||||
int32_t ifIndexC = ipv4C->AddInterface (deviceC);
|
||||
|
||||
ipv4A->SetAddress (ifIndexA, Ipv4Address ("172.16.1.1"));
|
||||
ipv4A->SetNetworkMask (ifIndexA, Ipv4Mask ("255.255.255.255"));
|
||||
ipv4A->SetMetric (ifIndexA, 1);
|
||||
ipv4A->SetUp (ifIndexA);
|
||||
|
||||
ipv4C->SetAddress (ifIndexC, Ipv4Address ("192.168.1.1"));
|
||||
ipv4C->SetNetworkMask (ifIndexC, Ipv4Mask ("255.255.255.255"));
|
||||
ipv4C->SetMetric (ifIndexC, 1);
|
||||
ipv4C->SetUp (ifIndexC);
|
||||
|
||||
// Create static routes from A to C
|
||||
// The ifIndex for this outbound route is 1; the first p2p link added
|
||||
ipv4A->AddHostRouteTo (Ipv4Address ("192.168.1.1"), Ipv4Address ("10.1.1.2"), 1);
|
||||
// The ifIndex we want on node B is 2; 0 corresponds to loopback, and 1 to the first point to point link
|
||||
ipv4B->AddHostRouteTo (Ipv4Address ("192.168.1.1"), Ipv4Address ("10.1.1.6"), 2);
|
||||
|
||||
// Create the OnOff application to send UDP datagrams of size
|
||||
// 210 bytes at a rate of 448 Kb/s
|
||||
uint16_t port = 9; // Discard port (RFC 863)
|
||||
OnOffHelper onoff ("ns3::UdpSocketFactory",
|
||||
Address (InetSocketAddress (Ipv4Address("192.168.1.1"), port)));
|
||||
onoff.SetAttribute ("OnTime", RandomVariableValue (ConstantVariable (1)));
|
||||
onoff.SetAttribute ("OffTime", RandomVariableValue (ConstantVariable (0)));
|
||||
onoff.SetAttribute ("DataRate", DataRateValue (DataRate (6000)));
|
||||
ApplicationContainer apps = onoff.Install (nA);
|
||||
apps.Start (Seconds (1.0));
|
||||
apps.Stop (Seconds (10.0));
|
||||
|
||||
// Create a packet sink to receive these packets
|
||||
PacketSinkHelper sink ("ns3::UdpSocketFactory",
|
||||
Address (InetSocketAddress (Ipv4Address::GetAny (), port)));
|
||||
apps = sink.Install (nC);
|
||||
apps.Start (Seconds (1.0));
|
||||
apps.Stop (Seconds (10.0));
|
||||
|
||||
std::ofstream ascii;
|
||||
ascii.open ("static-routing-slash32.tr");
|
||||
PointToPointHelper::EnablePcapAll ("static-routing-slash32");
|
||||
PointToPointHelper::EnableAsciiAll (ascii);
|
||||
|
||||
Simulator::Run ();
|
||||
Simulator::Destroy ();
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -4,10 +4,34 @@ def build(bld):
|
||||
obj = bld.create_ns3_program('hello-simulator')
|
||||
obj.source = 'hello-simulator.cc'
|
||||
|
||||
obj = bld.create_ns3_program('first',
|
||||
['core', 'simulator', 'point-to-point', 'internet-stack'])
|
||||
obj.source = 'first.cc'
|
||||
|
||||
obj = bld.create_ns3_program('second',
|
||||
['core', 'simulator', 'point-to-point', 'csma', 'internet-stack'])
|
||||
obj.source = 'second.cc'
|
||||
|
||||
obj = bld.create_ns3_program('third',
|
||||
['core', 'simulator', 'point-to-point', 'csma', 'wifi', 'internet-stack'])
|
||||
obj.source = 'third.cc'
|
||||
|
||||
obj = bld.create_ns3_program('mixed-wireless',
|
||||
['core', 'simulator', 'mobility', 'wifi', 'point-to-point', 'internet-stack'])
|
||||
obj.source = 'mixed-wireless.cc'
|
||||
|
||||
obj = bld.create_ns3_program('dynamic-global-routing',
|
||||
['point-to-point', 'csma', 'internet-stack', 'global-routing'])
|
||||
obj.source = 'dynamic-global-routing.cc'
|
||||
|
||||
obj = bld.create_ns3_program('static-routing-slash32',
|
||||
['point-to-point', 'internet-stack', 'global-routing'])
|
||||
obj.source = 'static-routing-slash32.cc'
|
||||
|
||||
obj = bld.create_ns3_program('global-routing-slash32',
|
||||
['point-to-point', 'internet-stack', 'global-routing'])
|
||||
obj.source = 'global-routing-slash32.cc'
|
||||
|
||||
obj = bld.create_ns3_program('simple-global-routing',
|
||||
['point-to-point', 'internet-stack', 'global-routing'])
|
||||
obj.source = 'simple-global-routing.cc'
|
||||
|
||||
12
regression/tests/test-dynamic-global-routing.py
Normal file
12
regression/tests/test-dynamic-global-routing.py
Normal file
@@ -0,0 +1,12 @@
|
||||
#! /usr/bin/env python
|
||||
|
||||
"""Generic trace-comparison-type regression test."""
|
||||
|
||||
import os
|
||||
import shutil
|
||||
import tracediff
|
||||
|
||||
def run(verbose, generate):
|
||||
"""Execute a test."""
|
||||
|
||||
return tracediff.run_test(verbose, generate, "dynamic-global-routing")
|
||||
12
regression/tests/test-global-routing-slash32.py
Normal file
12
regression/tests/test-global-routing-slash32.py
Normal file
@@ -0,0 +1,12 @@
|
||||
#! /usr/bin/env python
|
||||
|
||||
"""Generic trace-comparison-type regression test."""
|
||||
|
||||
import os
|
||||
import shutil
|
||||
import tracediff
|
||||
|
||||
def run(verbose, generate):
|
||||
"""Execute a test."""
|
||||
|
||||
return tracediff.run_test(verbose, generate, "global-routing-slash32")
|
||||
12
regression/tests/test-second.py
Normal file
12
regression/tests/test-second.py
Normal file
@@ -0,0 +1,12 @@
|
||||
#! /usr/bin/env python
|
||||
|
||||
"""Generic trace-comparison-type regression test."""
|
||||
|
||||
import os
|
||||
import shutil
|
||||
import tracediff
|
||||
|
||||
def run(verbose, generate):
|
||||
"""Execute a test."""
|
||||
|
||||
return tracediff.run_test(verbose, generate, "second")
|
||||
12
regression/tests/test-static-routing-slash32.py
Normal file
12
regression/tests/test-static-routing-slash32.py
Normal file
@@ -0,0 +1,12 @@
|
||||
#! /usr/bin/env python
|
||||
|
||||
"""Generic trace-comparison-type regression test."""
|
||||
|
||||
import os
|
||||
import shutil
|
||||
import tracediff
|
||||
|
||||
def run(verbose, generate):
|
||||
"""Execute a test."""
|
||||
|
||||
return tracediff.run_test(verbose, generate, "static-routing-slash32")
|
||||
12
regression/tests/test-third.py
Normal file
12
regression/tests/test-third.py
Normal file
@@ -0,0 +1,12 @@
|
||||
#! /usr/bin/env python
|
||||
|
||||
"""Generic trace-comparison-type regression test."""
|
||||
|
||||
import os
|
||||
import shutil
|
||||
import tracediff
|
||||
|
||||
def run(verbose, generate):
|
||||
"""Execute a test."""
|
||||
|
||||
return tracediff.run_test(verbose, generate, "third")
|
||||
@@ -1277,6 +1277,11 @@ GlobalRouter::AnotherRouterOnLink (Ptr<NetDevice> nd, bool allowRecursion) const
|
||||
NS_LOG_FUNCTION (nd << allowRecursion);
|
||||
|
||||
Ptr<Channel> ch = nd->GetChannel();
|
||||
if (!ch)
|
||||
{
|
||||
// It may be that this net device is a stub device, without a channel
|
||||
return false;
|
||||
}
|
||||
uint32_t nDevices = ch->GetNDevices();
|
||||
NS_ASSERT (nDevices);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user