Routing Protocol UnicastCallback forwarding issue

25 views
Skip to first unread message

Ubaid ur Rahman

unread,
Jan 14, 2016, 10:35:14 AM1/14/16
to ns-3-users
Hello,

Regarding my earlier topic, to which no one respond to... I figured I didn't explained it much. So I am creating a new topic with complete explanation of my issue. I am attaching the PDF which describes what topology I have, and the communication pattern. The image file attachment shows log.

in log, if you see the part

Unicast destination- looking up global route
FatTreeIpv4RoutingProtocol:LookupGlobal(0x9bc2530, 10.5.2.9, 0)
Looking for route for destination 10.5.2.9
---------------------------------
At Node: 54
Forwarding packet for:     10.5.2.9
To next hop with dest    10.0.5.0
 
Destination Network 10.0.5.0
Ouput Port:         6
---------------------------------
From lookup 0x9d026a8
Found unicast destination- calling unicast callback

This confirms that I am getting a route, but then

FatTreeIpv4RoutingProtocol:RouteInput(0x9c36718, 0x9cf4cc8, tos 0x0 DSCP Default ECN Not-ECT ttl 63 id 0 protocol 17 offset (bytes) 0 flags [none] length: 1052 10.0.0.1 > 10.5.2.9, 10.0.0.1, 10.5.2.9, 0x9c3b790, 0xbfc12464, 0xbfc12494)
Address 127.0.0.1 not a match
Address 10.0.5.2 not a match
Address 10.0.5.6 not a match
Address 10.0.5.10 not a match
Unicast destination- looking up global route
FatTreeIpv4RoutingProtocol:LookupGlobal(0x9c36718, 10.5.2.9, 0)
Looking for route for destination 10.5.2.9
Did not find unicast destination- returning false

Why?? Now am I understanding the protocol RouteInput wrong or what??
issue.png
routing issue explanation.pdf

Ubaid ur Rahman

unread,
Jan 14, 2016, 11:04:12 AM1/14/16
to ns-3-users
Further drilling down I found that the first time the suffix list contains list of table entries but the second time when the callback runs there is no entry in the list. I am using the following code:

if (allRoutes.size() == 0)
       
{
           
for (SuffixRoutesI i = m_suffixRoutes.begin();
                    i
!= m_suffixRoutes.end(); i++)
           
{
                allRoutes
.push_back(*i);
           
}
       
}

Tommaso Pecorella

unread,
Jan 14, 2016, 11:54:23 AM1/14/16
to ns-3-users
Hi,

no idea of the solution, but there's something strange for sure: a node shouldn't have an address like "To next hop with dest    10.0.5.0".
No node should be ".0". Perhaps that's a part of the problem ?

Cheers,

T.

Ubaid ur Rahman

unread,
Jan 14, 2016, 12:47:07 PM1/14/16
to ns-3-users
Hello,

Thank you for your reply. That is what I get from route->GetDest(); I am pasting both functions below, may be that will help

Ptr<Ipv4Route>
FatTreeIpv4RoutingProtocol::LookupGlobal (Ipv4Address dest, Ptr<NetDevice> oif)
{

  NS_LOG_FUNCTION
(this << dest << oif);
  NS_LOG_LOGIC
("Looking for route for destination " << dest);
 
Ptr<Ipv4Route> rtentry = 0;
 
// store all available routes
 
typedef std::vector<Ipv4RoutingTableEntry*> RouteVec_t;
 
RouteVec_t allRoutes;

 
if(m_isCoreSw)
 
{
      NS_LOG_INFO
("its a core switch");
     
for (NetworkRoutesI i = m_networkRoutes.begin();
                      i
!= m_networkRoutes.end(); i++)
       
{
           
Ipv4Mask mask("255.255.0.0");
           
Ipv4Address entry = (*i)->GetDestNetwork();
           
if (mask.IsMatch(dest, entry))
           
{
               
if (oif != 0)
               
{
                   
if (oif != m_ipv4->GetNetDevice((*i)->GetInterface()))
                   
{
                        NS_LOG_LOGIC
("Not on requested interface, skipping");
                       
continue;
                   
}
               
}
               
// found a route
                allRoutes
.push_back(*i);
           
}
       
}
 
}
 
else
 
{
      NS_LOG_INFO
("No Its not a core switch");
       
for (NetworkRoutesI i = m_networkRoutes.begin();
                i
!= m_networkRoutes.end(); i++)
       
{
           
Ipv4Mask mask = (*i)->GetDestNetworkMask();
           
Ipv4Address entry = (*i)->GetDestNetwork();
           
if (mask.IsMatch(dest, entry))
           
{
               
if (oif != 0)
               
{
                   
if (oif != m_ipv4->GetNetDevice((*i)->GetInterface()))
                   
{
                        NS_LOG_LOGIC
("Not on requested interface, skipping");
                       
continue;
                   
}
               
}
               
// found a route
                allRoutes
.push_back(*i);

           
}
       
}

       
if (allRoutes.size() == 0)
       
{
           
for (SuffixRoutesI i = m_suffixRoutes.begin();
                    i
!= m_suffixRoutes.end(); i++)
           
{
                allRoutes
.push_back(*i);
           
}
       
}
   
}


 
Ipv4RoutingTableEntry* route = 0;
 
if(allRoutes.size() > 0)
 
{
     
if(allRoutes.size() > 1)
     
{
          route
= FindCloseMatch(allRoutes, dest);
     
}
     
else
     
{
          route
= allRoutes.at(0);
     
}

    rtentry
= Create<Ipv4Route>();

    rtentry
->SetDestination (route->GetDest());


    rtentry
->SetSource (m_ipv4->GetAddress (route->GetInterface (), 0).GetLocal ());
    rtentry
->SetGateway (route->GetGateway ());
    uint32_t interfaceIdx
= route->GetInterface ();
    rtentry
->SetOutputDevice (m_ipv4->GetNetDevice (interfaceIdx));
    NS_LOG_UNCOND
("---------------------------------");
    NS_LOG_UNCOND
("At Node: "<< this->GetObject<Node> ()->GetId() <<"\nForwarding packet for: \t" << dest
                             
<< "\nTo next hop with dest\t" << route->GetDest()
                         
<< "\n Destination Network " << route->GetDestNetwork()
                         
<<"\nOuput Port: \t\t" << route->GetInterface());
    NS_LOG_UNCOND
("---------------------------------");
    NS_LOG_INFO
("From lookup " << rtentry);
   
return rtentry;
 
}
 
else
 
{
     
return 0;
 
}
}


//----------------------------------------------------


Ipv4RoutingTableEntry*
FatTreeIpv4RoutingProtocol::FindCloseMatch(std::vector<Ipv4RoutingTableEntry*> allRoutes, Ipv4Address dest)
{
    int32_t diff
= INT32_MAX;
    uint32_t destNo
= dest.Get();
   
int index = -1;
   
for(uint32_t i = 0; i < allRoutes.size(); i++)
   
{
        uint32_t rno
= allRoutes.at(i)->GetDestNetwork().Get();
        int32_t tmpDiff
= destNo - rno;
//        NS_LOG_UNCOND("Route: " << i << "\n" << "dest: " << allRoutes.at(i)->GetDestNetwork());
//        NS_LOG_UNCOND("tmpDiff" << tmpDiff);
       
if(tmpDiff < 0)
       
{
            tmpDiff
= (-1) * tmpDiff;
       
}

       
if(tmpDiff < diff)
       
{
            diff
= tmpDiff;
            index
= i;
       
}
   
}
//    NS_LOG_UNCOND("Destination Network: " << allRoutes.at(index)->GetDestNetwork() << " Destination Address" << allRoutes.at(index)->GetGateway());
   
return allRoutes.at(index);
}

Tommaso Pecorella

unread,
Jan 14, 2016, 1:52:38 PM1/14/16
to ns-3-users
Hi,

tbh there are too many things I can't analyst without all the surrounding code (and a lot of time to understand it).

What you can do is to print all the entries that are being added to the "allRoutes" container, with an indication of what loop part they're being added by.
In this way you should be able to spot where the .0 is coming from.

Cheers,

T.


On Thursday, January 14, 2016 at 6:47:07 PM UTC+1, Ubaid ur Rahman wrote:
Hello,

Thank you for your reply. That is what I get from route->GetDest(); I am pasting both functions below, may be that will help

Ubaid ur Rahman

unread,
Jan 14, 2016, 2:17:07 PM1/14/16
to ns-3-...@googlegroups.com
Hello,

Thank you, okay I'll dissect it more! But one last thing... you have a packet, and you want the route is not resolved on the current router level, so you send it to router above in the hierarchy. How would you forward it? Can you please post that small block of code 😌

--
Posting to this group should follow these guidelines https://www.nsnam.org/wiki/Ns-3-users-guidelines-for-posting
---
You received this message because you are subscribed to the Google Groups "ns-3-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ns-3-users+...@googlegroups.com.
To post to this group, send email to ns-3-...@googlegroups.com.
Visit this group at https://groups.google.com/group/ns-3-users.
For more options, visit https://groups.google.com/d/optout.



--
Regards,

Ubaid ur Rahman

Tommaso Pecorella

unread,
Jan 14, 2016, 4:49:01 PM1/14/16
to ns-3-users
Hi,

the packet is *always* resolved in the current router, otherwise it's discarded. 
Perhaps what you're missing is the default route. If you install a default route, the one will catch all the packets that did not match anything.
In your code, instead of returning zero if a route is not found, you can add something like "If a default router is set, then return it".
Another good way is to add a "normal" route with a "normal" next hop, but with address 0.0.0.0 and net mask 0.0.0.0, e.g.:
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         192.168.11.1    0.0.0.0         UG    0      0        0 eth0

This will catch all uncaught packets and will send 'em to the default next hop.

Cheers,

T.

Ubaid ur Rahman

unread,
Jan 15, 2016, 5:30:19 AM1/15/16
to ns-3-...@googlegroups.com
Hello,

You sir! Are a life savor!! Thank you so much...
Reply all
Reply to author
Forward
0 new messages