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 ();
 
virtual uint32_t AddInterface(Ptr< NetDevice > device)=0
void ReceivePkt(Ptr< Socket > socket)
void DoSendData_IpHdr(Ptr< Socket > socket, std::string to)
void ReceivePacket2(Ptr< Socket > socket, Ptr< Packet > packet, const Address &from)
void DoSendData(Ptr< Socket > socket, std::string to)
a class to represent an Ipv4 address mask 
virtual void DoRun(void)
Implementation to actually run this TestCase. 
void ReceivePacket(Ptr< Socket > socket)
#define NS_ASSERT(condition)
uint32_t GetSize(void) const 
virtual Ptr< Socket > CreateSocket(void)=0
API to create RAW socket instances. 
a polymophic address class 
void ReceivePkt2(Ptr< Socket > socket)
virtual void SetUp(uint32_t interface)=0
#define NS_TEST_EXPECT_MSG_EQ(actual, limit, msg)
Test that an actual and expected (limit) value are equal and report if not. 
void SendData(Ptr< Socket > socket, std::string to)
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)
void AggregateObject(Ptr< Object > other)
Access to the Ipv4 forwarding table, interfaces, and configuration. 
virtual int Bind(const Address &address)=0
Allocate a local endpoint for this socket. 
virtual Ptr< Packet > Recv(uint32_t maxSize, uint32_t flags)=0
Read data from the socket. 
Ptr< Packet > m_receivedPacket
void AddTestCase(TestCase *testCase) NS_DEPRECATED
Add an individual child TestCase case to this TestCase. 
Ipv4RawTestSuite g_ipv4rawTestSuite
Ipv4 addresses are stored in host order in this class. 
void ReceivePacket(Ptr< Socket > socket, Ptr< Packet > packet, const Address &from)
void SendData_IpHdr(Ptr< Socket > socket, std::string to)
uint32_t AddDevice(Ptr< NetDevice > device)
uint32_t GetId(void) const 
a class to store IPv4 address information on an interface 
virtual Ptr< Node > GetNode(void) const =0
virtual void SetAddress(Address address)
void RemoveAllByteTags(void)
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. 
Ptr< Packet > m_receivedPacket2
static void AddInternetStack(Ptr< Node > node)
This test suite implements a Unit Test. 
void SetChannel(Ptr< SimpleChannel > channel)
void SetAttribute(std::string name, const AttributeValue &value)
Ptr< T > GetObject(void) const 
void AddHeader(const Header &header)
virtual uint32_t GetRxAvailable(void) const =0
void SetRoutingProtocol(Ptr< Ipv4RoutingProtocol > routingProtocol)
Register a new routing protocol to be used by this Ipv4 stack.