update testcase to deal with the return value of Socket::Send. Make sure udp packets are copied before going down the ip stack.

This commit is contained in:
Mathieu Lacage
2008-04-15 10:49:09 -07:00
parent 6fd8b6c572
commit 53be11fe6f

View File

@@ -305,7 +305,7 @@ UdpSocket::DoSendTo (Ptr<Packet> p, Ipv4Address dest, uint16_t port)
else if (ipv4->GetIfIndexForDestination(dest, localIfIndex))
{
NS_LOG_LOGIC ("Route exists");
m_udp->Send (p, ipv4->GetAddress (localIfIndex), dest,
m_udp->Send (p->Copy (), ipv4->GetAddress (localIfIndex), dest,
m_endPoint->GetLocalPort (), port);
NotifyDataSent (p->GetSize ());
return p->GetSize();;
@@ -479,7 +479,7 @@ UdpSocketTest::RunTests (void)
m_receivedPacket = Create<Packet> ();
m_receivedPacket2 = Create<Packet> ();
NS_TEST_ASSERT_EQUAL (txSocket->SendTo (InetSocketAddress (Ipv4Address("10.0.0.1"), 1234),
Create<Packet> (123)), 0);
Create<Packet> (123)), 123);
Simulator::Run ();
NS_TEST_ASSERT_EQUAL (m_receivedPacket->GetSize (), 123);
NS_TEST_ASSERT_EQUAL (m_receivedPacket2->GetSize (), 0); // second interface should receive it
@@ -490,7 +490,7 @@ UdpSocketTest::RunTests (void)
m_receivedPacket = Create<Packet> ();
m_receivedPacket2 = Create<Packet> ();
NS_TEST_ASSERT_EQUAL (txSocket->SendTo (InetSocketAddress (Ipv4Address("255.255.255.255"), 1234),
Create<Packet> (123)), 0);
Create<Packet> (123)), 123);
Simulator::Run ();
NS_TEST_ASSERT_EQUAL (m_receivedPacket->GetSize (), 123);
// second socket should not receive it (it is bound specifically to the second interface's address
@@ -510,7 +510,7 @@ UdpSocketTest::RunTests (void)
m_receivedPacket = Create<Packet> ();
m_receivedPacket2 = Create<Packet> ();
NS_TEST_ASSERT_EQUAL (txSocket->SendTo (InetSocketAddress (Ipv4Address("255.255.255.255"), 1234),
Create<Packet> (123)), 0);
Create<Packet> (123)), 123);
Simulator::Run ();
NS_TEST_ASSERT_EQUAL (m_receivedPacket->GetSize (), 123);
NS_TEST_ASSERT_EQUAL (m_receivedPacket2->GetSize (), 123);