diff --git a/RELEASE_NOTES b/RELEASE_NOTES index 8a8222b38..5eae49506 100644 --- a/RELEASE_NOTES +++ b/RELEASE_NOTES @@ -106,6 +106,7 @@ Bugs fixed - Bug 2741 - IPv4 fragmentation fails when last fragment have to be re-fragmented. - Bug 2744 - 802.11n/ac with RTS/CTS is crashing for a large number of nodes - Bug 2758 - IPv4 sockets bound to unicast receive also subnet-directed broadcasts +- Bug 2759 - Packets sent to broadcast address are converted to subnet-directed broadcast Known issues ------------ diff --git a/src/internet/model/udp-socket-impl.cc b/src/internet/model/udp-socket-impl.cc index c9c9d2944..ced2901c1 100644 --- a/src/internet/model/udp-socket-impl.cc +++ b/src/internet/model/udp-socket-impl.cc @@ -572,28 +572,11 @@ UdpSocketImpl::DoSendTo (Ptr p, Ipv4Address dest, uint16_t port, uint8_t if (ipv4->GetNetDevice (i) != m_boundnetdevice) continue; } - Ipv4Mask maski = iaddr.GetMask (); - if (maski == Ipv4Mask::GetOnes ()) - { - // if the network mask is 255.255.255.255, do not convert dest - NS_LOG_LOGIC ("Sending one copy from " << addri << " to " << dest - << " (mask is " << maski << ")"); - m_udp->Send (p->Copy (), addri, dest, - m_endPoint->GetLocalPort (), port); - NotifyDataSent (p->GetSize ()); - NotifySend (GetTxAvailable ()); - } - else - { - // Convert to subnet-directed broadcast - Ipv4Address bcast = addri.GetSubnetDirectedBroadcast (maski); - NS_LOG_LOGIC ("Sending one copy from " << addri << " to " << bcast - << " (mask is " << maski << ")"); - m_udp->Send (p->Copy (), addri, bcast, - m_endPoint->GetLocalPort (), port); - NotifyDataSent (p->GetSize ()); - NotifySend (GetTxAvailable ()); - } + NS_LOG_LOGIC ("Sending one copy from " << addri << " to " << dest); + m_udp->Send (p->Copy (), addri, dest, + m_endPoint->GetLocalPort (), port); + NotifyDataSent (p->GetSize ()); + NotifySend (GetTxAvailable ()); } NS_LOG_LOGIC ("Limited broadcast end."); return p->GetSize (); diff --git a/src/internet/test/udp-test.cc b/src/internet/test/udp-test.cc index 70765100a..1bec1b0e8 100644 --- a/src/internet/test/udp-test.cc +++ b/src/internet/test/udp-test.cc @@ -342,36 +342,37 @@ UdpSocketImplTest::DoRun (void) // Receiver Node ipv4 = rxNode->GetObject (); netdev_idx = ipv4->AddInterface (net1.Get (0)); - ipv4Addr = Ipv4InterfaceAddress (Ipv4Address ("10.0.0.1"), Ipv4Mask (0xffff0000U)); + ipv4Addr = Ipv4InterfaceAddress (Ipv4Address ("10.0.0.1"), Ipv4Mask ("/24")); ipv4->AddAddress (netdev_idx, ipv4Addr); ipv4->SetUp (netdev_idx); netdev_idx = ipv4->AddInterface (net2.Get (0)); - ipv4Addr = Ipv4InterfaceAddress (Ipv4Address ("10.0.1.1"), Ipv4Mask (0xffff0000U)); + ipv4Addr = Ipv4InterfaceAddress (Ipv4Address ("10.0.1.1"), Ipv4Mask ("/24")); ipv4->AddAddress (netdev_idx, ipv4Addr); ipv4->SetUp (netdev_idx); // Sender Node ipv4 = txNode->GetObject (); netdev_idx = ipv4->AddInterface (net1.Get (1)); - ipv4Addr = Ipv4InterfaceAddress (Ipv4Address ("10.0.0.2"), Ipv4Mask (0xffff0000U)); + ipv4Addr = Ipv4InterfaceAddress (Ipv4Address ("10.0.0.2"), Ipv4Mask ("/24")); ipv4->AddAddress (netdev_idx, ipv4Addr); ipv4->SetUp (netdev_idx); netdev_idx = ipv4->AddInterface (net2.Get (1)); - ipv4Addr = Ipv4InterfaceAddress (Ipv4Address ("10.0.1.2"), Ipv4Mask (0xffff0000U)); + ipv4Addr = Ipv4InterfaceAddress (Ipv4Address ("10.0.1.2"), Ipv4Mask ("/24")); ipv4->AddAddress (netdev_idx, ipv4Addr); ipv4->SetUp (netdev_idx); // Create the UDP sockets Ptr rxSocketFactory = rxNode->GetObject (); + Ptr rxSocket = rxSocketFactory->CreateSocket (); NS_TEST_EXPECT_MSG_EQ (rxSocket->Bind (InetSocketAddress (Ipv4Address ("10.0.0.1"), 1234)), 0, "trivial"); rxSocket->SetRecvCallback (MakeCallback (&UdpSocketImplTest::ReceivePkt, this)); Ptr rxSocket2 = rxSocketFactory->CreateSocket (); - rxSocket2->SetRecvCallback (MakeCallback (&UdpSocketImplTest::ReceivePkt2, this)); NS_TEST_EXPECT_MSG_EQ (rxSocket2->Bind (InetSocketAddress (Ipv4Address ("10.0.1.1"), 1234)), 0, "trivial"); + rxSocket2->SetRecvCallback (MakeCallback (&UdpSocketImplTest::ReceivePkt2, this)); Ptr txSocketFactory = txNode->GetObject (); Ptr txSocket = txSocketFactory->CreateSocket (); @@ -382,7 +383,7 @@ UdpSocketImplTest::DoRun (void) // Unicast test SendDataTo (txSocket, "10.0.0.1"); NS_TEST_EXPECT_MSG_EQ (m_receivedPacket->GetSize (), 123, "trivial"); - NS_TEST_EXPECT_MSG_EQ (m_receivedPacket2->GetSize (), 0, "second interface should receive it"); + NS_TEST_EXPECT_MSG_EQ (m_receivedPacket2->GetSize (), 0, "second interface should not receive it"); m_receivedPacket->RemoveAllByteTags (); m_receivedPacket2->RemoveAllByteTags (); @@ -390,7 +391,7 @@ UdpSocketImplTest::DoRun (void) // Simple broadcast test SendDataTo (txSocket, "255.255.255.255"); - NS_TEST_EXPECT_MSG_EQ (m_receivedPacket->GetSize (), 123, "trivial"); + NS_TEST_EXPECT_MSG_EQ (m_receivedPacket->GetSize (), 0, "first socket should not receive it (it is bound specifically to the first interface's address"); NS_TEST_EXPECT_MSG_EQ (m_receivedPacket2->GetSize (), 0, "second socket should not receive it (it is bound specifically to the second interface's address"); m_receivedPacket->RemoveAllByteTags (); @@ -407,7 +408,7 @@ UdpSocketImplTest::DoRun (void) NS_TEST_EXPECT_MSG_EQ (rxSocket2->Bind (InetSocketAddress (Ipv4Address ("0.0.0.0"), 1234)), 0, "trivial"); SendDataTo (txSocket, "255.255.255.255"); - NS_TEST_EXPECT_MSG_EQ (m_receivedPacket->GetSize (), 123, "trivial"); + NS_TEST_EXPECT_MSG_EQ (m_receivedPacket->GetSize (), 0, "first socket should not receive it (it is bound specifically to the first interface's address"); NS_TEST_EXPECT_MSG_EQ (m_receivedPacket2->GetSize (), 123, "trivial"); m_receivedPacket = 0; @@ -417,7 +418,7 @@ UdpSocketImplTest::DoRun (void) txSocket->BindToNetDevice (net1.Get (1)); SendDataTo (txSocket, "224.0.0.9"); - NS_TEST_EXPECT_MSG_EQ (m_receivedPacket->GetSize (), 0, "first socket should not receive it (it is bound specifically to the second interface's address"); + NS_TEST_EXPECT_MSG_EQ (m_receivedPacket->GetSize (), 0, "first socket should not receive it (it is bound specifically to the first interface's address"); NS_TEST_EXPECT_MSG_EQ (m_receivedPacket2->GetSize (), 123, "recv2: 224.0.0.9"); m_receivedPacket->RemoveAllByteTags ();