21#include "ns3/arp-l3-protocol.h"
22#include "ns3/boolean.h"
23#include "ns3/icmpv4-l4-protocol.h"
24#include "ns3/inet-socket-address.h"
25#include "ns3/internet-stack-helper.h"
26#include "ns3/ipv4-l3-protocol.h"
27#include "ns3/ipv4-list-routing.h"
28#include "ns3/ipv4-raw-socket-factory.h"
29#include "ns3/ipv4-static-routing.h"
32#include "ns3/simple-channel.h"
33#include "ns3/simple-net-device.h"
34#include "ns3/simulator.h"
35#include "ns3/socket-factory.h"
36#include "ns3/socket.h"
38#include "ns3/traffic-control-layer.h"
41#include "ns3/win32-internet.h"
43#include <netinet/in.h>
44#include <sys/socket.h>
90 void DoRun()
override;
126 "Received packet size is not equal to 2");
130 "Received packet size is not equal to Rx buffer size");
164 Simulator::ScheduleWithContext(socket->
GetNode()->
GetId(),
190 rxDev1 = CreateObject<SimpleNetDevice>();
191 rxDev1->SetAddress(Mac48Address::ConvertFrom(Mac48Address::Allocate()));
194 uint32_t netdev_idx = ipv4->AddInterface(rxDev1);
197 ipv4->AddAddress(netdev_idx, ipv4Addr);
198 ipv4->SetUp(netdev_idx);
206 txDev1 = CreateObject<SimpleNetDevice>();
207 txDev1->SetAddress(Mac48Address::ConvertFrom(Mac48Address::Allocate()));
210 uint32_t netdev_idx = ipv4->AddInterface(txDev1);
213 ipv4->AddAddress(netdev_idx, ipv4Addr);
214 ipv4->SetUp(netdev_idx);
219 rxDev1->SetChannel(channel1);
220 txDev1->SetChannel(channel1);
224 Ptr<Socket> rxSocket = rxSocketFactory->CreateSocket();
231 Ptr<Socket> txSocket = txSocketFactory->CreateSocket();
236 std::cout <<
"Dscp Test\n";
238 std::vector<Ipv4Header::DscpType> vDscpTypes;
239 vDscpTypes.push_back(Ipv4Header::DscpDefault);
240 vDscpTypes.push_back(Ipv4Header::DSCP_CS1);
241 vDscpTypes.push_back(Ipv4Header::DSCP_AF11);
242 vDscpTypes.push_back(Ipv4Header::DSCP_AF12);
243 vDscpTypes.push_back(Ipv4Header::DSCP_AF13);
244 vDscpTypes.push_back(Ipv4Header::DSCP_CS2);
245 vDscpTypes.push_back(Ipv4Header::DSCP_AF21);
246 vDscpTypes.push_back(Ipv4Header::DSCP_AF22);
247 vDscpTypes.push_back(Ipv4Header::DSCP_AF23);
248 vDscpTypes.push_back(Ipv4Header::DSCP_CS3);
249 vDscpTypes.push_back(Ipv4Header::DSCP_AF31);
250 vDscpTypes.push_back(Ipv4Header::DSCP_AF32);
251 vDscpTypes.push_back(Ipv4Header::DSCP_AF33);
252 vDscpTypes.push_back(Ipv4Header::DSCP_CS4);
253 vDscpTypes.push_back(Ipv4Header::DSCP_AF41);
254 vDscpTypes.push_back(Ipv4Header::DSCP_AF42);
255 vDscpTypes.push_back(Ipv4Header::DSCP_AF43);
256 vDscpTypes.push_back(Ipv4Header::DSCP_CS5);
257 vDscpTypes.push_back(Ipv4Header::DSCP_EF);
258 vDscpTypes.push_back(Ipv4Header::DSCP_CS6);
259 vDscpTypes.push_back(Ipv4Header::DSCP_CS7);
261 for (
uint32_t i = 0; i < vDscpTypes.size(); i++)
267 std::cout << std::endl;
273 std::cout <<
"Ecn Test\n";
274 std::vector<Ipv4Header::EcnType> vEcnTypes;
275 vEcnTypes.push_back(Ipv4Header::ECN_NotECT);
276 vEcnTypes.push_back(Ipv4Header::ECN_ECT1);
277 vEcnTypes.push_back(Ipv4Header::ECN_ECT0);
278 vEcnTypes.push_back(Ipv4Header::ECN_CE);
280 for (
uint32_t i = 0; i < vEcnTypes.size(); i++)
286 std::cout << std::endl;
291 Simulator::Destroy();
a polymophic address class
AttributeValue implementation for Boolean.
aggregate IP/TCP/UDP functionality to existing Nodes.
void Install(std::string nodeName) const
Aggregate implementations of the ns3::Ipv4, ns3::Ipv6, ns3::Udp, and ns3::Tcp classes onto the provid...
void SetIpv6StackInstall(bool enable)
Enable/disable IPv6 stack install.
Ipv4 addresses are stored in host order in this class.
Access to the IPv4 forwarding table, interfaces, and configuration.
a class to store IPv4 address information on an interface
a class to represent an Ipv4 address mask
API to create RAW socket instances.
uint32_t AddDevice(Ptr< NetDevice > device)
Associate a NetDevice to this node.
void SetAttribute(std::string name, const AttributeValue &value)
Set a single attribute, raising fatal errors if unsuccessful.
Ptr< T > GetObject() const
Get a pointer to the requested aggregated Object.
void AddHeader(const Header &header)
Add header to this packet.
uint32_t GetSize() const
Returns the the size in bytes of the packet (including the zero-filled initial payload).
void RemoveAllByteTags()
Remove all byte tags stored in this packet.
uint32_t PeekHeader(Header &header) const
Deserialize but does not remove the header from the internal buffer.
virtual uint32_t GetRxAvailable() const =0
Return number of bytes which can be returned from one or multiple calls to Recv.
virtual Ptr< Packet > Recv(uint32_t maxSize, uint32_t flags)=0
Read data from the socket.
virtual Ptr< Node > GetNode() const =0
Return the node this socket is associated with.
virtual int SendTo(Ptr< Packet > p, uint32_t flags, const Address &toAddress)=0
Send data to a specified peer.
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
@ UNIT
This test suite implements a Unit Test.
#define NS_TEST_ASSERT_MSG_EQ(actual, limit, msg)
Test that an actual and expected (limit) value are equal and report and abort if not.
#define NS_TEST_EXPECT_MSG_EQ(actual, limit, msg)
Test that an actual and expected (limit) value are equal and report if not.
Time Seconds(double value)
Construct a Time in the indicated unit.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Callback< R, Args... > MakeCallback(R(T::*memPtr)(Args...), OBJ objPtr)
Build Callbacks for class method members which take varying numbers of arguments and potentially retu...