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/simple-net-device-helper.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" 
   43 #include "ns3/internet-stack-helper.h" 
   47 #include <netinet/in.h> 
   48 #include <sys/socket.h> 
   49 #include <sys/types.h> 
   70   void DoSendData (
Ptr<Socket> socket, std::string to);
 
   82   void DoSendData_IpHdr (
Ptr<Socket> socket, std::string to);
 
   88   void SendData_IpHdr (
Ptr<Socket> socket, std::string to);
 
   91   virtual void DoRun (
void);
 
  122   : 
TestCase (
"IPv4 Raw socket implementation") 
 
  138   uint32_t availableData;
 
  143   NS_ASSERT (availableData == m_receivedPacket->GetSize ());
 
  148   uint32_t availableData;
 
  153   NS_ASSERT (availableData == m_receivedPacket2->GetSize ());
 
  182   ipHeader.SetDestination (
Ipv4Address (to.c_str ()));
 
  183   ipHeader.SetProtocol (0);
 
  184   ipHeader.SetPayloadSize (p->
GetSize ());
 
  185   ipHeader.SetTtl (255);
 
  209   Ptr<Node> rxNode = CreateObject<Node> ();
 
  211   Ptr<Node> txNode = CreateObject<Node> ();
 
  235   ipv4->
SetUp (netdev_idx);
 
  240   ipv4->
SetUp (netdev_idx);
 
  247   ipv4->
SetUp (netdev_idx);
 
  252   ipv4->
SetUp (netdev_idx);
 
  288   SendData (txSocket, 
"255.255.255.255");
 
  317   SendData (txSocket, 
"255.255.255.255");
 
  328   int err = txSocket->GetPeerName (peerAddress);
 
  330   NS_TEST_EXPECT_MSG_EQ (txSocket->GetErrno (), Socket::ERROR_NOTCONN, 
"socket error code should be ERROR_NOTCONN");
 
  333   err = txSocket->Connect (peer);
 
  336   err = txSocket->GetPeerName (peerAddress);
 
  339   NS_TEST_EXPECT_MSG_EQ (peerAddress, peer, 
"address from socket GetPeerName() should equal the connected address");
 
  341   Simulator::Destroy ();
 
void Dispose(void)
Dispose of this Object. 
 
virtual uint32_t AddInterface(Ptr< NetDevice > device)=0
 
void ReceivePkt(Ptr< Socket > socket)
Receive data. 
 
void DoSendData_IpHdr(Ptr< Socket > socket, std::string to)
Send data. 
 
AttributeValue implementation for Boolean. 
 
void ReceivePacket2(Ptr< Socket > socket, Ptr< Packet > packet, const Address &from)
Receive data. 
 
NetDeviceContainer Install(Ptr< Node > node) const 
This method creates an ns3::SimpleChannel with the attributes configured by SimpleNetDeviceHelper::Se...
 
Ptr< T > GetObject(void) const 
Get a pointer to the requested aggregated Object. 
 
Ptr< NetDevice > Get(uint32_t i) const 
Get the Ptr stored in this container at a given index. 
 
void DoSendData(Ptr< Socket > socket, std::string to)
Send data. 
 
a class to represent an Ipv4 address mask 
 
IPv4 RAW Socket TestSuite. 
 
virtual void DoRun(void)
Implementation to actually run this TestCase. 
 
void ReceivePacket(Ptr< Socket > socket)
 
#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. 
 
uint32_t GetSize(void) const 
Returns the the size in bytes of the packet (including the zero-filled initial payload). 
 
virtual Ptr< Socket > CreateSocket(void)=0
 
This test suite implements a Unit Test. 
 
API to create RAW socket instances. 
 
a polymophic address class 
 
void ReceivePkt2(Ptr< Socket > socket)
Receive data. 
 
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite. 
 
virtual void SetUp(uint32_t interface)=0
 
void SendData(Ptr< Socket > socket, std::string to)
Send data. 
 
static Ipv4RawTestSuite g_ipv4rawTestSuite
Static variable for test initialization. 
 
holds a vector of ns3::NetDevice pointers 
 
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)
This method wraps the creation of sockets that is performed on a given node by a SocketFactory specif...
 
Access to the IPv4 forwarding table, interfaces, and configuration. 
 
virtual int Bind(const Address &address)=0
Allocate a local endpoint for this socket. 
 
Every class exported by the ns3 library is enclosed in the ns3 namespace. 
 
keep track of a set of node pointers. 
 
virtual Ptr< Packet > Recv(uint32_t maxSize, uint32_t flags)=0
Read data from the socket. 
 
Ptr< Packet > m_receivedPacket
Received packet (1). 
 
void SetNetDevicePointToPointMode(bool pointToPointMode)
SimpleNetDevice is Broadcast capable and ARP needing. 
 
void Install(std::string nodeName) const 
Aggregate implementations of the ns3::Ipv4, ns3::Ipv6, ns3::Udp, and ns3::Tcp classes onto the provid...
 
Ipv4 addresses are stored in host order in this class. 
 
void ReceivePacket(Ptr< Socket > socket, Ptr< Packet > packet, const Address &from)
Receive data. 
 
void SendData_IpHdr(Ptr< Socket > socket, std::string to)
Send data. 
 
uint32_t GetId(void) const 
 
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. 
 
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. 
 
Ptr< Packet > m_receivedPacket2
Received packet (2). 
 
build a set of SimpleNetDevice objects 
 
void SetAttribute(std::string name, const AttributeValue &value)
Set a single attribute, raising fatal errors if unsuccessful. 
 
void AddHeader(const Header &header)
Add header to this packet. 
 
virtual uint32_t GetRxAvailable(void) const =0
Return number of bytes which can be returned from one or multiple calls to Recv.