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/inet6-socket-address.h"
36 #include "ns3/internet-stack-helper.h"
37 #include "ns3/ipv6-address-helper.h"
38 #include "ns3/ipv6-l3-protocol.h"
39 #include "ns3/icmpv6-l4-protocol.h"
40 #include "ns3/udp-l4-protocol.h"
41 #include "ns3/ipv6-static-routing.h"
42 #include "ns3/ipv6-list-routing.h"
43 #include "ns3/ipv6-list-routing-helper.h"
44 #include "ns3/ripng.h"
45 #include "ns3/ripng-helper.h"
46 #include "ns3/node-container.h"
58 void DoSendData (
Ptr<Socket> socket, std::string to);
62 virtual void DoRun (
void);
75 uint32_t availableData;
107 Ptr<Node> txNode = CreateObject<Node> ();
108 Ptr<Node> rxNode = CreateObject<Node> ();
109 Ptr<Node> routerA = CreateObject<Node> ();
110 Ptr<Node> routerB = CreateObject<Node> ();
111 Ptr<Node> routerC = CreateObject<Node> ();
119 listRH.
Add (ripNgRouting, 0);
122 internetv6routers.
Install (routers);
125 internetv6nodes.
Install (nodes);
135 txDev = CreateObject<SimpleNetDevice> ();
144 fwDev1routerA = CreateObject<SimpleNetDevice> ();
146 routerA->AddDevice (fwDev1routerA);
148 net1.
Add (fwDev1routerA);
151 fwDev2routerA = CreateObject<SimpleNetDevice> ();
153 routerA->AddDevice (fwDev2routerA);
155 net2.
Add (fwDev2routerA);
160 fwDev1routerB = CreateObject<SimpleNetDevice> ();
162 routerB->AddDevice (fwDev1routerB);
164 net2.
Add (fwDev1routerB);
167 fwDev2routerB = CreateObject<SimpleNetDevice> ();
169 routerB->AddDevice (fwDev2routerB);
171 net3.
Add (fwDev2routerB);
176 fwDev1routerC = CreateObject<SimpleNetDevice> ();
178 routerC->AddDevice (fwDev1routerC);
180 net3.
Add (fwDev1routerC);
183 fwDev2routerC = CreateObject<SimpleNetDevice> ();
185 routerC->AddDevice (fwDev2routerC);
187 net4.
Add (fwDev2routerC);
192 rxDev = CreateObject<SimpleNetDevice> ();
194 rxNode->AddDevice (rxDev);
249 SendData (txSocket,
"2001:2::200:ff:fe00:8");
254 Simulator::Destroy ();
266 virtual void DoRun (
void);
273 :
TestCase (
"RIPng counting to infinity")
279 uint32_t availableData;
285 (void) availableData;
302 Simulator::Stop (
Seconds (66));
311 Ptr<Node> txNode = CreateObject<Node> ();
312 Ptr<Node> rxNode = CreateObject<Node> ();
313 Ptr<Node> routerA = CreateObject<Node> ();
314 Ptr<Node> routerB = CreateObject<Node> ();
315 Ptr<Node> routerC = CreateObject<Node> ();
330 listRH.
Add (ripNgRouting, 0);
333 internetv6routers.
Install (routers);
336 internetv6nodes.
Install (nodes);
346 txDev = CreateObject<SimpleNetDevice> ();
355 fwDev1routerA = CreateObject<SimpleNetDevice> ();
357 routerA->AddDevice (fwDev1routerA);
359 net1.
Add (fwDev1routerA);
362 fwDev2routerA = CreateObject<SimpleNetDevice> ();
364 routerA->AddDevice (fwDev2routerA);
366 net2.
Add (fwDev2routerA);
371 fwDev1routerB = CreateObject<SimpleNetDevice> ();
373 routerB->AddDevice (fwDev1routerB);
375 net2.
Add (fwDev1routerB);
378 fwDev2routerB = CreateObject<SimpleNetDevice> ();
380 routerB->AddDevice (fwDev2routerB);
382 net3.
Add (fwDev2routerB);
387 fwDev1routerC = CreateObject<SimpleNetDevice> ();
389 routerC->AddDevice (fwDev1routerC);
391 net3.
Add (fwDev1routerC);
394 fwDev2routerC = CreateObject<SimpleNetDevice> ();
396 routerC->AddDevice (fwDev2routerC);
398 net4.
Add (fwDev2routerC);
403 rxDev = CreateObject<SimpleNetDevice> ();
405 rxNode->AddDevice (rxDev);
459 SendData (txSocket,
"2001:2::200:ff:fe00:8");
462 Simulator::Destroy ();
473 virtual void DoRun (
void);
480 :
TestCase (
"RIPng Split Horizon strategy")
487 uint32_t availableData;
489 Ptr<Packet> receivedPacketProbe = socket->
Recv (std::numeric_limits<uint32_t>::max (), 0);
493 Ipv6Address senderAddress = Inet6SocketAddress::ConvertFrom (tag.GetAddress ()).GetIpv6 ();
495 if (senderAddress ==
"fe80::200:ff:fe00:4")
502 for (std::list<RipNgRte>::iterator iter = rtes.begin ();
503 iter != rtes.end (); iter++)
505 if (iter->GetPrefix () ==
"2001:1::")
507 bool correct =
false;
508 if (iter->GetRouteMetric () == 16)
513 else if (iter->GetRouteMetric () == 2)
518 NS_TEST_EXPECT_MSG_EQ (correct,
true,
"RIPng: unexpected metric value: " << iter->GetRouteMetric ());
525 (void) availableData;
533 Ptr<Node> fakeNode = CreateObject<Node> ();
534 Ptr<Node> listener = CreateObject<Node> ();
536 Ptr<Node> routerA = CreateObject<Node> ();
537 Ptr<Node> routerB = CreateObject<Node> ();
547 listRH.
Add (ripNgRouting, 0);
550 internetv6routers.
Install (routers);
553 internetv6nodes.
Install (listeners);
561 silentDev = CreateObject<SimpleNetDevice> ();
565 net0.
Add (silentDev);
570 silentDevRouterA = CreateObject<SimpleNetDevice> ();
572 routerA->AddDevice (silentDevRouterA);
574 net0.
Add (silentDevRouterA);
577 fwDevRouterA = CreateObject<SimpleNetDevice> ();
579 routerA->AddDevice (fwDevRouterA);
581 net1.
Add (fwDevRouterA);
586 fwDevRouterB = CreateObject<SimpleNetDevice> ();
588 routerB->AddDevice (fwDevRouterB);
590 net1.
Add (fwDevRouterB);
595 listenerDev = CreateObject<SimpleNetDevice> ();
597 listener->AddDevice (listenerDev);
599 net1.
Add (listenerDev);
632 Simulator::Stop (
Seconds (66));
636 Simulator::Destroy ();
Ptr< Packet > m_receivedPacket
uint32_t RemoveHeader(Header &header)
Deserialize and remove the header from the internal buffer.
virtual void DoRun(void)
Implementation to actually run this TestCase.
Keep track of a set of IPv6 interfaces.
virtual bool SetAllowBroadcast(bool allowBroadcast)=0
Configure whether broadcast datagram transmissions are allowed.
void SetDefaultRouteInAllNodes(uint32_t router)
Set the default route for all the devices (except the router itself).
#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).
void SetBase(Ipv6Address network, Ipv6Prefix prefix, Ipv6Address base=Ipv6Address("::1"))
Set the base network number, network prefix, and base interface ID.
Helper class that adds RIPng routing to nodes.
virtual Ptr< Socket > CreateSocket(void)=0
void ReceivePktProbe(Ptr< Socket > socket)
void ReceivePkt(Ptr< Socket > socket)
void SetForwarding(uint32_t i, bool state)
Set the state of the stack (act as a router or as an host) for the specified index.
a polymophic address class
Ipv6InterfaceContainer Assign(const NetDeviceContainer &c)
Allocate an Ipv6InterfaceContainer with auto-assigned addresses.
hold variables of type 'enum'
void DoSendData(Ptr< Socket > socket, std::string to)
void Add(NetDeviceContainer other)
Append the contents of another NetDeviceContainer to the end of this container.
Ipv6RipngTestSuite g_ipv6ripngTestSuite
void SetInterfaceMetric(Ptr< Node > node, uint32_t interface, uint8_t metric)
Set a metric for an interface.
RipNg::SplitHorizonType_e m_detectedStrategy
holds a vector of ns3::NetDevice pointers
This class implements a tag that carries an address of a packet across the socket interface...
Callback< R > MakeCallback(R(T::*memPtr)(void), OBJ objPtr)
RipNg::SplitHorizonType_e m_setStrategy
void SendData(Ptr< Socket > socket, std::string to)
keep track of a set of node pointers.
void Set(std::string name, const AttributeValue &value)
virtual Ptr< Packet > Recv(uint32_t maxSize, uint32_t flags)=0
Read data from the socket.
Ipv6RipngCountToInfinityTest()
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)
Ipv6RipngSplitHorizonStrategyTest(RipNg::SplitHorizonType_e strategy)
virtual void DoRun(void)
Implementation to actually run this TestCase.
void AddTestCase(TestCase *testCase) NS_DEPRECATED
Add an individual child TestCase case to this TestCase.
virtual void DoRun(void)
Implementation to actually run this TestCase.
Ptr< Packet > m_receivedPacket
Helper class to auto-assign global IPv6 unicast addresses.
void Add(const Ipv6RoutingHelper &routing, int16_t priority)
Describes an IPv6 address.
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.
void SendData(Ptr< Socket > socket, std::string to)
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.
Describes an IPv6 prefix.
Helper class that adds ns3::Ipv6ListRouting objects.
virtual int SendTo(Ptr< Packet > p, uint32_t flags, const Address &toAddress)=0
Send data to a specified peer.
API to create UDP socket instances.
SplitHorizonType_e
Split Horizon strategy type.
This test suite implements a Unit Test.
Ipv6InterfaceContainer AssignWithoutAddress(const NetDeviceContainer &c)
Allocate an Ipv6InterfaceContainer but do not assign any IPv6 addresses.
void SetChannel(Ptr< SimpleChannel > channel)
Attach a channel to this net device.
Ptr< T > GetObject(void) const
void SetRoutingHelper(const Ipv4RoutingHelper &routing)
void ReceivePkt(Ptr< Socket > socket)
virtual uint32_t GetRxAvailable(void) const =0
Return number of bytes which can be returned from one or multiple calls to Recv.