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>
50 #include <sys/types.h>
89 void DoRun()
override;
120 uint32_t availableData;
125 "Received packet size is not equal to 2");
129 "Received packet size is not equal to Rx buffer size");
163 Simulator::ScheduleWithContext(socket->
GetNode()->
GetId(),
180 internet.SetIpv6StackInstall(
false);
189 rxDev1 = CreateObject<SimpleNetDevice>();
190 rxDev1->SetAddress(Mac48Address::ConvertFrom(Mac48Address::Allocate()));
193 uint32_t netdev_idx =
ipv4->AddInterface(rxDev1);
196 ipv4->AddAddress(netdev_idx, ipv4Addr);
197 ipv4->SetUp(netdev_idx);
205 txDev1 = CreateObject<SimpleNetDevice>();
206 txDev1->SetAddress(Mac48Address::ConvertFrom(Mac48Address::Allocate()));
209 uint32_t netdev_idx =
ipv4->AddInterface(txDev1);
212 ipv4->AddAddress(netdev_idx, ipv4Addr);
213 ipv4->SetUp(netdev_idx);
218 rxDev1->SetChannel(channel1);
219 txDev1->SetChannel(channel1);
223 Ptr<Socket> rxSocket = rxSocketFactory->CreateSocket();
230 Ptr<Socket> txSocket = txSocketFactory->CreateSocket();
235 std::cout <<
"Dscp Test\n";
237 std::vector<Ipv4Header::DscpType> vDscpTypes;
238 vDscpTypes.push_back(Ipv4Header::DscpDefault);
239 vDscpTypes.push_back(Ipv4Header::DSCP_CS1);
240 vDscpTypes.push_back(Ipv4Header::DSCP_AF11);
241 vDscpTypes.push_back(Ipv4Header::DSCP_AF12);
242 vDscpTypes.push_back(Ipv4Header::DSCP_AF13);
243 vDscpTypes.push_back(Ipv4Header::DSCP_CS2);
244 vDscpTypes.push_back(Ipv4Header::DSCP_AF21);
245 vDscpTypes.push_back(Ipv4Header::DSCP_AF22);
246 vDscpTypes.push_back(Ipv4Header::DSCP_AF23);
247 vDscpTypes.push_back(Ipv4Header::DSCP_CS3);
248 vDscpTypes.push_back(Ipv4Header::DSCP_AF31);
249 vDscpTypes.push_back(Ipv4Header::DSCP_AF32);
250 vDscpTypes.push_back(Ipv4Header::DSCP_AF33);
251 vDscpTypes.push_back(Ipv4Header::DSCP_CS4);
252 vDscpTypes.push_back(Ipv4Header::DSCP_AF41);
253 vDscpTypes.push_back(Ipv4Header::DSCP_AF42);
254 vDscpTypes.push_back(Ipv4Header::DSCP_AF43);
255 vDscpTypes.push_back(Ipv4Header::DSCP_CS5);
256 vDscpTypes.push_back(Ipv4Header::DSCP_EF);
257 vDscpTypes.push_back(Ipv4Header::DSCP_CS6);
258 vDscpTypes.push_back(Ipv4Header::DSCP_CS7);
260 for (uint32_t i = 0; i < vDscpTypes.size(); i++)
266 std::cout << std::endl;
272 std::cout <<
"Ecn Test\n";
273 std::vector<Ipv4Header::EcnType> vEcnTypes;
274 vEcnTypes.push_back(Ipv4Header::ECN_NotECT);
275 vEcnTypes.push_back(Ipv4Header::ECN_ECT1);
276 vEcnTypes.push_back(Ipv4Header::ECN_ECT0);
277 vEcnTypes.push_back(Ipv4Header::ECN_CE);
279 for (uint32_t i = 0; i < vEcnTypes.size(); i++)
285 std::cout << std::endl;
290 Simulator::Destroy();
a polymophic address class
aggregate IP/TCP/UDP functionality to existing Nodes.
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.
void ReceivePacket(Ptr< Socket > socket)
#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...