23 #include "ns3/socket-factory.h" 
   24 #include "ns3/ipv4-raw-socket-factory.h" 
   25 #include "ns3/simulator.h" 
   26 #include "ns3/simple-channel.h" 
   27 #include "ns3/simple-net-device.h" 
   28 #include "ns3/drop-tail-queue.h" 
   29 #include "ns3/socket.h" 
   33 #include "ns3/inet-socket-address.h" 
   34 #include "ns3/boolean.h" 
   36 #include "ns3/arp-l3-protocol.h" 
   37 #include "ns3/ipv4-l3-protocol.h" 
   38 #include "ns3/icmpv4-l4-protocol.h" 
   39 #include "ns3/ipv4-list-routing.h" 
   40 #include "ns3/ipv4-static-routing.h" 
   45 #include <netinet/in.h> 
   46 #include <sys/socket.h> 
   47 #include <sys/types.h> 
   63   ipv4Routing->AddRoutingProtocol (ipv4staticRouting, 0);
 
   82   virtual void DoRun (
void);
 
  103   uint32_t availableData;
 
  108   NS_ASSERT (availableData == m_receivedPacket->GetSize ());
 
  122   ipHeader.SetDestination (
Ipv4Address (to.c_str ()));
 
  123   ipHeader.SetProtocol (0);
 
  124   ipHeader.SetPayloadSize (p->
GetSize ());
 
  125   ipHeader.SetTtl (255);
 
  126   ipHeader.SetDscp (dscp);
 
  127   ipHeader.SetEcn (ecn);
 
  150   Ptr<Node> rxNode = CreateObject<Node> ();
 
  154     rxDev1 = CreateObject<SimpleNetDevice> ();
 
  155     rxDev1->
SetAddress (Mac48Address::ConvertFrom (Mac48Address::Allocate ()));
 
  161     ipv4->
SetUp (netdev_idx);
 
  166   Ptr<Node> txNode = CreateObject<Node> ();
 
  170     txDev1 = CreateObject<SimpleNetDevice> ();
 
  171     txDev1->
SetAddress (Mac48Address::ConvertFrom (Mac48Address::Allocate ()));
 
  177     ipv4->
SetUp (netdev_idx);
 
  199   std::cout << 
"Dscp Test\n";
 
  201   std::vector <Ipv4Header::DscpType> vDscpTypes;
 
  202   vDscpTypes.push_back (Ipv4Header::DscpDefault);
 
  203   vDscpTypes.push_back (Ipv4Header::DSCP_CS1);
 
  204   vDscpTypes.push_back (Ipv4Header::DSCP_AF11);
 
  205   vDscpTypes.push_back (Ipv4Header::DSCP_AF12);
 
  206   vDscpTypes.push_back (Ipv4Header::DSCP_AF13);
 
  207   vDscpTypes.push_back (Ipv4Header::DSCP_CS2);
 
  208   vDscpTypes.push_back (Ipv4Header::DSCP_AF21);
 
  209   vDscpTypes.push_back (Ipv4Header::DSCP_AF22);
 
  210   vDscpTypes.push_back (Ipv4Header::DSCP_AF23);
 
  211   vDscpTypes.push_back (Ipv4Header::DSCP_CS3);
 
  212   vDscpTypes.push_back (Ipv4Header::DSCP_AF31);
 
  213   vDscpTypes.push_back (Ipv4Header::DSCP_AF32);
 
  214   vDscpTypes.push_back (Ipv4Header::DSCP_AF33);
 
  215   vDscpTypes.push_back (Ipv4Header::DSCP_CS4);
 
  216   vDscpTypes.push_back (Ipv4Header::DSCP_AF41);
 
  217   vDscpTypes.push_back (Ipv4Header::DSCP_AF42);
 
  218   vDscpTypes.push_back (Ipv4Header::DSCP_AF43);
 
  219   vDscpTypes.push_back (Ipv4Header::DSCP_CS5);
 
  220   vDscpTypes.push_back (Ipv4Header::DSCP_EF);
 
  221   vDscpTypes.push_back (Ipv4Header::DSCP_CS6);
 
  222   vDscpTypes.push_back (Ipv4Header::DSCP_CS7);
 
  224   for (uint32_t i = 0; i < vDscpTypes.size (); i++)
 
  230       std::cout << std::endl;
 
  236   std::cout << 
"Ecn Test\n";
 
  237   std::vector <Ipv4Header::EcnType> vEcnTypes;
 
  238   vEcnTypes.push_back (Ipv4Header::ECN_NotECT);
 
  239   vEcnTypes.push_back (Ipv4Header::ECN_ECT1);
 
  240   vEcnTypes.push_back (Ipv4Header::ECN_ECT0);
 
  241   vEcnTypes.push_back (Ipv4Header::ECN_CE);
 
  243   for (uint32_t i = 0; i < vEcnTypes.size (); i++)
 
  249       std::cout << std::endl;
 
  256   Simulator::Destroy ();
 
virtual uint32_t AddInterface(Ptr< NetDevice > device)=0
 
AttributeValue implementation for Boolean. 
 
Ptr< T > GetObject(void) const 
Get a pointer to the requested aggregated Object. 
 
a class to represent an Ipv4 address mask 
 
void AggregateObject(Ptr< Object > other)
Aggregate two Objects together. 
 
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...
 
#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 AddTestCase(TestCase *testCase, enum TestDuration duration)
Add an individual child TestCase to this test suite. 
 
virtual void SetUp(uint32_t interface)=0
 
Callback< R > MakeCallback(R(T::*memPtr)(void), OBJ objPtr)
 
Access to the Ipv4 forwarding table, interfaces, and configuration. 
 
Every class exported by the ns3 library is enclosed in the ns3 namespace. 
 
virtual Ptr< Packet > Recv(uint32_t maxSize, uint32_t flags)=0
Read data from the socket. 
 
Ipv4 addresses are stored in host order in this class. 
 
uint32_t AddDevice(Ptr< NetDevice > device)
Associate a NetDevice to this node. 
 
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. 
 
virtual void SetAddress(Address address)
Set the address of this interface. 
 
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. 
 
void SetChannel(Ptr< SimpleChannel > channel)
Attach a channel to this net device. 
 
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. 
 
void SetRoutingProtocol(Ptr< Ipv4RoutingProtocol > routingProtocol)
Register a new routing protocol to be used by this Ipv4 stack.