21 #define NS_LOG_APPEND_CONTEXT \
22 if (m_ipv4 && m_ipv4->GetObject<Node> ()) { \
23 std::clog << Simulator::Now ().GetSeconds () \
24 << " [node " << m_ipv4->GetObject<Node> ()->GetId () << "] "; }
28 #include "ns3/names.h"
29 #include "ns3/packet.h"
31 #include "ns3/simulator.h"
32 #include "ns3/ipv4-route.h"
33 #include "ns3/output-stream-wrapper.h"
50 .AddConstructor<Ipv4StaticRouting> ()
68 NS_LOG_FUNCTION (
this << network <<
" " << networkMask <<
" " << nextHop <<
" " << interface <<
" " << metric);
83 NS_LOG_FUNCTION (
this << network <<
" " << networkMask <<
" " << interface <<
" " << metric);
97 NS_LOG_FUNCTION (
this << dest <<
" " << nextHop <<
" " << interface <<
" " << metric);
115 NS_LOG_FUNCTION (
this << nextHop <<
" " << interface <<
" " << metric);
122 uint32_t inputInterface,
123 std::vector<uint32_t> outputInterfaces)
125 NS_LOG_FUNCTION (
this << origin <<
" " << group <<
" " << inputInterface <<
" " << &outputInterfaces);
128 inputInterface, outputInterfaces);
160 "Ipv4StaticRouting::GetMulticastRoute (): Index out of range");
182 uint32_t inputInterface)
184 NS_LOG_FUNCTION (
this << origin <<
" " << group <<
" " << inputInterface);
226 uint16_t longest_mask = 0;
227 uint32_t shortest_metric = 0xffffffff;
231 NS_ASSERT_MSG (oif,
"Try to send on link-local multicast address, and no interface index is given!");
233 rtentry = Create<Ipv4Route> ();
247 uint32_t metric =i->second;
248 Ipv4Mask mask = (j)->GetDestNetworkMask ();
251 NS_LOG_LOGIC (
"Searching for route to " << dest <<
", checking against route to " << entry <<
"/" << masklen);
252 if (mask.
IsMatch (dest, entry))
254 NS_LOG_LOGIC (
"Found global network route " << j <<
", mask length " << masklen <<
", metric " << metric);
263 if (masklen < longest_mask)
268 if (masklen > longest_mask)
270 shortest_metric = 0xffffffff;
272 longest_mask = masklen;
273 if (metric > shortest_metric)
275 NS_LOG_LOGIC (
"Equal mask length, but previous metric shorter, skipping");
278 shortest_metric = metric;
281 rtentry = Create<Ipv4Route> ();
294 NS_LOG_LOGIC (
"No matching route to " << dest <<
" found");
324 NS_LOG_LOGIC (
"Found multicast source specific route" << *i);
332 mrtentry = Create<Ipv4MulticastRoute> ();
333 mrtentry->SetGroup (route->
GetGroup ());
334 mrtentry->SetOrigin (route->
GetOrigin ());
364 uint32_t shortest_metric = 0xffffffff;
371 uint32_t metric = i->second;
372 Ipv4Mask mask = (j)->GetDestNetworkMask ();
378 if (metric > shortest_metric)
382 shortest_metric = metric;
507 mcb (mrtentry, p, ipHeader);
540 NS_LOG_LOGIC (
"For me (destination " << addr <<
" match)");
546 lcb (p, ipHeader, iif);
552 lcb (p, ipHeader, iif);
561 NS_LOG_LOGIC (
"Forwarding disabled for this interface");
569 NS_LOG_LOGIC (
"Found unicast destination- calling unicast callback");
570 ucb (rtentry, p, ipHeader);
575 NS_LOG_LOGIC (
"Did not find unicast destination- returning false");
659 networkMask, interface);
713 *os <<
"Destination Gateway Genmask Flags Metric Ref Use Iface" << std::endl;
716 std::ostringstream dest, gw, mask, flags;
719 *os << std::setiosflags (std::ios::left) << std::setw (16) << dest.str ();
721 *os << std::setiosflags (std::ios::left) << std::setw (16) << gw.str ();
723 *os << std::setiosflags (std::ios::left) << std::setw (16) << mask.str ();
733 *os << std::setiosflags (std::ios::left) << std::setw (6) << flags.str ();
734 *os << std::setiosflags (std::ios::left) << std::setw (7) <<
GetMetric (j);