5#include "ns3/boolean.h"
6#include "ns3/bridge-helper.h"
8#include "ns3/inet-socket-address.h"
9#include "ns3/internet-stack-helper.h"
10#include "ns3/ipv4-address-helper.h"
11#include "ns3/ipv4-global-routing-helper.h"
12#include "ns3/ipv4-global-routing.h"
13#include "ns3/ipv4-l3-protocol.h"
14#include "ns3/ipv4-packet-info-tag.h"
15#include "ns3/ipv4-routing-protocol.h"
16#include "ns3/ipv4-routing-table-entry.h"
17#include "ns3/ipv4-static-routing-helper.h"
19#include "ns3/node-container.h"
21#include "ns3/packet.h"
22#include "ns3/pointer.h"
23#include "ns3/simple-channel.h"
24#include "ns3/simple-net-device-helper.h"
25#include "ns3/simple-net-device.h"
26#include "ns3/simulator.h"
27#include "ns3/socket-factory.h"
28#include "ns3/string.h"
30#include "ns3/udp-socket-factory.h"
31#include "ns3/uinteger.h"
117 void DoRun()
override;
125 :
TestCase(
"Global routing on point-to-point link")
147 ipv4.SetBase(
"10.1.1.0",
"255.255.255.252");
201 void DoRun()
override;
209 :
TestCase(
"Global routing on broadcast link")
230 ipv4.SetBase(
"10.1.1.0",
"255.255.255.0");
282 void DoRun()
override;
290 :
TestCase(
"Global routing across two hops (point-to-point links)")
319 ipv4.SetBase(
"10.1.1.0",
"255.255.255.252");
321 ipv4.SetBase(
"10.1.2.0",
"255.255.255.252");
401 void DoRun()
override;
409 :
TestCase(
"Global routing across two hops (broadcast links)")
436 ipv4.SetBase(
"10.1.1.0",
"255.255.255.0");
438 ipv4.SetBase(
"10.1.2.0",
"255.255.255.0");
501 void DoRun()
override;
509 :
TestCase(
"Global routing across bridging topology (bug 2102)")
533 switchDevices.Add(
net2.Get(1));
541 switchDevices.Add(
net3.Get(0));
551 bridge.
Install(switchNode, switchDevices);
566 address.SetBase(
"10.1.1.0",
"255.255.255.0");
569 address.SetBase(
"10.1.2.0",
"255.255.255.0");
572 address.SetBase(
"10.1.3.0",
"255.255.255.0");
573 address.Assign(
net4);
619 "Error-- wrong destination");
622 "Error-- wrong gateway");
641 "Error-- wrong destination");
644 "Error-- wrong gateway");
648 NS_LOG_DEBUG(
"BridgeTest skip print out of n2 and n3, go next to node n4");
666 "Error-- wrong destination");
669 "Error-- wrong gateway");
684 void DoRun()
override;
692 :
TestCase(
"Global routing across two bridges")
756 address.SetBase(
"10.1.1.0",
"255.255.255.0");
759 address.SetBase(
"10.1.2.0",
"255.255.255.0");
799 "Error-- wrong destination");
802 "Error-- wrong gateway");
805 NS_LOG_DEBUG(
"BridgeTest skip print out of n1-n3, go next to node n4");
823 "Error-- wrong destination");
826 "Error-- wrong gateway");
861 void DoRun()
override;
875 :
TestCase(
"Dynamic global routing example"),
890 iter->second =
false;
891 iter->first->Close();
892 iter->first =
nullptr;
902 while ((packet = socket->RecvFrom(from)))
904 if (packet->GetSize() == 0)
914 if (
tag.GetRecvIf() == 1)
918 if (
tag.GetRecvIf() == 2)
991 devHelper.SetNetDevicePointToPointMode(
false);
1000 ipv4.SetBase(
"10.1.1.0",
"255.255.255.0");
1003 ipv4.SetBase(
"10.1.2.0",
"255.255.255.0");
1006 ipv4.SetBase(
"10.1.3.0",
"255.255.255.0");
1009 ipv4.SetBase(
"10.250.1.0",
"255.255.255.0");
1012 ipv4.SetBase(
"172.16.1.0",
"255.255.255.0");
1046 sink2->ShutdownSend();
1048 sink2->SetRecvPktInfo(
true);
1079 "Dynamic global routing did not deliver all packets "
1083 "Dynamic global routing did not deliver all packets "
1087 "Dynamic global routing did not deliver all packets "
1091 "Dynamic global routing did not deliver all packets "
1095 "Dynamic global routing did not deliver all packets "
1099 "Dynamic global routing did not deliver all packets "
1103 "Dynamic global routing did not deliver all packets "
1107 "Dynamic global routing did not deliver all packets "
1111 "Dynamic global routing did not deliver all packets "
1115 "Dynamic global routing did not deliver all packets "
1119 "Dynamic global routing did not deliver all packets "
1123 "Dynamic global routing did not deliver all packets "
1127 "Dynamic global routing did not deliver all packets "
1131 "Dynamic global routing did not deliver all packets "
1135 "Dynamic global routing did not deliver all packets "
1172 void DoRun()
override;
1177 :
TestCase(
"Slash 32 global routing example")
1192 "Received packet size is not equal to Rx buffer size");
1230 internet.Install(
c);
1251 ipv4.SetBase(
"10.1.1.0",
"255.255.255.252");
1254 ipv4.SetBase(
"10.1.1.4",
"255.255.255.252");
1298 "Static routing with /32 did not deliver all packets.");
NodeContainer n1n2
Nodecontainer n1 + n2.
NodeContainer n0n2
Nodecontainer n0 + n2.
IPv4 GlobalRouting Bridge test.
void DoSetup() override
Implementation to do any local setup required for this TestCase.
void DoRun() override
Implementation to actually run this TestCase.
NodeContainer m_nodes
Nodes used in the test.
IPv4 Dynamic GlobalRouting test.
void DoRun() override
Implementation to actually run this TestCase.
uint16_t m_packetSize
Packet size.
~Ipv4DynamicGlobalRoutingTestCase() override
std::vector< uint8_t > m_secondInterface
Packets received on the 2nd interface at a given time.
Ipv4DynamicGlobalRoutingTestCase()
void HandleRead(Ptr< Socket > socket)
Handle an incoming packet.
uint16_t m_count
Number of packets received.
DataRate m_dataRate
Data rate.
std::vector< std::pair< Ptr< Socket >, bool > > m_sendSocks
Sending sockets.
std::vector< uint8_t > m_firstInterface
Packets received on the 1st interface at a given time.
void ShutDownSock(uint8_t index)
Shutdown a socket.
void SendData(uint8_t index)
Send some data.
IPv4 Dynamic GlobalRouting /32 test.
void ReceivePkt(Ptr< Socket > socket)
Receive a packet.
void SendData(Ptr< Socket > socket, std::string to)
Send a packet.
~Ipv4GlobalRoutingSlash32TestCase() override
void DoRun() override
Implementation to actually run this TestCase.
Ipv4GlobalRoutingSlash32TestCase()
void DoSendData(Ptr< Socket > socket, std::string to)
Send a packet.
Ptr< Packet > m_receivedPacket
number of received packets
IPv4 GlobalRouting TestSuite.
Ipv4GlobalRoutingTestSuite()
IPv4 GlobalRouting LAN test.
void DoSetup() override
Implementation to do any local setup required for this TestCase.
void DoRun() override
Implementation to actually run this TestCase.
NodeContainer m_nodes
Nodes used in the test.
IPv4 GlobalRouting Link test.
void DoRun() override
Implementation to actually run this TestCase.
NodeContainer m_nodes
Nodes used in the test.
void DoSetup() override
Implementation to do any local setup required for this TestCase.
IPv4 GlobalRouting Two bridges test.
void DoSetup() override
Implementation to do any local setup required for this TestCase.
void DoRun() override
Implementation to actually run this TestCase.
NodeContainer m_nodes
Nodes used in the test.
IPv4 GlobalRouting Two LAN test.
NodeContainer m_nodes
Nodes used in the test.
void DoRun() override
Implementation to actually run this TestCase.
void DoSetup() override
Implementation to do any local setup required for this TestCase.
IPv4 GlobalRouting Two Link test.
void DoRun() override
Implementation to actually run this TestCase.
NodeContainer m_nodes
Nodes used in the test.
void DoSetup() override
Implementation to do any local setup required for this TestCase.
a polymophic address class
AttributeValue implementation for Boolean.
Add capability to bridge multiple LAN segments (IEEE 802.1D bridging)
NetDeviceContainer Install(Ptr< Node > node, NetDeviceContainer c)
This method creates an ns3::BridgeNetDevice with the attributes configured by BridgeHelper::SetDevice...
Class for representing data rates.
uint64_t GetBitRate() const
Get the underlying bitrate.
aggregate IP/TCP/UDP functionality to existing Nodes.
A helper class to make life easier while doing simple IPv4 address assignment in scripts.
Ipv4 addresses are stored in host order in this class.
static Ipv4Address GetAny()
Helper class that adds ns3::Ipv4GlobalRouting objects.
static void PopulateRoutingTables()
Build a routing database and initialize the routing tables of the nodes in the simulation.
Global routing protocol for IPv4 stacks.
Access to the IPv4 forwarding table, interfaces, and configuration.
virtual void SetUp(uint32_t interface)=0
virtual void SetDown(uint32_t interface)=0
a class to store IPv4 address information on an interface
holds a vector of std::pair of Ptr<Ipv4> and interface index.
Implement the IPv4 layer.
a class to represent an Ipv4 address mask
This class implements Linux struct pktinfo in order to deliver ancillary information to the socket in...
A record of an IPv4 routing table entry for Ipv4GlobalRouting and Ipv4StaticRouting.
static Mac48Address Allocate()
Allocate a new Mac48Address.
holds a vector of ns3::NetDevice pointers
void Add(NetDeviceContainer other)
Append the contents of another NetDeviceContainer to the end of this container.
keep track of a set of node pointers.
void Create(uint32_t n)
Create n nodes and append pointers to them to the end of this NodeContainer.
Ptr< Node > Get(uint32_t i) const
Get the Ptr<Node> stored in this container at a given index.
Ptr< T > GetObject() const
Get a pointer to the requested aggregated Object.
Smart pointer class similar to boost::intrusive_ptr.
build a set of SimpleNetDevice objects
void SetNetDevicePointToPointMode(bool pointToPointMode)
SimpleNetDevice is Broadcast capable and ARP needing.
static EventId Schedule(const Time &delay, FUNC f, Ts &&... args)
Schedule an event to expire after delay.
static void Destroy()
Execute the events scheduled with ScheduleDestroy().
static void ScheduleWithContext(uint32_t context, const Time &delay, FUNC f, Ts &&... args)
Schedule an event with the given context.
static Time Now()
Return the current simulation virtual time.
static void Run()
Run the simulation.
static void Stop()
Tell the Simulator the calling event should be the last one executed.
static Ptr< Socket > CreateSocket(Ptr< Node > node, TypeId tid)
This method wraps the creation of sockets that is performed on a given node by a SocketFactory specif...
void AddTestCase(TestCase *testCase, Duration duration=Duration::QUICK)
Add an individual child TestCase to this test suite.
Simulation virtual time values and global simulation resolution.
double GetSeconds() const
Get an approximation of the time stored in this instance in the indicated unit.
a unique identifier for an interface.
static TypeId LookupByName(std::string name)
Get a TypeId by name.
API to create UDP socket instances.
void SetDefault(std::string name, const AttributeValue &value)
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Ptr< T > Create(Ts &&... args)
Create class instances by constructors with varying numbers of arguments and return them by Ptr.
#define NS_TEST_ASSERT_MSG_EQ(actual, limit, msg)
Test that an actual and expected (limit) value are equal and report and abort if not.
#define NS_TEST_EXPECT_MSG_EQ(actual, limit, msg)
Test that an actual and expected (limit) value are equal and report if not.
#define NS_TEST_ASSERT_MSG_NE(actual, limit, msg)
Test that an actual and expected (limit) value are not equal and report and abort if not.
Time MicroSeconds(uint64_t value)
Construct a Time in the indicated unit.
Time Seconds(double value)
Construct a Time in the indicated unit.
static Ipv4GlobalRoutingTestSuite g_globalRoutingTestSuite
Static variable for test initialization.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Callback< R, Args... > MakeCallback(R(T::*memPtr)(Args...), OBJ objPtr)
Build Callbacks for class method members which take varying numbers of arguments and potentially retu...