20 #include "ns3/abort.h"
22 #include "ns3/pcap-file.h"
23 #include "ns3/config.h"
24 #include "ns3/string.h"
25 #include "ns3/uinteger.h"
26 #include "ns3/data-rate.h"
27 #include "ns3/inet-socket-address.h"
28 #include "ns3/point-to-point-helper.h"
29 #include "ns3/internet-stack-helper.h"
30 #include "ns3/ipv4-global-routing-helper.h"
31 #include "ns3/ipv4-address-helper.h"
32 #include "ns3/packet-sink-helper.h"
33 #include "ns3/tcp-socket-factory.h"
34 #include "ns3/traffic-control-helper.h"
35 #include "ns3/simulator.h"
36 #include "ns3/point-to-point-net-device.h"
37 #include "ns3/pointer.h"
38 #include "ns3/queue.h"
90 static TypeId GetTypeId (
void);
95 virtual void StartApplication (
void);
96 virtual void StopApplication (
void);
98 void ScheduleTx (
void);
134 .SetGroupName (
"Stats")
205 virtual void DoRun (
void);
216 void CwndChange (uint32_t oldCwnd, uint32_t newCwnd);
220 :
TestCase (
"Check to see that the ns-3 TCP congestion window works as expected against liblinux2.6.26.so"),
221 m_writeResults (false)
235 event.m_newCwnd = newCwnd;
239 NS_LOG_DEBUG (
"Cwnd change event " <<
m_responses.GetN () <<
" at " <<
Now ().As (Time::S) <<
" " << oldCwnd <<
" " << newCwnd);
281 std::string nscStack =
"liblinux2.6.26.so";
282 stack.SetTcp (
"ns3::NscTcpL4Protocol",
"Library",
StringValue (
"liblinux2.6.26.so"));
290 address.SetBase (
"10.1.1.0",
"255.255.255.252");
298 uint16_t sinkPort = 8080;
314 Ptr<Socket> ns3TcpSocket = Socket::CreateSocket (
nodes.Get (0), TcpSocketFactory::GetTypeId ());
322 app->Setup (ns3TcpSocket, sinkAddress, 1040, 10,
DataRate (
"5Mbps"));
323 nodes.Get (0)->AddApplication (app);
324 app->SetStartTime (
Seconds (1.));
325 app->SetStopTime (
Seconds (1.1));
349 Simulator::Destroy ();
363 const uint32_t MSS = 536;
364 const uint32_t N_EVENTS = 20;
371 for (uint32_t i = 1, from = MSS, to = MSS * 2; i < N_EVENTS; ++i, from += MSS, to += MSS)
401 virtual void DoRun (
void);
402 void VerifyCwndRun (uint32_t beginIdx, uint32_t endIdx, uint32_t initialCwnd, uint32_t mss);
413 void CwndChange (uint32_t oldCwnd, uint32_t newCwnd);
418 :
TestCase (
"Check to see that the ns-3 TCP congestion window works as expected for out-of-order packet delivery"),
419 m_writeResults (false)
433 event.m_newCwnd = newCwnd;
436 NS_LOG_DEBUG (
"Cwnd change event " <<
m_responses.GetN () <<
" at " <<
Now ().As (Time::S) <<
" " << oldCwnd <<
" " << newCwnd);
442 NS_LOG_DEBUG (
"Cwnd NOT INFLATED change event " <<
m_responses.GetN () <<
" at " <<
Now ().As (Time::S) <<
" " << oldCwnd <<
" " << newCwnd);
451 Packet::EnablePrinting ();
484 ipv4.
SetBase (
"10.1.3.0",
"255.255.255.0");
486 ipv4.
SetBase (
"10.1.2.0",
"255.255.255.0");
488 ipv4.
SetBase (
"10.1.1.0",
"255.255.255.0");
492 Ipv4GlobalRoutingHelper::PopulateRoutingTables ();
501 uint16_t servPort = 50000;
513 Ptr<Socket> ns3TcpSocket = Socket::CreateSocket (n0n1.
Get (0), TcpSocketFactory::GetTypeId ());
521 app->Setup (ns3TcpSocket, sinkAddress, 1040, 1000,
DataRate (
"1Mbps"));
523 app->SetStartTime (
Seconds (1.0));
524 app->SetStopTime (
Seconds (4.1));
534 Simulator::Stop (
Seconds (4.1));
536 Simulator::Destroy ();
552 const uint32_t MSS = 536;
553 const uint32_t N_EVENTS = 38;
590 uint32_t cwnd = 2412;
591 for (uint32_t i = 26; i < N_EVENTS; ++i)
593 double adder =
static_cast<double> (MSS * MSS) / cwnd;
595 cwnd +=
static_cast<uint32_t
> (adder);
599 for (uint32_t i = 0; i < N_EVENTS; ++i)
611 for(uint32_t i = beginIdx, to = initialCwnd; i < endIdx; ++i, to += mss)
void CwndChange(uint32_t oldCwnd, uint32_t newCwnd)
virtual void DoRun(void)
Implementation to actually run this TestCase.
virtual ~Ns3TcpCwndTestCase1()
TestVectors< CwndEvent > m_responses
virtual ~Ns3TcpCwndTestCase2()
void CwndChange(uint32_t oldCwnd, uint32_t newCwnd)
virtual void DoRun(void)
Implementation to actually run this TestCase.
TestVectors< CwndEvent > m_responses
void CwndChangeNotInflated(uint32_t oldCwnd, uint32_t newCwnd)
void VerifyCwndRun(uint32_t beginIdx, uint32_t endIdx, uint32_t initialCwnd, uint32_t mss)
static TypeId GetTypeId(void)
Register this type.
virtual void StartApplication(void)
Application specific startup code.
virtual void StopApplication(void)
Application specific shutdown code.
void Setup(Ptr< Socket > socket, Address address, uint32_t packetSize, uint32_t nPackets, DataRate dataRate)
a polymophic address class
holds a vector of ns3::Application pointers.
void Start(Time start)
Arrange for all of the Applications in this container to Start() at the Time given as a parameter.
void Stop(Time stop)
Arrange for all of the Applications in this container to Stop() at the Time given as a parameter.
The base class for all ns3 applications.
AttributeValue implementation for Boolean.
Class for representing data rates.
uint64_t GetBitRate() const
Get the underlying bitrate.
AttributeValue implementation for DataRate.
An identifier for simulation events.
bool IsRunning(void) const
This method is syntactic sugar for !IsExpired().
aggregate IP/TCP/UDP functionality to existing Nodes.
void InstallAll(void) const
Aggregate IPv4, IPv6, UDP, and TCP stacks to all nodes in the simulation.
A helper class to make life easier while doing simple IPv4 address assignment in scripts.
void SetBase(Ipv4Address network, Ipv4Mask mask, Ipv4Address base="0.0.0.1")
Set the base network number, network mask and base address.
Ipv4InterfaceContainer Assign(const NetDeviceContainer &c)
Assign IP addresses to the net devices specified in the container based on the current network prefix...
holds a vector of std::pair of Ptr<Ipv4> and interface index.
Ipv4Address GetAddress(uint32_t i, uint32_t j=0) const
holds a vector of ns3::NetDevice pointers
keep track of a set of node pointers.
void Create(uint32_t n)
Create n nodes and append pointers to them to the end of this NodeContainer.
void Add(NodeContainer other)
Append the contents of another NodeContainer to the end of this container.
Ptr< Node > Get(uint32_t i) const
Get the Ptr<Node> stored in this container at a given index.
uint32_t AddApplication(Ptr< Application > application)
Associate an Application to this Node.
bool TraceConnectWithoutContext(std::string name, const CallbackBase &cb)
Connect a TraceSource to a Callback without a context.
void SetAttribute(std::string name, const AttributeValue &value)
Set a single attribute, raising fatal errors if unsuccessful.
A helper to make it easier to instantiate an ns3::PacketSinkApplication on a set of nodes.
ApplicationContainer Install(NodeContainer c) const
Install an ns3::PacketSinkApplication on each node of the input container configured with all the att...
Build a set of PointToPointNetDevice objects.
void SetDeviceAttribute(std::string name, const AttributeValue &value)
Set an attribute value to be propagated to each NetDevice created by the helper.
void SetChannelAttribute(std::string name, const AttributeValue &value)
Set an attribute value to be propagated to each Channel created by the helper.
NetDeviceContainer Install(NodeContainer c)
Class for representing queue sizes.
virtual int Send(Ptr< Packet > p, uint32_t flags)=0
Send data (or dummy data) to the remote host.
virtual int Connect(const Address &address)=0
Initiate a connection to a remote host.
virtual int Close(void)=0
Close a socket.
virtual int Bind(const Address &address)=0
Allocate a local endpoint for this socket.
Hold variables of type string.
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
A simple way to store test vectors (for stimulus or from responses)
Simulation virtual time values and global simulation resolution.
AttributeValue implementation for Time.
Build a set of QueueDisc objects.
void Uninstall(NetDeviceContainer c)
a unique identifier for an interface.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Hold an unsigned integer type.
void SetDefault(std::string name, const AttributeValue &value)
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
@ PACKETS
Use number of packets for queue size.
Time Now(void)
create an ns3::Time instance which contains the current simulation time.
#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.
Time Seconds(double value)
Construct a Time in the indicated unit.
Time MilliSeconds(uint64_t 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...
Ns3TcpCwndTestSuite ns3TcpCwndTestSuite
static const uint32_t packetSize
void SendPacket(Ptr< NetDevice > sourceDevice, Address &destination)
This example (inspired from tv-trans-example) enables to generate the transmitted spectra of Wi-Fi st...