25 #include "ns3/socket-factory.h"
26 #include "ns3/ipv4-raw-socket-factory.h"
27 #include "ns3/simulator.h"
28 #include "ns3/simple-channel.h"
29 #include "ns3/simple-net-device.h"
30 #include "ns3/drop-tail-queue.h"
31 #include "ns3/socket.h"
35 #include "ns3/inet-socket-address.h"
36 #include "ns3/boolean.h"
38 #include "ns3/arp-l3-protocol.h"
39 #include "ns3/ipv4-l3-protocol.h"
40 #include "ns3/icmpv4-l4-protocol.h"
41 #include "ns3/ipv4-list-routing.h"
42 #include "ns3/ipv4-static-routing.h"
46 #include <netinet/in.h>
47 #include <sys/socket.h>
48 #include <sys/types.h>
64 ipv4Routing->AddRoutingProtocol (ipv4staticRouting, 0);
79 void DoSendData (
Ptr<Socket> socket, std::string to);
81 void DoSendData_IpHdr (
Ptr<Socket> socket, std::string to);
82 void SendData_IpHdr (
Ptr<Socket> socket, std::string to);
85 virtual void DoRun (
void);
96 :
TestCase (
"IPv4 Raw socket implementation")
112 uint32_t availableData;
117 NS_ASSERT (availableData == m_receivedPacket->GetSize ());
122 uint32_t availableData;
127 NS_ASSERT (availableData == m_receivedPacket2->GetSize ());
143 Simulator::ScheduleWithContext (socket->
GetNode ()->
GetId (), Seconds (0),
156 ipHeader.SetDestination (
Ipv4Address (to.c_str ()));
157 ipHeader.SetProtocol (0);
158 ipHeader.SetPayloadSize (p->
GetSize ());
159 ipHeader.SetTtl (255);
172 Simulator::ScheduleWithContext (socket->
GetNode ()->
GetId (), Seconds (0),
183 Ptr<Node> rxNode = CreateObject<Node> ();
187 rxDev1 = CreateObject<SimpleNetDevice> ();
188 rxDev1->
SetAddress (Mac48Address::ConvertFrom (Mac48Address::Allocate ()));
194 ipv4->
SetUp (netdev_idx);
198 rxDev2 = CreateObject<SimpleNetDevice> ();
199 rxDev2->
SetAddress (Mac48Address::ConvertFrom (Mac48Address::Allocate ()));
205 ipv4->
SetUp (netdev_idx);
209 Ptr<Node> txNode = CreateObject<Node> ();
213 txDev1 = CreateObject<SimpleNetDevice> ();
214 txDev1->
SetAddress (Mac48Address::ConvertFrom (Mac48Address::Allocate ()));
220 ipv4->
SetUp (netdev_idx);
224 txDev2 = CreateObject<SimpleNetDevice> ();
225 txDev2->
SetAddress (Mac48Address::ConvertFrom (Mac48Address::Allocate ()));
231 ipv4->
SetUp (netdev_idx);
278 SendData (txSocket,
"255.255.255.255");
307 SendData (txSocket,
"255.255.255.255");
315 Simulator::Destroy ();