tcp: ns3-tcp-loss updated
Before this patch, the test failed. The reason is in the following trace: Expected 49153 > 50000 [ACK] Seq=33001 Ack=1 Win=32768 received: 49153 > 50000 [ACK] Seq=33001 Ack=1 Win=32768 Expected 49153 > 50000 [ACK] Seq=34001 Ack=1 Win=32768 received: 49153 > 50000 [ACK] Seq=34001 Ack=1 Win=32768 Expected 49153 > 50000 [ACK] Seq=35001 Ack=1 Win=32768 received: 49153 > 50000 [ACK] Seq=15001 Ack=1 Win=32768 Expected 49153 > 50000 [ACK] Seq=15001 Ack=1 Win=32768 received: 49153 > 50000 [ACK] Seq=35001 Ack=1 Win=32768 Expected 49153 > 50000 [ACK] Seq=36001 Ack=1 Win=32768 received: 49153 > 50000 [ACK] Seq=36001 Ack=1 Win=32768 Expected 49153 > 50000 [ACK] Seq=37001 Ack=1 Win=32768 received: 49153 > 50000 [ACK] Seq=37001 Ack=1 Win=32768 The old implementation expected this sequences: 33001, 34001, 35001, 15001, while the new one expects 33001, 34001, 15001, 35001. Thanks to the SACK informations we can sent the (lost) 15001 one round before.
This commit is contained in:
@@ -69,7 +69,9 @@ class Ns3TcpLossTestCase : public TestCase
|
||||
public:
|
||||
Ns3TcpLossTestCase ();
|
||||
Ns3TcpLossTestCase (std::string tcpModel, uint32_t testCase);
|
||||
virtual ~Ns3TcpLossTestCase () {}
|
||||
virtual ~Ns3TcpLossTestCase ()
|
||||
{
|
||||
}
|
||||
|
||||
private:
|
||||
virtual void DoSetup (void);
|
||||
@@ -91,8 +93,8 @@ private:
|
||||
void Ipv4L3Tx (std::string context, Ptr<const Packet> packet, Ptr<Ipv4> ipv4, uint32_t interface);
|
||||
void CwndTracer (uint32_t oldval, uint32_t newval);
|
||||
void WriteUntilBufferFull (Ptr<Socket> localSocket, uint32_t txSpace);
|
||||
void StartFlow (Ptr<Socket> localSocket,
|
||||
Ipv4Address servAddress,
|
||||
void StartFlow (Ptr<Socket> localSocket,
|
||||
Ipv4Address servAddress,
|
||||
uint16_t servPort);
|
||||
|
||||
};
|
||||
@@ -132,16 +134,16 @@ Ns3TcpLossTestCase::DoSetup (void)
|
||||
//
|
||||
std::ostringstream oss;
|
||||
oss << "ns3tcp-loss-" << m_tcpModel << m_testCase << "-response-vectors.pcap";
|
||||
m_pcapFilename = CreateDataDirFilename(oss.str ());
|
||||
m_pcapFilename = CreateDataDirFilename (oss.str ());
|
||||
|
||||
if (m_writeVectors)
|
||||
{
|
||||
m_pcapFile.Open (m_pcapFilename, std::ios::out|std::ios::binary);
|
||||
m_pcapFile.Open (m_pcapFilename, std::ios::out | std::ios::binary);
|
||||
m_pcapFile.Init (PCAP_LINK_TYPE, PCAP_SNAPLEN);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_pcapFile.Open (m_pcapFilename, std::ios::in|std::ios::binary);
|
||||
m_pcapFile.Open (m_pcapFilename, std::ios::in | std::ios::binary);
|
||||
NS_ABORT_MSG_UNLESS (m_pcapFile.GetDataLinkType () == PCAP_LINK_TYPE,
|
||||
"Wrong response vectors in directory: opening " <<
|
||||
m_pcapFilename);
|
||||
@@ -161,9 +163,9 @@ Ns3TcpLossTestCase::Ipv4L3Tx (std::string context, Ptr<const Packet> packet, Ptr
|
||||
// We're not testing IP so remove and toss the header. In order to do this,
|
||||
// though, we need to copy the packet since we have a const version.
|
||||
//
|
||||
Ptr<Packet> p = packet->Copy ();
|
||||
Ptr<Packet> received = packet->Copy ();
|
||||
Ipv4Header ipHeader;
|
||||
p->RemoveHeader (ipHeader);
|
||||
received->RemoveHeader (ipHeader);
|
||||
|
||||
//
|
||||
// What is left is the TCP header and any data that may be sent. We aren't
|
||||
@@ -179,10 +181,9 @@ Ns3TcpLossTestCase::Ipv4L3Tx (std::string context, Ptr<const Packet> packet, Ptr
|
||||
int64_t tMicroSeconds = tNow.GetMicroSeconds ();
|
||||
|
||||
|
||||
m_pcapFile.Write (uint32_t (tMicroSeconds / 1000000),
|
||||
uint32_t (tMicroSeconds % 1000000),
|
||||
p
|
||||
);
|
||||
m_pcapFile.Write (uint32_t (tMicroSeconds / 1000000),
|
||||
uint32_t (tMicroSeconds % 1000000),
|
||||
received);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -190,16 +191,24 @@ Ns3TcpLossTestCase::Ipv4L3Tx (std::string context, Ptr<const Packet> packet, Ptr
|
||||
// Read the TCP under test expected response from the expected vector
|
||||
// file and see if it still does the right thing.
|
||||
//
|
||||
uint8_t expected[PCAP_SNAPLEN];
|
||||
uint8_t expectedBuffer[PCAP_SNAPLEN];
|
||||
uint32_t tsSec, tsUsec, inclLen, origLen, readLen;
|
||||
m_pcapFile.Read (expected, sizeof(expected), tsSec, tsUsec, inclLen, origLen, readLen);
|
||||
m_pcapFile.Read (expectedBuffer, sizeof(expectedBuffer), tsSec, tsUsec, inclLen, origLen, readLen);
|
||||
|
||||
NS_LOG_DEBUG ("read " << readLen);
|
||||
NS_LOG_INFO ("read " << readLen << " bytes");
|
||||
|
||||
uint8_t *actual = new uint8_t[readLen];
|
||||
p->CopyData (actual, readLen);
|
||||
received->CopyData (actual, readLen);
|
||||
|
||||
int result = memcmp (actual, expected, readLen);
|
||||
int result = memcmp (actual, expectedBuffer, readLen);
|
||||
|
||||
TcpHeader expectedHeader, receivedHeader;
|
||||
Ptr<Packet> expected = Create<Packet> (expectedBuffer, readLen);
|
||||
|
||||
expected->RemoveHeader (expectedHeader);
|
||||
received->RemoveHeader (receivedHeader);
|
||||
|
||||
NS_LOG_DEBUG ("Expected " << expectedHeader << " received: " << receivedHeader);
|
||||
|
||||
delete [] actual;
|
||||
|
||||
@@ -218,7 +227,7 @@ Ns3TcpLossTestCase::CwndTracer (uint32_t oldval, uint32_t newval)
|
||||
{
|
||||
if (m_writeLogging)
|
||||
{
|
||||
*(m_osw->GetStream ()) << "Moving cwnd from " << oldval << " to " << newval
|
||||
*(m_osw->GetStream ()) << "Moving cwnd from " << oldval << " to " << newval
|
||||
<< " at time " << Simulator::Now ().GetSeconds ()
|
||||
<< " seconds" << std::endl;
|
||||
}
|
||||
@@ -226,7 +235,7 @@ Ns3TcpLossTestCase::CwndTracer (uint32_t oldval, uint32_t newval)
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Implementing an "application" to send bytes over a TCP connection
|
||||
void
|
||||
void
|
||||
Ns3TcpLossTestCase::WriteUntilBufferFull (Ptr<Socket> localSocket, uint32_t txSpace)
|
||||
{
|
||||
while (m_currentTxBytes < m_totalTxBytes)
|
||||
@@ -240,10 +249,10 @@ Ns3TcpLossTestCase::WriteUntilBufferFull (Ptr<Socket> localSocket, uint32_t txSp
|
||||
if (txAvail == 0)
|
||||
{
|
||||
return;
|
||||
};
|
||||
}
|
||||
if (m_writeLogging)
|
||||
{
|
||||
std::clog << "Submitting " << toWrite
|
||||
std::clog << "Submitting " << toWrite
|
||||
<< " bytes to TCP socket" << std::endl;
|
||||
}
|
||||
int amountSent = localSocket->Send (0, toWrite, 0);
|
||||
@@ -254,7 +263,7 @@ Ns3TcpLossTestCase::WriteUntilBufferFull (Ptr<Socket> localSocket, uint32_t txSp
|
||||
{
|
||||
if (m_writeLogging)
|
||||
{
|
||||
std::clog << "Close socket at "
|
||||
std::clog << "Close socket at "
|
||||
<< Simulator::Now ().GetSeconds () << std::endl;
|
||||
}
|
||||
localSocket->Close ();
|
||||
@@ -262,14 +271,14 @@ Ns3TcpLossTestCase::WriteUntilBufferFull (Ptr<Socket> localSocket, uint32_t txSp
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
void
|
||||
Ns3TcpLossTestCase::StartFlow (Ptr<Socket> localSocket,
|
||||
Ipv4Address servAddress,
|
||||
uint16_t servPort)
|
||||
{
|
||||
if (m_writeLogging)
|
||||
{
|
||||
std::clog << "Starting flow at time "
|
||||
std::clog << "Starting flow at time "
|
||||
<< Simulator::Now ().GetSeconds () << std::endl;
|
||||
}
|
||||
localSocket->Connect (InetSocketAddress (servAddress, servPort)); // connect
|
||||
@@ -291,21 +300,23 @@ Ns3TcpLossTestCase::DoRun (void)
|
||||
// s1-----------------r1-----------------k1
|
||||
//
|
||||
// Example corresponding to simulations in the paper "Simulation-based
|
||||
// Comparisons of Tahoe, Reno, and SACK TCP
|
||||
// Comparisons of Tahoe, Reno, and SACK TCP
|
||||
|
||||
Config::SetDefault ("ns3::TcpSocketBase::Sack", BooleanValue (false));
|
||||
|
||||
std::ostringstream tcpModel;
|
||||
tcpModel << "ns3::Tcp" << m_tcpModel;
|
||||
if (m_tcpModel.compare("WestwoodPlus") == 0)
|
||||
if (m_tcpModel.compare ("WestwoodPlus") == 0)
|
||||
{
|
||||
Config::SetDefault("ns3::TcpL4Protocol::SocketType",
|
||||
TypeIdValue (TcpWestwood::GetTypeId()));
|
||||
Config::SetDefault("ns3::TcpWestwood::ProtocolType",
|
||||
EnumValue(TcpWestwood::WESTWOODPLUS));
|
||||
Config::SetDefault ("ns3::TcpL4Protocol::SocketType",
|
||||
TypeIdValue (TcpWestwood::GetTypeId ()));
|
||||
Config::SetDefault ("ns3::TcpWestwood::ProtocolType",
|
||||
EnumValue (TcpWestwood::WESTWOODPLUS));
|
||||
}
|
||||
else
|
||||
{
|
||||
Config::SetDefault ("ns3::TcpL4Protocol::SocketType",
|
||||
StringValue (tcpModel.str ()));
|
||||
Config::SetDefault ("ns3::TcpL4Protocol::SocketType",
|
||||
StringValue (tcpModel.str ()));
|
||||
}
|
||||
|
||||
Config::SetDefault ("ns3::TcpSocket::SegmentSize", UintegerValue (1000));
|
||||
@@ -374,10 +385,10 @@ Ns3TcpLossTestCase::DoRun (void)
|
||||
// registering callbacks in function StarFlow().
|
||||
Ptr<Socket> localSocket = Socket::CreateSocket (s1r1.Get (0), TcpSocketFactory::GetTypeId ());
|
||||
localSocket->Bind ();
|
||||
Simulator::ScheduleNow (&Ns3TcpLossTestCase::StartFlow,
|
||||
this,
|
||||
localSocket,
|
||||
ipInterfs.GetAddress (1),
|
||||
Simulator::ScheduleNow (&Ns3TcpLossTestCase::StartFlow,
|
||||
this,
|
||||
localSocket,
|
||||
ipInterfs.GetAddress (1),
|
||||
servPort);
|
||||
|
||||
Config::Connect ("/NodeList/0/$ns3::Ipv4L3Protocol/Tx",
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user