22 #include "ns3/socket-factory.h"
23 #include "ns3/udp-socket-factory.h"
24 #include "ns3/simulator.h"
25 #include "ns3/simple-channel.h"
26 #include "ns3/simple-net-device.h"
27 #include "ns3/drop-tail-queue.h"
28 #include "ns3/socket.h"
29 #include "ns3/boolean.h"
34 #include "ns3/inet-socket-address.h"
36 #include "ns3/internet-stack-helper.h"
37 #include "ns3/ipv4-address-helper.h"
38 #include "ns3/ipv4-l3-protocol.h"
39 #include "ns3/icmpv4-l4-protocol.h"
40 #include "ns3/udp-l4-protocol.h"
42 #include "ns3/rip-helper.h"
43 #include "ns3/node-container.h"
44 #include "ns3/ipv4-static-routing.h"
56 void DoSendData (
Ptr<Socket> socket, std::string to);
60 virtual void DoRun (
void);
73 uint32_t availableData;
105 Ptr<Node> txNode = CreateObject<Node> ();
106 Ptr<Node> rxNode = CreateObject<Node> ();
107 Ptr<Node> routerA = CreateObject<Node> ();
108 Ptr<Node> routerB = CreateObject<Node> ();
109 Ptr<Node> routerC = CreateObject<Node> ();
118 internetRouters.
Install (routers);
131 txDev = CreateObject<SimpleNetDevice> ();
140 fwDev1routerA = CreateObject<SimpleNetDevice> ();
142 routerA->AddDevice (fwDev1routerA);
144 net1.
Add (fwDev1routerA);
147 fwDev2routerA = CreateObject<SimpleNetDevice> ();
149 routerA->AddDevice (fwDev2routerA);
151 net2.
Add (fwDev2routerA);
156 fwDev1routerB = CreateObject<SimpleNetDevice> ();
158 routerB->AddDevice (fwDev1routerB);
160 net2.
Add (fwDev1routerB);
163 fwDev2routerB = CreateObject<SimpleNetDevice> ();
165 routerB->AddDevice (fwDev2routerB);
167 net3.
Add (fwDev2routerB);
172 fwDev1routerC = CreateObject<SimpleNetDevice> ();
174 routerC->AddDevice (fwDev1routerC);
176 net3.
Add (fwDev1routerC);
179 fwDev2routerC = CreateObject<SimpleNetDevice> ();
181 routerC->AddDevice (fwDev2routerC);
183 net4.
Add (fwDev2routerC);
188 rxDev = CreateObject<SimpleNetDevice> ();
190 rxNode->AddDevice (rxDev);
227 staticRouting = Ipv4RoutingHelper::GetRouting <Ipv4StaticRouting> (txNode->
GetObject<
Ipv4> ()->GetRoutingProtocol ());
229 staticRouting = Ipv4RoutingHelper::GetRouting <Ipv4StaticRouting> (rxNode->GetObject<
Ipv4> ()->GetRoutingProtocol ());
250 Simulator::Destroy ();
262 virtual void DoRun (
void);
269 :
TestCase (
"RIP counting to infinity")
275 uint32_t availableData;
281 (void) availableData;
298 Simulator::Stop (
Seconds (66));
307 Ptr<Node> txNode = CreateObject<Node> ();
308 Ptr<Node> rxNode = CreateObject<Node> ();
309 Ptr<Node> routerA = CreateObject<Node> ();
310 Ptr<Node> routerB = CreateObject<Node> ();
311 Ptr<Node> routerC = CreateObject<Node> ();
327 internetv6routers.
Install (routers);
330 internetv6nodes.
Install (nodes);
340 txDev = CreateObject<SimpleNetDevice> ();
349 fwDev1routerA = CreateObject<SimpleNetDevice> ();
351 routerA->AddDevice (fwDev1routerA);
353 net1.
Add (fwDev1routerA);
356 fwDev2routerA = CreateObject<SimpleNetDevice> ();
358 routerA->AddDevice (fwDev2routerA);
360 net2.
Add (fwDev2routerA);
365 fwDev1routerB = CreateObject<SimpleNetDevice> ();
367 routerB->AddDevice (fwDev1routerB);
369 net2.
Add (fwDev1routerB);
372 fwDev2routerB = CreateObject<SimpleNetDevice> ();
374 routerB->AddDevice (fwDev2routerB);
376 net3.
Add (fwDev2routerB);
381 fwDev1routerC = CreateObject<SimpleNetDevice> ();
383 routerC->AddDevice (fwDev1routerC);
385 net3.
Add (fwDev1routerC);
388 fwDev2routerC = CreateObject<SimpleNetDevice> ();
390 routerC->AddDevice (fwDev2routerC);
392 net4.
Add (fwDev2routerC);
397 rxDev = CreateObject<SimpleNetDevice> ();
399 rxNode->AddDevice (rxDev);
436 staticRouting = Ipv4RoutingHelper::GetRouting <Ipv4StaticRouting> (txNode->
GetObject<
Ipv4> ()->GetRoutingProtocol ());
438 staticRouting = Ipv4RoutingHelper::GetRouting <Ipv4StaticRouting> (rxNode->GetObject<
Ipv4> ()->GetRoutingProtocol ());
457 Simulator::Destroy ();
468 virtual void DoRun (
void);
475 :
TestCase (
"RIP Split Horizon strategy")
482 uint32_t availableData;
488 Ipv4Address senderAddress = InetSocketAddress::ConvertFrom (tag.GetAddress ()).GetIpv4 ();
490 if (senderAddress ==
"192.168.0.2")
498 for (std::list<RipRte>::iterator iter = rtes.begin ();
499 iter != rtes.end (); iter++)
501 if (iter->GetPrefix () ==
"10.0.1.0")
503 bool correct =
false;
504 if (iter->GetRouteMetric () == 16)
509 else if (iter->GetRouteMetric () == 2)
521 (void) availableData;
529 Ptr<Node> fakeNode = CreateObject<Node> ();
530 Ptr<Node> listener = CreateObject<Node> ();
532 Ptr<Node> routerA = CreateObject<Node> ();
533 Ptr<Node> routerB = CreateObject<Node> ();
544 internetRouters.
Install (routers);
547 internetNodes.
Install (listeners);
555 silentDev = CreateObject<SimpleNetDevice> ();
559 net0.
Add (silentDev);
564 silentDevRouterA = CreateObject<SimpleNetDevice> ();
566 routerA->AddDevice (silentDevRouterA);
568 net0.
Add (silentDevRouterA);
571 fwDevRouterA = CreateObject<SimpleNetDevice> ();
573 routerA->AddDevice (fwDevRouterA);
575 net1.
Add (fwDevRouterA);
580 fwDevRouterB = CreateObject<SimpleNetDevice> ();
582 routerB->AddDevice (fwDevRouterB);
584 net1.
Add (fwDevRouterB);
589 listenerDev = CreateObject<SimpleNetDevice> ();
591 listener->AddDevice (listenerDev);
593 net1.
Add (listenerDev);
618 rxSocket->BindToNetDevice (listenerDev);
626 Simulator::Stop (
Seconds (66));
630 Simulator::Destroy ();
uint32_t RemoveHeader(Header &header)
Deserialize and remove the header from the internal buffer.
Ptr< Packet > m_receivedPacket
holds a vector of std::pair of Ptr and interface index.
void SetDefaultRoute(Ipv4Address nextHop, uint32_t interface, uint32_t metric=0)
Add a default route to the static routing table.
Ptr< T > GetObject(void) const
Get a pointer to the requested aggregated Object.
virtual bool SetAllowBroadcast(bool allowBroadcast)=0
Configure whether broadcast datagram transmissions are allowed.
a class to represent an Ipv4 address mask
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file...
aggregate IP/TCP/UDP functionality to existing Nodes.
#define NS_TEST_EXPECT_MSG_EQ(actual, limit, msg)
Test that an actual and expected (limit) value are equal and report if not.
uint32_t GetSize(void) const
Returns the the size in bytes of the packet (including the zero-filled initial payload).
virtual Ptr< Socket > CreateSocket(void)=0
Helper class that adds RIP routing to nodes.
Rip::SplitHorizonType_e m_detectedStrategy
This test suite implements a Unit Test.
Ipv4RipSplitHorizonStrategyTest(Rip::SplitHorizonType_e strategy)
a polymophic address class
void Set(std::string name, const AttributeValue &value)
SplitHorizonType_e
Split Horizon strategy type.
void ReceivePkt(Ptr< Socket > socket)
Hold variables of type enum.
void AddTestCase(TestCase *testCase, enum TestDuration duration)
Add an individual child TestCase to this test suite.
void Add(NetDeviceContainer other)
Append the contents of another NetDeviceContainer to the end of this container.
Rip::SplitHorizonType_e m_setStrategy
void SendData(Ptr< Socket > socket, std::string to)
Ptr< Packet > m_receivedPacket
holds a vector of ns3::NetDevice pointers
void ReceivePkt(Ptr< Socket > socket)
This class implements a tag that carries an address of a packet across the socket interface...
virtual void DoRun(void)
Implementation to actually run this TestCase.
Callback< R > MakeCallback(R(T::*memPtr)(void), OBJ objPtr)
void SendData(Ptr< Socket > socket, std::string to)
Access to the Ipv4 forwarding table, interfaces, and configuration.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
keep track of a set of node pointers.
virtual void DoRun(void)
Implementation to actually run this TestCase.
virtual Ptr< Packet > Recv(uint32_t maxSize, uint32_t flags)=0
Read data from the socket.
void Install(std::string nodeName) const
Aggregate implementations of the ns3::Ipv4, ns3::Ipv6, ns3::Udp, and ns3::Tcp classes onto the provid...
void SetInterfaceMetric(Ptr< Node > node, uint32_t interface, uint8_t metric)
Set a metric for an interface.
Ipv4RipTestSuite g_ipv4ripTestSuite
void DoSendData(Ptr< Socket > socket, std::string to)
Ipv4 addresses are stored in host order in this class.
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)
Associate a NetDevice to this node.
uint32_t GetId(void) const
virtual Ptr< Node > GetNode(void) const =0
Return the node this socket is associated with.
virtual void DoRun(void)
Implementation to actually run this TestCase.
bool RemovePacketTag(Tag &tag)
Remove a packet tag.
virtual void SetAddress(Address address)
Set the address of this interface.
Time Seconds(double value)
Construct a Time in the indicated unit.
void RemoveAllByteTags(void)
Remove all byte tags stored in this packet.
virtual int SendTo(Ptr< Packet > p, uint32_t flags, const Address &toAddress)=0
Send data to a specified peer.
A helper class to make life easier while doing simple IPv4 address assignment in scripts.
API to create UDP socket instances.
void SetChannel(Ptr< SimpleChannel > channel)
Attach a channel to this net device.
void ReceivePktProbe(Ptr< Socket > socket)
void SetRoutingHelper(const Ipv4RoutingHelper &routing)
Ipv4RipCountToInfinityTest()
void SetBase(Ipv4Address network, Ipv4Mask mask, Ipv4Address base="0.0.0.1")
Set the base network number, network mask and base address.
void DoSendData(Ptr< Socket > socket, std::string to)
virtual uint32_t GetRxAvailable(void) const =0
Return number of bytes which can be returned from one or multiple calls to Recv.