|
A Discrete-Event Network Simulator
|
API
|
Go to the documentation of this file.
24 #include "ns3/random-variable-stream.h"
25 #include "ns3/tcp-rx-buffer.h"
44 static TypeId GetTypeId (
void);
73 void SetInvalidAwndCb (InvalidAwndCallback cb);
84 virtual uint16_t AdvertisedWindowSize (
bool scale =
true)
const;
87 uint16_t OldAdvertisedWindowSize (
bool scale =
true)
const;
103 m_inwalidAwndCb = cb;
109 static TypeId tid =
TypeId (
"ns3::TcpSocketAdvertisedWindowProxy")
111 .SetGroupName (
"Internet")
120 return CopyObject<TcpSocketAdvertisedWindowProxy> (
this);
129 uint16_t oldAwnd = OldAdvertisedWindowSize (scale);
131 if (!m_tcb->m_rxBuffer->Finished ())
135 if (newAwnd != oldAwnd)
137 uint32_t available = m_tcb->m_rxBuffer->Available ();
142 uint32_t newAwndKnownDifference = newAwnd;
145 newAwndKnownDifference += (available >> m_rcvWindShift);
149 newAwndKnownDifference += available;
152 if (newAwndKnownDifference > m_maxWinSize)
154 newAwndKnownDifference = m_maxWinSize;
157 if (
static_cast<uint16_t
> (newAwndKnownDifference) != oldAwnd)
159 if (!m_inwalidAwndCb.IsNull ())
161 m_inwalidAwndCb(oldAwnd, newAwnd);
189 uint32_t w = m_tcb->m_rxBuffer->MaxBufferSize ();
193 w >>= m_rcvWindShift;
195 if (w > m_maxWinSize)
198 NS_LOG_WARN (
"Adv window size truncated to " << m_maxWinSize <<
"; possibly to avoid overflow of the 16-bit integer");
200 NS_LOG_DEBUG (
"Returning AdvertisedWindowSize of " <<
static_cast<uint16_t
> (w));
201 return static_cast<uint16_t
> (w);
219 static TypeId GetTypeId (
void);
227 m_prng = CreateObject<UniformRandomVariable> ();
245 static TypeId tid =
TypeId (
"ns3::TcpDropRatioErrorModel")
255 return m_prng->GetValue () < m_dropRatio;
294 virtual void ConfigureEnvironment ();
303 void InvalidAwndCb (uint16_t oldAwnd, uint16_t newAwnd);
310 uint32_t size, uint32_t packets,
double lossRatio)
313 m_pktCount (packets),
314 m_lossRatio (lossRatio)
321 TcpGeneralTest::ConfigureEnvironment ();
335 DynamicCast<TcpSocketAdvertisedWindowProxy> (sock)->SetExpectedSegmentSize (500);
336 DynamicCast<TcpSocketAdvertisedWindowProxy> (sock)->SetInvalidAwndCb (
345 return CreateObject<TcpDropRatioErrorModel> (
m_lossRatio);
352 "Old and new AWND calculations do not match.");
372 std::vector<uint32_t> &toDrop);
392 uint32_t size, uint32_t packets,
393 std::vector<uint32_t> &toDrop)
396 m_pktCount (packets),
404 TcpGeneralTest::ConfigureEnvironment ();
417 DynamicCast<TcpSocketAdvertisedWindowProxy> (sock)->SetExpectedSegmentSize (500);
418 DynamicCast<TcpSocketAdvertisedWindowProxy> (sock)->SetInvalidAwndCb (
427 auto socket = TcpGeneralTest::CreateSenderSocket (node);
437 for (std::vector<uint32_t>::iterator it =
m_toDrop.begin (); it !=
m_toDrop.end (); ++it)
449 "Old and new AWND calculations do not match.");
478 std::vector<uint32_t> toDrop;
479 toDrop.push_back(8001);
480 toDrop.push_back(9001);
a unique identifier for an interface.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
virtual uint16_t AdvertisedWindowSize(bool scale=true) const
The amount of Rx window announced to the peer.
TcpSocketAdvertisedWindowProxy(const TcpSocketAdvertisedWindowProxy &other)
Copy-constructor.
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
Every class exported by the ns3 library is enclosed in the ns3 namespace.
bool IsNull(void) const
Check for null implementation.
void SetTransmitStart(Time startTime)
Set the initial time at which the application sends the first data packet.
virtual bool ShouldDrop(const Ipv4Header &ipHeader, const TcpHeader &tcpHeader, uint32_t packetSize)
Check if the packet should be dropped.
virtual Ptr< ErrorModel > CreateReceiverErrorModel()
Create and return the error model to install in the receiver node.
Callback< void, uint16_t, uint16_t > InvalidAwndCallback
typedef for a cb
void SetExpectedSegmentSize(uint16_t seg)
Set the expected segment size.
void SetAppPktCount(uint32_t pktCount)
Set app packet count.
static TypeId GetTypeId(void)
Get the type ID.
Test Suite for TCP adv window.
Class for inserting callbacks special points of the flow of TCP sockets.
virtual Ptr< TcpSocketMsgBase > CreateSocket(Ptr< Node > node, TypeId socketType, TypeId congControl)
Create a socket.
#define NS_LOG_WARN(msg)
Use NS_LOG to output a message of level LOG_WARN.
TcpAdvWindowOnLossTest(const std::string &desc, uint32_t size, uint32_t packets, std::vector< uint32_t > &toDrop)
Constructor.
virtual Ptr< TcpSocketMsgBase > CreateReceiverSocket(Ptr< Node > node)
Create and install the socket to install on the receiver.
virtual uint16_t AdvertisedWindowSize(bool scale=true) const
The amount of Rx window announced to the peer.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
virtual void ConfigureEnvironment()
Change the configuration of the environment.
uint32_t m_pktCount
Pkt count.
static TypeId GetTypeId(void)
Get the type ID.
TcpDropRatioErrorModel(double dropRatio)
Constructor.
void SetInvalidAwndCb(InvalidAwndCallback cb)
Set the invalid AdvWnd callback.
virtual Ptr< TcpSocketMsgBase > CreateReceiverSocket(Ptr< Node > node)
Create and install the socket to install on the receiver.
uint32_t m_pktCount
Pkt count.
Smart pointer class similar to boost::intrusive_ptr.
uint32_t m_pktSize
Packet size.
uint16_t OldAdvertisedWindowSize(bool scale=true) const
The legacy code used for calculating the advertised window.
void InvalidAwndCb(uint16_t oldAwnd, uint16_t newAwnd)
Callback called for the update of the awnd.
double m_dropRatio
Drop ratio.
TcpSocketAdvertisedWindowProxy()
Constructor.
virtual Ptr< TcpSocketBase > Fork()
Call CopyObject<> to clone me.
virtual void DoReset(void)
Re-initialize any state.
Test the TCP's advertised window size when there is a loss of specific packets.
Time MilliSeconds(uint64_t value)
Construct a Time in the indicated unit.
uint16_t m_segmentSize
Test meta-information: size of the segments that are received.
uint32_t m_pktSize
Packet size.
void InvalidAwndCb(uint16_t oldAwnd, uint16_t newAwnd)
Callback called for the update of the awnd.
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...
General infrastructure for TCP testing.
virtual Ptr< TcpSocketMsgBase > CreateSenderSocket(Ptr< Node > node)
Create and install the socket to install on the sender.
static TcpAdvertisedWindowTestSuite g_tcpAdvertisedWindowTestSuite
InvalidAwndCallback m_inwalidAwndCb
Callback.
#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.
static const uint32_t packetSize
virtual void ConfigureEnvironment()
Change the configuration of the environment.
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
@ UNIT
This test suite implements a Unit Test.
Time Seconds(double value)
Construct a Time in the indicated unit.
TypeId m_congControlTypeId
Congestion control.
std::vector< uint32_t > m_toDrop
Sequences to drop.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
void SetAppPktSize(uint32_t pktSize)
Set app packet size.
Hold an unsigned integer type.
Test the new formula for calculating TCP's advertised window size.
void AddSeqToKill(const SequenceNumber32 &seq)
Add the sequence number to the list of segments to be killed.
TcpAdvertisedWindowTestSuite()
A general (TCP-aware) error model.
Ptr< UniformRandomVariable > m_prng
Random variable.
An error model that randomly drops a given rĂ¡tio of TCP segments.
Socket that wraps every call to AdvertisedWindowSize ().
TcpAdvertisedWindowTest(const std::string &desc, uint32_t size, uint32_t packets, double lossRatio)
Constructor.
double m_lossRatio
Loss ratio.
void SetPropagationDelay(Time propDelay)
Propagation delay of the bottleneck link.
virtual Ptr< ErrorModel > CreateReceiverErrorModel()
Create and return the error model to install in the receiver node.