18 #include "ns3/boolean.h"
19 #include "ns3/config.h"
20 #include "ns3/csma-helper.h"
21 #include "ns3/flow-monitor.h"
22 #include "ns3/flow-monitor-helper.h"
23 #include "ns3/inet-socket-address.h"
24 #include "ns3/internet-stack-helper.h"
25 #include "ns3/ipv4-address-helper.h"
26 #include "ns3/ipv4-global-routing-helper.h"
27 #include "ns3/ipv4-static-routing-helper.h"
29 #include "ns3/node-container.h"
30 #include "ns3/on-off-helper.h"
31 #include "ns3/packet.h"
32 #include "ns3/packet-sink-helper.h"
33 #include "ns3/packet-sink.h"
34 #include "ns3/packet-socket-helper.h"
35 #include "ns3/packet-socket-address.h"
36 #include "ns3/csma-net-device.h"
37 #include "ns3/point-to-point-helper.h"
38 #include "ns3/pointer.h"
39 #include "ns3/simple-channel.h"
40 #include "ns3/simulator.h"
41 #include "ns3/string.h"
43 #include "ns3/uinteger.h"
44 #include "ns3/ipv4-packet-info-tag.h"
57 virtual void DoRun (
void);
65 :
TestCase (
"Dynamic global routing example"), m_count (0)
95 while ((packet = socket->
RecvFrom (from)))
178 ipv4.
SetBase (
"10.1.1.0",
"255.255.255.0");
181 ipv4.
SetBase (
"10.1.2.0",
"255.255.255.0");
184 ipv4.
SetBase (
"10.1.3.0",
"255.255.255.0");
187 ipv4.
SetBase (
"10.250.1.0",
"255.255.255.0");
190 ipv4.
SetBase (
"172.16.1.0",
"255.255.255.0");
195 Ipv4GlobalRoutingHelper::PopulateRoutingTables ();
206 apps.
Start (Seconds (1.0));
207 apps.
Stop (Seconds (10.0));
219 apps2.
Start (Seconds (11.0));
220 apps2.
Stop (Seconds (16.0));
223 TypeId tid = TypeId::LookupByName (
"ns3::UdpSocketFactory");
236 uint32_t ipv4ifIndex1 = 2;
242 Simulator::Schedule (Seconds (2),&Ipv4::SetDown,ipv41, ipv4ifIndex1);
243 Simulator::Schedule (Seconds (4),&
Ipv4::SetUp,ipv41, ipv4ifIndex1);
249 uint32_t ipv4ifIndex6 = 2;
250 Simulator::Schedule (Seconds (6),&Ipv4::SetDown,ipv46, ipv4ifIndex6);
251 Simulator::Schedule (Seconds (8),&
Ipv4::SetUp,ipv46, ipv4ifIndex6);
253 Simulator::Schedule (Seconds (12),&Ipv4::SetDown,ipv41, ipv4ifIndex1);
254 Simulator::Schedule (Seconds (14),&
Ipv4::SetUp,ipv41, ipv4ifIndex1);
277 Simulator::Destroy ();
287 virtual void DoRun (
void);
292 :
TestCase (
"Slash 32 global routing example")
329 deviceA->
SetAddress (Mac48Address::Allocate ());
333 deviceC->
SetAddress (Mac48Address::Allocate ());
334 nC->AddDevice (deviceC);
338 ipv4.
SetBase (
"10.1.1.0",
"255.255.255.252");
341 ipv4.
SetBase (
"10.1.1.4",
"255.255.255.252");
348 int32_t ifIndexC = ipv4C->AddInterface (deviceC);
353 ipv4A->
SetUp (ifIndexA);
356 ipv4C->AddAddress (ifIndexC, ifInAddrC);
357 ipv4C->SetMetric (ifIndexC, 1);
358 ipv4C->SetUp (ifIndexC);
362 Ipv4GlobalRoutingHelper::PopulateRoutingTables ();
371 apps.
Start (Seconds (1.0));
372 apps.
Stop (Seconds (10.0));
378 apps.
Start (Seconds (1.0));
379 apps.
Stop (Seconds (10.0));
385 Simulator::Destroy ();
holds a vector of ns3::Application pointers.
virtual ~GlobalRoutingSlash32TestCase()
virtual uint32_t AddInterface(Ptr< NetDevice > device)=0
void SetChannelAttribute(std::string n1, const AttributeValue &v1)
holds a vector of std::pair of Ptr and interface index.
Ipv4Address GetLocal(void) const
Get the local address.
hold variables of type string
NetDeviceContainer Install(NodeContainer c)
a class to represent an Ipv4 address mask
virtual int ShutdownSend(void)=0
virtual ~DynamicGlobalRoutingTestCase()
aggregate IP/TCP/UDP functionality to existing Nodes.
uint32_t GetSize(void) const
NetDeviceContainer Install(Ptr< Node > node) const
This method creates an ns3::CsmaChannel with the attributes configured by CsmaHelper::SetChannelAttri...
A helper to make it easier to instantiate an ns3::PacketSinkApplication on a set of nodes...
Build a set of PointToPointNetDevice objects.
void Connect(std::string path, const CallbackBase &cb)
void SetDeviceAttribute(std::string name, const AttributeValue &value)
Set an attribute value to be propagated to each NetDevice created by the helper.
A helper to make it easier to instantiate an ns3::OnOffApplication on a set of nodes.
a polymophic address class
void SetUp(char *deviceName)
virtual int Listen(void)=0
Listen for incoming connections.
Class for representing data rates.
void SetRecvPktInfo(bool flag)
Enable/Disable receive packet information to socket.
double GetSeconds(void) const
std::vector< uint8_t > m_secondInterface
bool PeekPacketTag(Tag &tag) const
Search a matching tag and call Tag::Deserialize if it is found.
DynamicGlobalRoutingTestCase()
void HandleRead(Ptr< Socket >)
virtual void DoRun(void)
Implementation to actually run this TestCase.
virtual void SetUp(uint32_t interface)=0
uint32_t GetRecvIf(void) const
Get the tag's receiving interface.
Hold an unsigned integer type.
holds a vector of ns3::NetDevice pointers
virtual void DoRun(void)
Implementation to actually run this TestCase.
Callback< R > MakeCallback(R(T::*memPtr)(void), OBJ objPtr)
void SetRecvCallback(Callback< void, Ptr< Socket > >)
Notify application when new data is available to be read.
void Start(Time start)
Arrange for all of the Applications in this container to Start() at the Time given as a parameter...
GlobalRoutingSlash32TestCase()
Access to the Ipv4 forwarding table, interfaces, and configuration.
void SetDefault(std::string name, const AttributeValue &value)
virtual int Bind(const Address &address)=0
Allocate a local endpoint for this socket.
void SetConstantRate(DataRate dataRate, uint32_t packetSize=512)
Helper function to set a constant rate source.
keep track of a set of node pointers.
Ptr< Application > Get(uint32_t i) const
Get the Ptr
stored in this container at a given index.
void Install(std::string nodeName) const
Aggregate implementations of the ns3::Ipv4, ns3::Ipv6, ns3::Udp, and ns3::Tcp classes onto the provid...
void AddTestCase(TestCase *testCase) NS_DEPRECATED
Add an individual child TestCase case to this TestCase.
uint32_t GetTotalRx() const
static GlobalRoutingTestSuite globalRoutingTestSuite
This class implements Linux struct pktinfo in order to deliver ancillary information to the socket in...
build a set of CsmaNetDevice objects
void SetChannelAttribute(std::string name, const AttributeValue &value)
Set an attribute value to be propagated to each Channel created by the helper.
Ipv4 addresses are stored in host order in this class.
void Stop(Time stop)
Arrange for all of the Applications in this container to Stop() at the Time given as a parameter...
Ipv4InterfaceContainer Assign(const NetDeviceContainer &c)
Assign IP addresses to the net devices specified in the container based on the current network prefix...
uint32_t AddDevice(Ptr< NetDevice > device)
a class to store IPv4 address information on an interface
Time Now(void)
create an ns3::Time instance which contains the current simulation time.
Ptr< Node > Get(uint32_t i) const
Get the Ptr stored in this container at a given index.
std::vector< uint8_t > m_firstInterface
virtual void SetMetric(uint32_t interface, uint16_t metric)=0
virtual void SetAddress(Address address)
Set the address of this interface.
virtual bool AddAddress(uint32_t interface, Ipv4InterfaceAddress address)=0
ApplicationContainer Install(NodeContainer c) const
Install an ns3::PacketSinkApplication on each node of the input container configured with all the att...
A helper class to make life easier while doing simple IPv4 address assignment in scripts.
void Create(uint32_t n)
Create n nodes and append pointers to them to the end of this NodeContainer.
virtual Ptr< Packet > RecvFrom(uint32_t maxSize, uint32_t flags, Address &fromAddress)=0
Read a single packet from the socket and retrieve the sender address.
void SinkRx(std::string path, Ptr< const Packet > p, const Address &address)
static void SinkRx(std::string path, Ptr< const Packet > p, const Address &address)
Ptr< T > GetObject(void) const
ApplicationContainer Install(NodeContainer c) const
Install an ns3::OnOffApplication on each node of the input container configured with all the attribut...
a unique identifier for an interface.
void SetAttribute(std::string name, const AttributeValue &value)
Helper function used to set the underlying application attributes.
void SetBase(Ipv4Address network, Ipv4Mask mask, Ipv4Address base="0.0.0.1")
Set the base network number, network mask and base address.
#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.
Ipv4Address GetAddress(uint32_t i, uint32_t j=0) const