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" 32 #include "ns3/inet-socket-address.h" 34 #include "ns3/arp-l3-protocol.h" 35 #include "ns3/ipv4-l3-protocol.h" 36 #include "ns3/icmpv4-l4-protocol.h" 37 #include "ns3/udp-l4-protocol.h" 38 #include "ns3/ipv4-static-routing.h" 39 #include "ns3/internet-stack-helper.h" 40 #include "ns3/ipv4-routing-helper.h" 42 #include "ns3/traffic-control-layer.h" 65 void DoSendData (
Ptr<Socket> socket, std::string to);
74 virtual void DoRun (
void);
85 :
TestCase (
"UDP socket implementation")
91 uint32_t availableData;
120 Ptr<Node> rxNode = CreateObject<Node> ();
125 internet.Install (rxNode);
128 rxDev = CreateObject<SimpleNetDevice> ();
129 rxDev->
SetAddress (Mac48Address::ConvertFrom (Mac48Address::Allocate ()));
135 ipv4->
SetUp (netdev_idx);
139 Ptr<Node> fwNode = CreateObject<Node> ();
141 internet.Install (fwNode);
144 fwDev1 = CreateObject<SimpleNetDevice> ();
145 fwDev1->
SetAddress (Mac48Address::ConvertFrom (Mac48Address::Allocate ()));
151 ipv4->
SetUp (netdev_idx);
155 fwDev2 = CreateObject<SimpleNetDevice> ();
156 fwDev2->
SetAddress (Mac48Address::ConvertFrom (Mac48Address::Allocate ()));
162 ipv4->
SetUp (netdev_idx);
166 Ptr<Node> txNode = CreateObject<Node> ();
168 internet.Install (txNode);
171 txDev = CreateObject<SimpleNetDevice> ();
172 txDev->
SetAddress (Mac48Address::ConvertFrom (Mac48Address::Allocate ()));
178 ipv4->
SetUp (netdev_idx);
216 Simulator::Destroy ();
virtual uint32_t AddInterface(Ptr< NetDevice > device)=0
AttributeValue implementation for Boolean.
uint32_t GetId(void) const
void DoSendData(Ptr< Socket > socket, std::string to)
Send data.
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
Ptr< Packet > m_receivedPacket
Received packet.
#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
virtual void DoRun(void)
Implementation to actually run this TestCase.
a polymophic address class
void SendData(Ptr< Socket > socket, std::string to)
Send data.
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
virtual void SetUp(uint32_t interface)=0
static Ipv4ForwardingTestSuite g_ipv4forwardingTestSuite
Static variable for test initialization.
Callback< R > MakeCallback(R(T::*memPtr)(void), OBJ objPtr)
Ipv4ForwardingTestSuite()
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.
virtual Ptr< Packet > Recv(uint32_t maxSize, uint32_t flags)=0
Read data from the socket.
Ipv4 addresses are stored in host order in this class.
void ReceivePkt(Ptr< Socket > socket)
Receive data.
uint32_t AddDevice(Ptr< NetDevice > device)
Associate a NetDevice to this node.
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.
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 bool AddAddress(uint32_t interface, Ipv4InterfaceAddress address)=0
virtual int SendTo(Ptr< Packet > p, uint32_t flags, const Address &toAddress)=0
Send data to a specified peer.
IPv4 Forwarding TestSuite.
API to create UDP socket instances.
void SetChannel(Ptr< SimpleChannel > channel)
Attach a channel to this net device.
void SetAttribute(std::string name, const AttributeValue &value)
Set a single attribute, raising fatal errors if unsuccessful.
void SetIpv6StackInstall(bool enable)
Enable/disable IPv6 stack install.
virtual uint32_t GetRxAvailable(void) const =0
Return number of bytes which can be returned from one or multiple calls to Recv.