Don't flood multicasts if no route found
This commit is contained in:
@@ -284,29 +284,29 @@ Ipv4L3Protocol::Lookup (
|
||||
NS_DEBUG ("Ipv4L3Protocol::Lookup (): "
|
||||
"Multicast destination with local source");
|
||||
//
|
||||
// We have a multicast packet originating from the current node. We didn't
|
||||
// want to force users to construct a route in order to get packets out of a
|
||||
// node, so there will have been no route found and it is left to us to send
|
||||
// the packet. What we'll do is to send the multicast out all of the
|
||||
// interfaces on this node. Note that we start with interface 1 since we
|
||||
// don't particularly want to send the packet out the loopback.
|
||||
// We have a multicast packet originating from the current node and were not
|
||||
// able to send it using the usual RequestRoute process. Since the usual
|
||||
// process includes trying to use a default multicast route, this means that
|
||||
// there was no specific route out of the node found, and there was no default
|
||||
// multicast route set.
|
||||
//
|
||||
NS_DEBUG ("Ipv4StaticRouting::Lookup (): "
|
||||
"Local source. Flooding multicast packet");
|
||||
// The fallback position is to look for a default unicast route and use that
|
||||
// to get the packet off the node if we have one.
|
||||
//
|
||||
Ipv4Route *route = m_staticRouting->GetDefaultRoute ();
|
||||
|
||||
for (uint32_t i = 1; i < GetNInterfaces (); ++i)
|
||||
if (route)
|
||||
{
|
||||
Packet p = packet;
|
||||
Ipv4Header h = ipHeader;
|
||||
Ipv4Route route =
|
||||
Ipv4Route::CreateHostRouteTo(h.GetDestination (), i);
|
||||
NS_DEBUG ("Ipv4StaticRouting::Lookup (): "
|
||||
"Send via interface " << i);
|
||||
routeReply (true, route, p, h);
|
||||
"Local source. Using unicast default route for multicast packet");
|
||||
|
||||
routeReply (true, *route, packet, ipHeader);
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
// No route found
|
||||
//
|
||||
// No route found
|
||||
//
|
||||
routeReply (false, Ipv4Route (), packet, ipHeader);
|
||||
}
|
||||
|
||||
|
||||
@@ -30,6 +30,7 @@ namespace ns3 {
|
||||
|
||||
Ipv4Route::Ipv4Route ()
|
||||
{}
|
||||
|
||||
Ipv4Route::Ipv4Route (Ipv4Route const &route)
|
||||
: m_dest (route.m_dest),
|
||||
m_destNetworkMask (route.m_destNetworkMask),
|
||||
@@ -37,6 +38,13 @@ Ipv4Route::Ipv4Route (Ipv4Route const &route)
|
||||
m_interface (route.m_interface)
|
||||
{}
|
||||
|
||||
Ipv4Route::Ipv4Route (Ipv4Route const *route)
|
||||
: m_dest (route->m_dest),
|
||||
m_destNetworkMask (route->m_destNetworkMask),
|
||||
m_gateway (route->m_gateway),
|
||||
m_interface (route->m_interface)
|
||||
{}
|
||||
|
||||
Ipv4Route::Ipv4Route (Ipv4Address dest,
|
||||
Ipv4Address gateway,
|
||||
uint32_t interface)
|
||||
@@ -236,6 +244,15 @@ Ipv4MulticastRoute::Ipv4MulticastRoute (Ipv4MulticastRoute const &route)
|
||||
{
|
||||
}
|
||||
|
||||
Ipv4MulticastRoute::Ipv4MulticastRoute (Ipv4MulticastRoute const *route)
|
||||
:
|
||||
m_origin (route->m_origin),
|
||||
m_group (route->m_group),
|
||||
m_inputInterface (route->m_inputInterface),
|
||||
m_outputInterfaces (route->m_outputInterfaces)
|
||||
{
|
||||
}
|
||||
|
||||
Ipv4MulticastRoute::Ipv4MulticastRoute (
|
||||
Ipv4Address origin,
|
||||
Ipv4Address group,
|
||||
|
||||
@@ -37,12 +37,19 @@ public:
|
||||
* \brief This constructor does nothing
|
||||
*/
|
||||
Ipv4Route ();
|
||||
|
||||
/**
|
||||
* \brief Copy Constructor
|
||||
* \param route The route to copy
|
||||
*/
|
||||
Ipv4Route (Ipv4Route const &route);
|
||||
|
||||
/**
|
||||
* \brief Copy Constructor
|
||||
* \param route The route to copy
|
||||
*/
|
||||
Ipv4Route (Ipv4Route const *route);
|
||||
|
||||
bool IsHost (void) const;
|
||||
/**
|
||||
* \return The IPv4 address of the destination of this route
|
||||
@@ -108,12 +115,19 @@ public:
|
||||
* \brief This constructor does nothing
|
||||
*/
|
||||
Ipv4MulticastRoute ();
|
||||
|
||||
/**
|
||||
* \brief Copy Constructor
|
||||
* \param route The route to copy
|
||||
*/
|
||||
Ipv4MulticastRoute (Ipv4MulticastRoute const &route);
|
||||
|
||||
/**
|
||||
* \brief Copy Constructor
|
||||
* \param route The route to copy
|
||||
*/
|
||||
Ipv4MulticastRoute (Ipv4MulticastRoute const *route);
|
||||
|
||||
/**
|
||||
* \return The IPv4 address of the source of this route
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user