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
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
if (allRoutes.size() == 0)
{
for (SuffixRoutesI i = m_suffixRoutes.begin();
i != m_suffixRoutes.end(); i++)
{
allRoutes.push_back(*i);
}
}
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);
}
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
--
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.