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/socket.h"
32 #include "ns3/inet-socket-address.h"
33 #include "ns3/boolean.h"
35 #include "ns3/arp-l3-protocol.h"
36 #include "ns3/ipv4-l3-protocol.h"
37 #include "ns3/icmpv4-l4-protocol.h"
38 #include "ns3/ipv4-list-routing.h"
39 #include "ns3/ipv4-static-routing.h"
40 #include "ns3/traffic-control-layer.h"
41 #include "ns3/internet-stack-helper.h"
46 #include <netinet/in.h>
47 #include <sys/socket.h>
48 #include <sys/types.h>
83 virtual void DoRun (
void);
113 uint32_t availableData;
161 Ptr<Node> rxNode = CreateObject<Node> ();
166 rxDev1 = CreateObject<SimpleNetDevice> ();
167 rxDev1->SetAddress (Mac48Address::ConvertFrom (Mac48Address::Allocate ()));
170 uint32_t netdev_idx = ipv4->AddInterface (rxDev1);
172 ipv4->AddAddress (netdev_idx, ipv4Addr);
173 ipv4->SetUp (netdev_idx);
177 Ptr<Node> txNode = CreateObject<Node> ();
181 txDev1 = CreateObject<SimpleNetDevice> ();
182 txDev1->SetAddress (Mac48Address::ConvertFrom (Mac48Address::Allocate ()));
185 uint32_t netdev_idx = ipv4->AddInterface (txDev1);
187 ipv4->AddAddress (netdev_idx, ipv4Addr);
188 ipv4->SetUp (netdev_idx);
193 rxDev1->SetChannel (channel1);
194 txDev1->SetChannel (channel1);
199 Ptr<Socket> rxSocket = rxSocketFactory->CreateSocket ();
205 Ptr<Socket> txSocket = txSocketFactory->CreateSocket ();
210 std::cout <<
"Dscp Test\n";
212 std::vector <Ipv4Header::DscpType> vDscpTypes;
213 vDscpTypes.push_back (Ipv4Header::DscpDefault);
214 vDscpTypes.push_back (Ipv4Header::DSCP_CS1);
215 vDscpTypes.push_back (Ipv4Header::DSCP_AF11);
216 vDscpTypes.push_back (Ipv4Header::DSCP_AF12);
217 vDscpTypes.push_back (Ipv4Header::DSCP_AF13);
218 vDscpTypes.push_back (Ipv4Header::DSCP_CS2);
219 vDscpTypes.push_back (Ipv4Header::DSCP_AF21);
220 vDscpTypes.push_back (Ipv4Header::DSCP_AF22);
221 vDscpTypes.push_back (Ipv4Header::DSCP_AF23);
222 vDscpTypes.push_back (Ipv4Header::DSCP_CS3);
223 vDscpTypes.push_back (Ipv4Header::DSCP_AF31);
224 vDscpTypes.push_back (Ipv4Header::DSCP_AF32);
225 vDscpTypes.push_back (Ipv4Header::DSCP_AF33);
226 vDscpTypes.push_back (Ipv4Header::DSCP_CS4);
227 vDscpTypes.push_back (Ipv4Header::DSCP_AF41);
228 vDscpTypes.push_back (Ipv4Header::DSCP_AF42);
229 vDscpTypes.push_back (Ipv4Header::DSCP_AF43);
230 vDscpTypes.push_back (Ipv4Header::DSCP_CS5);
231 vDscpTypes.push_back (Ipv4Header::DSCP_EF);
232 vDscpTypes.push_back (Ipv4Header::DSCP_CS6);
233 vDscpTypes.push_back (Ipv4Header::DSCP_CS7);
235 for (uint32_t i = 0; i < vDscpTypes.size (); i++)
241 std::cout << std::endl;
247 std::cout <<
"Ecn Test\n";
248 std::vector <Ipv4Header::EcnType> vEcnTypes;
249 vEcnTypes.push_back (Ipv4Header::ECN_NotECT);
250 vEcnTypes.push_back (Ipv4Header::ECN_ECT1);
251 vEcnTypes.push_back (Ipv4Header::ECN_ECT0);
252 vEcnTypes.push_back (Ipv4Header::ECN_CE);
254 for (uint32_t i = 0; i < vEcnTypes.size (); i++)
260 std::cout << std::endl;
265 Simulator::Destroy ();
a polymophic address class
AttributeValue implementation for Boolean.
aggregate IP/TCP/UDP functionality to existing Nodes.
void Install(std::string nodeName) const
Aggregate implementations of the ns3::Ipv4, ns3::Ipv6, ns3::Udp, and ns3::Tcp classes onto the provid...
void SetIpv6StackInstall(bool enable)
Enable/disable IPv6 stack install.
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 GetId(void) const
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(void) const
Get a pointer to the requested aggregated Object.
void RemoveAllByteTags(void)
Remove all byte tags stored in this packet.
void AddHeader(const Header &header)
Add header to this packet.
uint32_t PeekHeader(Header &header) const
Deserialize but does not remove the header from the internal buffer.
uint32_t GetSize(void) const
Returns the the size in bytes of the packet (including the zero-filled initial payload).
virtual Ptr< Packet > Recv(uint32_t maxSize, uint32_t flags)=0
Read data from the socket.
virtual Ptr< Node > GetNode(void) const =0
Return the node this socket is associated with.
virtual uint32_t GetRxAvailable(void) const =0
Return number of bytes which can be returned from one or multiple calls to Recv.
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, Ts... > MakeCallback(R(T::*memPtr)(Ts...), OBJ objPtr)
Build Callbacks for class method members which take varying numbers of arguments and potentially retu...