Fix bug 1378 (UdpEchoClient::SetFill() does not set packet size correctly) (fix from jesse1013000@gmail.com)
This commit is contained in:
@@ -30,6 +30,7 @@ Bugs fixed
|
||||
- bug 1319 - Fix Ipv6RawSocketImpl Icmpv6 filter
|
||||
- bug 1318 - Asserts for IPv6 malformed packets
|
||||
- bug 1357 - IPv6 fragmentation fails due to checks about malformed extensions
|
||||
- bug 1378 - UdpEchoClient::SetFill () does not set packet size correctly
|
||||
|
||||
Known issues
|
||||
------------
|
||||
|
||||
@@ -236,6 +236,7 @@ UdpEchoClient::SetFill (uint8_t *fill, uint32_t fillSize, uint32_t dataSize)
|
||||
if (fillSize >= dataSize)
|
||||
{
|
||||
memcpy (m_data, fill, dataSize);
|
||||
m_size = dataSize;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
#include "ns3/internet-stack-helper.h"
|
||||
#include "ns3/ipv4-address-helper.h"
|
||||
#include "ns3/udp-client-server-helper.h"
|
||||
#include "ns3/udp-echo-helper.h"
|
||||
#include "ns3/simple-net-device.h"
|
||||
#include "ns3/simple-channel.h"
|
||||
#include "ns3/test.h"
|
||||
@@ -52,8 +53,8 @@ private:
|
||||
|
||||
};
|
||||
|
||||
UdpClientServerTestCase::UdpClientServerTestCase () :
|
||||
TestCase ("Test that all the udp packets generated by an udpClient application are correctly received by an udpServer application")
|
||||
UdpClientServerTestCase::UdpClientServerTestCase ()
|
||||
: TestCase ("Test that all the udp packets generated by an udpClient application are correctly received by an udpServer application")
|
||||
{
|
||||
}
|
||||
|
||||
@@ -126,8 +127,8 @@ private:
|
||||
|
||||
};
|
||||
|
||||
UdpTraceClientServerTestCase::UdpTraceClientServerTestCase () :
|
||||
TestCase ("Test that all the udp packets generated by an udpTraceClient application are correctly received by an udpServer application")
|
||||
UdpTraceClientServerTestCase::UdpTraceClientServerTestCase ()
|
||||
: TestCase ("Test that all the udp packets generated by an udpTraceClient application are correctly received by an udpServer application")
|
||||
{
|
||||
}
|
||||
|
||||
@@ -165,7 +166,7 @@ void UdpTraceClientServerTestCase::DoRun (void)
|
||||
apps.Start (Seconds (1.0));
|
||||
apps.Stop (Seconds (10.0));
|
||||
|
||||
uint32_t MaxPacketSize = 1400-28; // ip/udp header
|
||||
uint32_t MaxPacketSize = 1400 - 28; // ip/udp header
|
||||
UdpTraceClientHelper client (i.GetAddress (1), port,"");
|
||||
client.SetAttribute ("MaxPacketSize", UintegerValue (MaxPacketSize));
|
||||
apps = client.Install (n.Get (0));
|
||||
@@ -195,8 +196,8 @@ private:
|
||||
|
||||
};
|
||||
|
||||
PacketLossCounterTestCase::PacketLossCounterTestCase () :
|
||||
TestCase ("Test that all the PacketLossCounter class checks loss correctly in different cases")
|
||||
PacketLossCounterTestCase::PacketLossCounterTestCase ()
|
||||
: TestCase ("Test that all the PacketLossCounter class checks loss correctly in different cases")
|
||||
{
|
||||
}
|
||||
|
||||
@@ -208,20 +209,20 @@ void PacketLossCounterTestCase::DoRun (void)
|
||||
{
|
||||
PacketLossCounter lossCounter (32);
|
||||
lossCounter.NotifyReceived (32); //out of order
|
||||
for (uint32_t i=0; i<64; i++)
|
||||
for (uint32_t i = 0; i < 64; i++)
|
||||
{
|
||||
lossCounter.NotifyReceived (i);
|
||||
}
|
||||
|
||||
NS_TEST_ASSERT_MSG_EQ (lossCounter.GetLost (), 0, "Check that 0 packets are lost");
|
||||
|
||||
for (uint32_t i=65; i<128; i++) // drop (1) seqNum 64
|
||||
for (uint32_t i = 65; i < 128; i++) // drop (1) seqNum 64
|
||||
{
|
||||
lossCounter.NotifyReceived (i);
|
||||
}
|
||||
NS_TEST_ASSERT_MSG_EQ (lossCounter.GetLost (), 1, "Check that 1 packet is lost");
|
||||
|
||||
for (uint32_t i=134; i<200; i++) // drop seqNum 128,129,130,131,132,133
|
||||
for (uint32_t i = 134; i < 200; i++) // drop seqNum 128,129,130,131,132,133
|
||||
{
|
||||
lossCounter.NotifyReceived (i);
|
||||
}
|
||||
@@ -236,7 +237,7 @@ void PacketLossCounterTestCase::DoRun (void)
|
||||
lossCounter.NotifyReceived (202);
|
||||
lossCounter.NotifyReceived (203);
|
||||
lossCounter.NotifyReceived (204);
|
||||
for (uint32_t i=205; i<250; i++)
|
||||
for (uint32_t i = 205; i < 250; i++)
|
||||
{
|
||||
lossCounter.NotifyReceived (i);
|
||||
}
|
||||
@@ -248,24 +249,101 @@ void PacketLossCounterTestCase::DoRun (void)
|
||||
lossCounter.NotifyReceived (252);
|
||||
lossCounter.NotifyReceived (253);
|
||||
lossCounter.NotifyReceived (254);
|
||||
for (uint32_t i=256; i<300; i++)
|
||||
for (uint32_t i = 256; i < 300; i++)
|
||||
{
|
||||
lossCounter.NotifyReceived (i);
|
||||
}
|
||||
NS_TEST_ASSERT_MSG_EQ (lossCounter.GetLost (), 9, "Check that 9 (6+1+2) packet are lost");
|
||||
}
|
||||
|
||||
/**
|
||||
* Test fix for bug 1378
|
||||
*/
|
||||
|
||||
class UdpEchoClientSetFillTestCase : public TestCase
|
||||
{
|
||||
public:
|
||||
UdpEchoClientSetFillTestCase ();
|
||||
virtual ~UdpEchoClientSetFillTestCase ();
|
||||
|
||||
private:
|
||||
virtual void DoRun (void);
|
||||
|
||||
};
|
||||
|
||||
UdpEchoClientSetFillTestCase::UdpEchoClientSetFillTestCase ()
|
||||
: TestCase ("Test that the UdpEchoClient::SetFill class sets packet size (bug 1378)")
|
||||
{
|
||||
}
|
||||
|
||||
UdpEchoClientSetFillTestCase::~UdpEchoClientSetFillTestCase ()
|
||||
{
|
||||
}
|
||||
|
||||
void UdpEchoClientSetFillTestCase::DoRun (void)
|
||||
{
|
||||
NodeContainer nodes;
|
||||
nodes.Create (2);
|
||||
|
||||
InternetStackHelper internet;
|
||||
internet.Install (nodes);
|
||||
|
||||
Ptr<SimpleNetDevice> txDev = CreateObject<SimpleNetDevice> ();
|
||||
Ptr<SimpleNetDevice> rxDev = CreateObject<SimpleNetDevice> ();
|
||||
nodes.Get (0)->AddDevice (txDev);
|
||||
nodes.Get (1)->AddDevice (rxDev);
|
||||
Ptr<SimpleChannel> channel1 = CreateObject<SimpleChannel> ();
|
||||
rxDev->SetChannel (channel1);
|
||||
txDev->SetChannel (channel1);
|
||||
NetDeviceContainer d;
|
||||
d.Add (txDev);
|
||||
d.Add (rxDev);
|
||||
|
||||
Ipv4AddressHelper ipv4;
|
||||
|
||||
ipv4.SetBase ("10.1.1.0", "255.255.255.0");
|
||||
Ipv4InterfaceContainer interfaces = ipv4.Assign (d);
|
||||
|
||||
uint16_t port = 5000;
|
||||
UdpEchoServerHelper echoServer (port);
|
||||
ApplicationContainer serverApps = echoServer.Install (nodes.Get (1));
|
||||
serverApps.Start (Seconds (1.0));
|
||||
serverApps.Stop (Seconds (10.0));
|
||||
UdpEchoClientHelper echoClient (interfaces.GetAddress (1), port);
|
||||
echoClient.SetAttribute ("MaxPackets", UintegerValue (1));
|
||||
echoClient.SetAttribute ("Interval", TimeValue (Seconds (1.0)));
|
||||
echoClient.SetAttribute ("PacketSize", UintegerValue (1024));
|
||||
|
||||
ApplicationContainer clientApps = echoClient.Install (nodes.Get (0));
|
||||
|
||||
uint8_t arry[64];
|
||||
uint8_t i;
|
||||
for (i = 0; i < 64; i++)
|
||||
{
|
||||
arry[i] = i;
|
||||
}
|
||||
echoClient.SetFill (clientApps.Get (0), &(arry[0]), (uint32_t)64, (uint32_t)64);
|
||||
|
||||
clientApps.Start (Seconds (2.0));
|
||||
clientApps.Stop (Seconds (10.0));
|
||||
|
||||
Simulator::Run ();
|
||||
Simulator::Destroy ();
|
||||
}
|
||||
|
||||
class UdpClientServerTestSuite : public TestSuite
|
||||
{
|
||||
public:
|
||||
UdpClientServerTestSuite ();
|
||||
};
|
||||
|
||||
UdpClientServerTestSuite::UdpClientServerTestSuite () :
|
||||
TestSuite ("udp-client-server", UNIT)
|
||||
UdpClientServerTestSuite::UdpClientServerTestSuite ()
|
||||
: TestSuite ("udp-client-server", UNIT)
|
||||
{
|
||||
AddTestCase (new UdpTraceClientServerTestCase);
|
||||
AddTestCase (new UdpClientServerTestCase);
|
||||
AddTestCase (new PacketLossCounterTestCase);
|
||||
AddTestCase (new UdpEchoClientSetFillTestCase);
|
||||
}
|
||||
|
||||
static UdpClientServerTestSuite udpClientServerTestSuite;
|
||||
|
||||
Reference in New Issue
Block a user