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/socket.h"    28 #include "ns3/boolean.h"    33 #include "ns3/inet-socket-address.h"    35 #include "ns3/internet-stack-helper.h"    36 #include "ns3/ipv4-address-helper.h"    37 #include "ns3/ipv4-l3-protocol.h"    38 #include "ns3/icmpv4-l4-protocol.h"    39 #include "ns3/udp-l4-protocol.h"    41 #include "ns3/rip-helper.h"    42 #include "ns3/node-container.h"    43 #include "ns3/ipv4-static-routing.h"    65   void DoSendData (
Ptr<Socket> socket, std::string to);
    74   virtual void DoRun (
void);
    91   uint32_t availableData;
   114   Simulator::Stop (
Seconds (66));
   123   Ptr<Node> txNode = CreateObject<Node> ();
   124   Ptr<Node> rxNode = CreateObject<Node> ();
   125   Ptr<Node> routerA = CreateObject<Node> ();
   126   Ptr<Node> routerB = CreateObject<Node> ();
   127   Ptr<Node> routerC = CreateObject<Node> ();
   136   internetRouters.
Install (routers);
   149     txDev = CreateObject<SimpleNetDevice> ();
   158     fwDev1routerA = CreateObject<SimpleNetDevice> ();
   160     routerA->AddDevice (fwDev1routerA);
   162   net1.
Add (fwDev1routerA);
   165     fwDev2routerA = CreateObject<SimpleNetDevice> ();
   167     routerA->AddDevice (fwDev2routerA);
   169   net2.
Add (fwDev2routerA);
   174     fwDev1routerB = CreateObject<SimpleNetDevice> ();
   176     routerB->AddDevice (fwDev1routerB);
   178   net2.
Add (fwDev1routerB);
   181     fwDev2routerB = CreateObject<SimpleNetDevice> ();
   183     routerB->AddDevice (fwDev2routerB);
   185   net3.
Add (fwDev2routerB);
   190     fwDev1routerC = CreateObject<SimpleNetDevice> ();
   192     routerC->AddDevice (fwDev1routerC);
   194   net3.
Add (fwDev1routerC);
   197     fwDev2routerC = CreateObject<SimpleNetDevice> ();
   199     routerC->AddDevice (fwDev2routerC);
   201   net4.
Add (fwDev2routerC);
   206     rxDev = CreateObject<SimpleNetDevice> ();
   208     rxNode->AddDevice (rxDev);
   245   staticRouting = Ipv4RoutingHelper::GetRouting <Ipv4StaticRouting> (txNode->
GetObject<
Ipv4> ()->GetRoutingProtocol ());
   247   staticRouting = Ipv4RoutingHelper::GetRouting <Ipv4StaticRouting> (rxNode->GetObject<
Ipv4> ()->GetRoutingProtocol ());
   268   Simulator::Destroy ();
   296   virtual void DoRun (
void);
   307   : 
TestCase (
"RIP counting to infinity")
   313   uint32_t availableData;
   319   (void) availableData;
   336   Simulator::Stop (
Seconds (66));
   345   Ptr<Node> txNode = CreateObject<Node> ();
   346   Ptr<Node> rxNode = CreateObject<Node> ();
   347   Ptr<Node> routerA = CreateObject<Node> ();
   348   Ptr<Node> routerB = CreateObject<Node> ();
   349   Ptr<Node> routerC = CreateObject<Node> ();
   365   internetv6routers.
Install (routers);
   378     txDev = CreateObject<SimpleNetDevice> ();
   387     fwDev1routerA = CreateObject<SimpleNetDevice> ();
   389     routerA->AddDevice (fwDev1routerA);
   391   net1.
Add (fwDev1routerA);
   394     fwDev2routerA = CreateObject<SimpleNetDevice> ();
   396     routerA->AddDevice (fwDev2routerA);
   398   net2.
Add (fwDev2routerA);
   403     fwDev1routerB = CreateObject<SimpleNetDevice> ();
   405     routerB->AddDevice (fwDev1routerB);
   407   net2.
Add (fwDev1routerB);
   410     fwDev2routerB = CreateObject<SimpleNetDevice> ();
   412     routerB->AddDevice (fwDev2routerB);
   414   net3.
Add (fwDev2routerB);
   419     fwDev1routerC = CreateObject<SimpleNetDevice> ();
   421     routerC->AddDevice (fwDev1routerC);
   423   net3.
Add (fwDev1routerC);
   426     fwDev2routerC = CreateObject<SimpleNetDevice> ();
   428     routerC->AddDevice (fwDev2routerC);
   430   net4.
Add (fwDev2routerC);
   435     rxDev = CreateObject<SimpleNetDevice> ();
   437     rxNode->AddDevice (rxDev);
   474   staticRouting = Ipv4RoutingHelper::GetRouting <Ipv4StaticRouting> (txNode->
GetObject<
Ipv4> ()->GetRoutingProtocol ());
   476   staticRouting = Ipv4RoutingHelper::GetRouting <Ipv4StaticRouting> (rxNode->GetObject<
Ipv4> ()->GetRoutingProtocol ());
   495   Simulator::Destroy ();
   511   virtual void DoRun (
void);
   527   : 
TestCase (
"RIP Split Horizon strategy")
   534   uint32_t availableData;
   539   Ipv4Address senderAddress = InetSocketAddress::ConvertFrom (srcAddr).GetIpv4 ();
   541   if (senderAddress == 
"192.168.0.2")
   549       for (std::list<RipRte>::iterator iter = rtes.begin ();
   550           iter != rtes.end (); iter++)
   552           if (iter->GetPrefix () == 
"10.0.1.0")
   554               bool correct = 
false;
   555               if (iter->GetRouteMetric () == 16)
   560               else if (iter->GetRouteMetric () == 2)
   572   (void) availableData;
   580   Ptr<Node> fakeNode = CreateObject<Node> ();
   581   Ptr<Node> listener = CreateObject<Node> ();
   583   Ptr<Node> routerA = CreateObject<Node> ();
   584   Ptr<Node> routerB = CreateObject<Node> ();
   595   internetRouters.
Install (routers);
   598   internetNodes.
Install (listeners);
   606     silentDev = CreateObject<SimpleNetDevice> ();
   610   net0.
Add (silentDev);
   615     silentDevRouterA = CreateObject<SimpleNetDevice> ();
   617     routerA->AddDevice (silentDevRouterA);
   619   net0.
Add (silentDevRouterA);
   622     fwDevRouterA = CreateObject<SimpleNetDevice> ();
   624     routerA->AddDevice (fwDevRouterA);
   626   net1.
Add (fwDevRouterA);
   631     fwDevRouterB = CreateObject<SimpleNetDevice> ();
   633     routerB->AddDevice (fwDevRouterB);
   635   net1.
Add (fwDevRouterB);
   640     listenerDev = CreateObject<SimpleNetDevice> ();
   642     listener->AddDevice (listenerDev);
   644   net1.
Add (listenerDev);
   677   Simulator::Stop (
Seconds (66));
   681   Simulator::Destroy ();
 uint32_t RemoveHeader(Header &header)
Deserialize and remove the header from the internal buffer. 
Ptr< Packet > m_receivedPacket
Received packet. 
uint32_t GetId(void) const
static Ipv4RipTestSuite g_ipv4ripTestSuite
Static variable for test initialization. 
holds a vector of std::pair of Ptr<Ipv4> and interface index. 
void SetDefaultRoute(Ipv4Address nextHop, uint32_t interface, uint32_t metric=0)
Add a default route to the static routing table. 
uint32_t GetSize(void) const
Returns the the size in bytes of the packet (including the zero-filled initial payload). 
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. 
virtual Ptr< Socket > CreateSocket(void)=0
Helper class that adds RIP routing to nodes. 
Rip::SplitHorizonType_e m_detectedStrategy
Strategy detected. 
Ipv4RipSplitHorizonStrategyTest(Rip::SplitHorizonType_e strategy)
Constructor. 
IPv4 RIP count to infinity Test. 
a polymophic address class 
void Set(std::string name, const AttributeValue &value)
void ReceivePkt(Ptr< Socket > socket)
Receive data. 
Hold variables of type enum. 
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
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
Strategy set. 
void SendData(Ptr< Socket > socket, std::string to)
Send data. 
Ptr< Packet > m_receivedPacket
Received packet. 
IPv4 RIP SplitHorizon strategy Test. 
holds a vector of ns3::NetDevice pointers 
void ReceivePkt(Ptr< Socket > socket)
Receive data. 
virtual void DoRun(void)
Implementation to actually run this TestCase. 
Callback< R > MakeCallback(R(T::*memPtr)(void), OBJ objPtr)
SplitHorizonType_e
Split Horizon strategy type. 
void SendData(Ptr< Socket > socket, std::string to)
Send data. 
Access to the IPv4 forwarding table, interfaces, and configuration. 
Ptr< T > GetObject(void) const
Get a pointer to the requested aggregated Object. 
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 SetInterfaceMetric(Ptr< Node > node, uint32_t interface, uint8_t metric)
Set a metric for an interface. 
virtual void BindToNetDevice(Ptr< NetDevice > netdevice)
Bind a socket to specific device. 
void Install(std::string nodeName) const
Aggregate implementations of the ns3::Ipv4, ns3::Ipv6, ns3::Udp, and ns3::Tcp classes onto the provid...
void DoSendData(Ptr< Socket > socket, std::string to)
Send data. 
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. 
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. 
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. 
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. 
This test suite implements a Unit Test. 
void SetChannel(Ptr< SimpleChannel > channel)
Attach a channel to this net device. 
void ReceivePktProbe(Ptr< Socket > socket)
Receive data. 
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)
Send data. 
virtual uint32_t GetRxAvailable(void) const =0
Return number of bytes which can be returned from one or multiple calls to Recv.