21 #include "ns3/socket-factory.h"
22 #include "ns3/tcp-socket-factory.h"
23 #include "ns3/simulator.h"
24 #include "ns3/simple-channel.h"
25 #include "ns3/simple-net-device.h"
26 #include "ns3/drop-tail-queue.h"
27 #include "ns3/config.h"
28 #include "ns3/ipv4-static-routing.h"
29 #include "ns3/ipv4-list-routing.h"
30 #include "ns3/ipv6-static-routing.h"
31 #include "ns3/ipv6-list-routing.h"
33 #include "ns3/inet-socket-address.h"
34 #include "ns3/inet6-socket-address.h"
35 #include "ns3/uinteger.h"
37 #include "ns3/tcp-socket-base.h"
39 #include "ns3/arp-l3-protocol.h"
40 #include "ns3/ipv4-l3-protocol.h"
41 #include "ns3/ipv6-l3-protocol.h"
42 #include "ns3/icmpv4-l4-protocol.h"
43 #include "ns3/icmpv6-l4-protocol.h"
44 #include "ns3/udp-l4-protocol.h"
45 #include "ns3/tcp-l4-protocol.h"
47 #include "ns3/private/tcp-option-ts.h"
67 virtual void DoRun (
void);
97 :
TestCase (
"Testing the TCP Timestamp option")
175 int sent = sock->
Send (p);
179 m_currentServerTxBytes += sent;
199 int sent = sock->
Send (p);
201 m_currentSourceTxBytes += sent;
238 ipv4->SetRoutingProtocol (ipv4Routing);
240 ipv4Routing->AddRoutingProtocol (ipv4staticRouting, 0);
261 uint32_t ndid = ipv4->AddInterface (dev);
263 ipv4->AddAddress (ndid, ipv4Addr);
271 const char* netmask =
"255.255.255.0";
272 const char* ipaddr0 =
"192.168.1.1";
273 const char* ipaddr1 =
"192.168.1.2";
280 dev0->SetChannel (channel);
281 dev1->SetChannel (channel);
286 Ptr<TcpSocketBase> server = DynamicCast<TcpSocketBase> (sockFactory0->CreateSocket ());
287 Ptr<TcpSocketBase> source = DynamicCast<TcpSocketBase> (sockFactory1->CreateSocket ());
295 server->SetAttribute (
"Timestamp",
BooleanValue (
false));
296 source->SetAttribute (
"Timestamp",
BooleanValue (
false));
300 server->SetAttribute (
"Timestamp",
BooleanValue (
false));
301 source->SetAttribute (
"Timestamp",
BooleanValue (
true));
305 server->SetAttribute (
"Timestamp",
BooleanValue (
true));
306 source->SetAttribute (
"Timestamp",
BooleanValue (
false));
310 server->SetAttribute (
"Timestamp",
BooleanValue (
true));
311 source->SetAttribute (
"Timestamp",
BooleanValue (
true));
315 uint16_t
port = 50000;
319 server->Bind (serverlocaladdr);
327 source->Connect (serverremoteaddr);
337 virtual void DoRun (
void);
static Ipv4Address GetAny(void)
AttributeValue implementation for Boolean.
void ServerHandleConnectionCreated(Ptr< Socket > s, const Address &addr)
static Time ElapsedTimeFromTsValue(uint32_t echoTime)
Estimate the Time elapsed from a TS echo value.
Ptr< T > GetObject(void) const
Get a pointer to the requested aggregated Object.
API to create TCP socket instances.
a class to represent an Ipv4 address mask
void AggregateObject(Ptr< Object > other)
Aggregate two Objects together.
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file...
static void Run(void)
Run the simulation.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Time MilliSeconds(uint64_t value)
Construct a Time in the indicated unit.
#define NS_TEST_EXPECT_MSG_EQ(actual, limit, msg)
Test that an actual and expected (limit) value are equal and report if not.
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
Callback< R > MakeNullCallback(void)
This test suite implements a Unit Test.
Ptr< Node > CreateInternetNode6(void)
ns3::TcpTimestampTestSuite g_tcpTimestampTestSuite
uint32_t m_currentSourceRxBytes
virtual enum Socket::SocketErrno GetErrno(void) const =0
Get last error number.
a polymophic address class
TimestampTestCase(TimestampTestCase::Configuration conf)
static Mac48Address Allocate(void)
Allocate a new Mac48Address.
static EventId Schedule(Time const &delay, MEM mem_ptr, OBJ obj)
Schedule an event to expire after delay.
void AddTestCase(TestCase *testCase, enum TestDuration duration)
Add an individual child TestCase to this test suite.
uint32_t m_serverReadSize
TimestampValueTestCase(double startTime, double timeToWait, std::string name)
Ptr< SimpleNetDevice > AddSimpleNetDevice(Ptr< Node > node, const char *ipaddr, const char *netmask)
void ServerHandleSend(Ptr< Socket > sock, uint32_t sendB)
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.
Configuration m_configuration
#define NS_TEST_ASSERT_MSG_EQ_TOL(actual, limit, tol, msg)
Test that actual and expected (limit) values are equal to plus or minus some tolerance and report and...
static void Destroy(void)
Execute the events scheduled with ScheduleDestroy().
void SourceHandleRecv(Ptr< Socket > sock)
static Mac48Address ConvertFrom(const Address &address)
Access to the Ipv4 forwarding table, interfaces, and configuration.
void SetupDefaultSim(void)
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.
Ptr< Node > CreateInternetNode(void)
void SourceHandleSend(Ptr< Socket > sock, uint32_t available)
void ServerHandleRecv(Ptr< Socket > sock)
uint32_t m_sourceReadSize
void SetSendCallback(Callback< void, Ptr< Socket >, uint32_t > sendCb)
Notify application when space in transmit buffer is added.
static uint32_t NowToTsValue()
Return an uint32_t value which represent "now".
uint32_t m_serverWriteSize
Describes an IPv6 address.
uint32_t m_currentSourceTxBytes
Ipv4 addresses are stored in host order in this class.
uint32_t m_currentServerRxBytes
uint32_t AddDevice(Ptr< NetDevice > device)
Associate a NetDevice to this node.
a class to store IPv4 address information on an interface
virtual void DoTeardown(void)
Implementation to do any local setup required for this TestCase.
Time Seconds(double value)
Construct a Time in the indicated unit.
uint32_t m_sourceWriteSize
virtual void DoTeardown(void)
Implementation to do any local setup required for this TestCase.
Ptr< SimpleNetDevice > AddSimpleNetDevice6(Ptr< Node > node, Ipv6Address ipaddr, Ipv6Prefix prefix)
Describes an IPv6 prefix.
virtual void DoRun(void)
Implementation to actually run this TestCase.
virtual int Send(Ptr< Packet > p, uint32_t flags)=0
Send data (or dummy data) to the remote host.
virtual int Close(void)=0
Close a socket.
virtual void DoRun(void)
Implementation to actually run this TestCase.
virtual uint32_t GetTxAvailable(void) const =0
Returns the number of bytes which can be sent in a single call to Send.
virtual uint32_t GetRxAvailable(void) const =0
Return number of bytes which can be returned from one or multiple calls to Recv.
uint32_t m_currentServerTxBytes