26 #include "ns3/socket-factory.h"
27 #include "ns3/udp-socket-factory.h"
28 #include "ns3/simulator.h"
29 #include "ns3/simple-channel.h"
30 #include "ns3/simple-net-device.h"
31 #include "ns3/simple-net-device-helper.h"
32 #include "ns3/drop-tail-queue.h"
33 #include "ns3/socket.h"
35 #include "ns3/boolean.h"
38 #include "ns3/inet-socket-address.h"
39 #include "ns3/inet6-socket-address.h"
40 #include "ns3/internet-stack-helper.h"
42 #include "ns3/arp-l3-protocol.h"
43 #include "ns3/ipv4-l3-protocol.h"
44 #include "ns3/ipv6-l3-protocol.h"
45 #include "ns3/icmpv4-l4-protocol.h"
46 #include "ns3/icmpv6-l4-protocol.h"
47 #include "ns3/udp-l4-protocol.h"
48 #include "ns3/tcp-l4-protocol.h"
49 #include "ns3/ipv4-list-routing.h"
50 #include "ns3/ipv4-static-routing.h"
51 #include "ns3/ipv6-list-routing.h"
52 #include "ns3/ipv6-static-routing.h"
53 #include "ns3/ipv6-address-helper.h"
65 virtual void DoRun (
void);
78 uint32_t availableData;
99 Simulator::Destroy ();
107 virtual void DoRun (
void);
120 uint32_t availableData;
126 (void) availableData;
132 Ptr<Node> rxNode = CreateObject<Node> ();
144 Simulator::Destroy ();
156 virtual void DoRun (
void);
166 :
TestCase (
"UDP socket implementation")
182 uint32_t availableData;
190 uint32_t availableData;
220 Ptr<Node> rxNode = CreateObject<Node> ();
222 Ptr<Node> txNode = CreateObject<Node> ();
246 ipv4->
SetUp (netdev_idx);
251 ipv4->
SetUp (netdev_idx);
258 ipv4->
SetUp (netdev_idx);
263 ipv4->
SetUp (netdev_idx);
291 SendData (txSocket,
"255.255.255.255");
308 SendData (txSocket,
"255.255.255.255");
317 txSocket->BindToNetDevice (net1.
Get (1));
319 NS_TEST_EXPECT_MSG_EQ (m_receivedPacket->GetSize (), 0,
"first socket should not receive it (it is bound specifically to the second interface's address");
322 m_receivedPacket->RemoveAllByteTags ();
325 Simulator::Destroy ();
337 virtual void DoRun (
void);
347 :
TestCase (
"UDP6 socket implementation")
363 uint32_t availableData;
369 (void) availableData;
374 uint32_t availableData;
380 (void) availableData;
407 Ptr<Node> rxNode = CreateObject<Node> ();
409 Ptr<Node> txNode = CreateObject<Node> ();
437 device = net1.
Get (0);
441 ipv6->
SetUp (ifIndex);
443 device = net2.
Get (0);
447 ipv6->
SetUp (ifIndex);
450 device = net1.
Get (1);
454 ipv6->
SetUp (ifIndex);
456 device = net2.
Get (1);
460 ipv6->
SetUp (ifIndex);
478 SendData (txSocket,
"2001:0100::1");
495 txSocket->BindToNetDevice (net1.
Get (1));
503 Simulator::Destroy ();
void ReceivePkt(Ptr< Socket > socket)
virtual uint32_t AddInterface(Ptr< NetDevice > device)=0
Keep track of a set of IPv6 interfaces.
NetDeviceContainer Install(Ptr< Node > node) const
This method creates an ns3::SimpleChannel with the attributes configured by SimpleNetDeviceHelper::Se...
virtual void DoRun(void)
Implementation to actually run this TestCase.
Access to the IPv6 forwarding table, interfaces, and configuration.
virtual bool SetAllowBroadcast(bool allowBroadcast)=0
Configure whether broadcast datagram transmissions are allowed.
Ptr< NetDevice > Get(uint32_t i) const
Get the Ptr stored in this container at a given index.
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...
IPv6 address associated with an interface.
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 void DoRun(void)
Implementation to actually run this TestCase.
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
Ptr< Packet > m_receivedPacket2
a polymophic address class
void DoSendData(Ptr< Socket > socket, std::string to)
void SendData(Ptr< Socket > socket, std::string to)
void ReceivePkt(Ptr< Socket > socket)
void ReceivePacket2(Ptr< Socket > socket, Ptr< Packet > packet, const Address &from)
Ptr< Packet > m_receivedPacket
Ptr< Packet > m_receivedPacket
virtual void SetUp(uint32_t interface)=0
holds a vector of ns3::NetDevice pointers
An implementation of the ICMPv6 protocol.
void ReceivePacket(Ptr< Socket > socket, Ptr< Packet > packet, const Address &from)
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.
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 ReceivePkt2(Ptr< Socket > socket)
Access to the Ipv4 forwarding table, interfaces, and configuration.
void ReceivePkt2(Ptr< Socket > socket)
virtual int Bind(const Address &address)=0
Allocate a local endpoint for this socket.
keep track of a set of node pointers.
void DoSendData(Ptr< Socket > socket, std::string to)
virtual Ptr< Packet > Recv(uint32_t maxSize, uint32_t flags)=0
Read data from the socket.
void SetNetDevicePointToPointMode(bool pointToPointMode)
SimpleNetDevice is Broadcast capable and ARP needing.
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.
void ReceivePacket2(Ptr< Socket > socket, Ptr< Packet > packet, const Address &from)
void ReceivePkt(Ptr< Socket > socket)
Helper class to auto-assign global IPv6 unicast addresses.
UdpTestSuite g_udpTestSuite
Ptr< Packet > m_receivedPacket2
void SendData(Ptr< Socket > socket, std::string to)
Describes an IPv6 address.
Ipv4 addresses are stored in host order in this class.
uint32_t GetId(void) const
a class to store IPv4 address information on an interface
virtual Ptr< Node > GetNode(void) const =0
Return the node this socket is associated with.
void ReceivePkt(Ptr< Socket > socket)
Time Seconds(double value)
Construct a Time in the indicated unit.
void RemoveAllByteTags(void)
Remove all byte tags stored in this packet.
Ptr< Packet > m_receivedPacket
Ptr< Packet > m_receivedPacket
Describes an IPv6 prefix.
virtual bool AddAddress(uint32_t interface, Ipv4InterfaceAddress address)=0
virtual bool AddAddress(uint32_t interface, Ipv6InterfaceAddress address)=0
Add an address on the specified IPv6 interface.
virtual int SendTo(Ptr< Packet > p, uint32_t flags, const Address &toAddress)=0
Send data to a specified peer.
void ReceivePacket(Ptr< Socket > socket, Ptr< Packet > packet, const Address &from)
API to create UDP socket instances.
build a set of SimpleNetDevice objects
This test suite implements a Unit Test.
Ptr< T > GetObject(void) const
virtual void DoRun(void)
Implementation to actually run this TestCase.
virtual int32_t GetInterfaceForDevice(Ptr< const NetDevice > device) const =0
Get the interface index of the specified NetDevice.
void Dispose(void)
Run the DoDispose methods of this object and all the objects aggregated to it.
virtual void DoRun(void)
Implementation to actually run this TestCase.
virtual void SetUp(uint32_t interface)=0
Set the interface into the "up" state.
virtual uint32_t GetRxAvailable(void) const =0
Return number of bytes which can be returned from one or multiple calls to Recv.