24 #include "ns3/packet.h" 
   25 #include "ns3/simulator.h" 
   26 #include "ns3/ipv6-route.h" 
   27 #include "ns3/net-device.h" 
   28 #include "ns3/names.h" 
   43     .SetGroupName (
"Internet")
 
   67   for (i = 0; i < 
m_ipv6->GetNInterfaces (); i++)
 
   87   *os << 
"Node: " << 
m_ipv6->GetObject<
Node> ()->GetId ()
 
   88       << 
", Time: " << 
Now().
As (unit)
 
   89       << 
", Local time: " << GetObject<Node> ()->GetLocalTime ().As (unit)
 
   90       << 
", Ipv6StaticRouting table" << std::endl;
 
   94       *os << 
"Destination                    Next Hop                   Flag Met Ref Use If" << std::endl;
 
   97           std::ostringstream dest, gw, mask, flags;
 
  100           *os << std::setiosflags (std::ios::left) << std::setw (31) << dest.str ();
 
  102           *os << std::setiosflags (std::ios::left) << std::setw (27) << gw.str ();
 
  112           *os << std::setiosflags (std::ios::left) << std::setw (5) << flags.str ();
 
  113           *os << std::setiosflags (std::ios::left) << std::setw (4) << 
GetMetric (j);
 
  134   NS_LOG_FUNCTION (
this << dst << nextHop << interface << prefixToUse << metric);
 
  137       NS_LOG_WARN (
"Ipv6StaticRouting::AddHostRouteTo - Next hop should be link-local");
 
  151   NS_LOG_FUNCTION (
this << network << networkPrefix << nextHop << interface << metric);
 
  159   NS_LOG_FUNCTION (
this << network << networkPrefix << nextHop << interface << prefixToUse << metric);
 
  162       NS_LOG_WARN (
"Ipv6StaticRouting::AddNetworkRouteTo - Next hop should be link-local");
 
  288   uint16_t longestMask = 0;
 
  289   uint32_t shortestMetric = 0xffffffff;
 
  294       NS_ASSERT_MSG (interface, 
"Try to send on link-local multicast address, and no interface index is given!");
 
  295       rtentry = Create<Ipv6Route> ();
 
  296       rtentry->SetSource (
m_ipv6->SourceAddressSelection (
m_ipv6->GetInterfaceForDevice (interface), dst));
 
  297       rtentry->SetDestination (dst);
 
  299       rtentry->SetOutputDevice (interface);
 
  306       uint32_t metric = it->second;
 
  311       NS_LOG_LOGIC (
"Searching for route to " << dst << 
", mask length " << maskLen << 
", metric " << metric);
 
  315           NS_LOG_LOGIC (
"Found global network route " << *j << 
", mask length " << maskLen << 
", metric " << metric);
 
  320               if (maskLen < longestMask)
 
  326               if (maskLen > longestMask)
 
  328                   shortestMetric = 0xffffffff;
 
  331               longestMask = maskLen;
 
  332               if (metric > shortestMetric)
 
  334                   NS_LOG_LOGIC (
"Equal mask length, but previous metric shorter, skipping");
 
  338               shortestMetric = metric;
 
  341               rtentry = Create<Ipv6Route> ();
 
  345                   rtentry->SetSource (
m_ipv6->SourceAddressSelection (interfaceIdx, route->
GetDest ()));
 
  353                   rtentry->SetSource (
m_ipv6->SourceAddressSelection (interfaceIdx, route->
GetGateway ()));
 
  356               rtentry->SetDestination (route->
GetDest ());
 
  358               rtentry->SetOutputDevice (
m_ipv6->GetNetDevice (interfaceIdx));
 
  369       NS_LOG_LOGIC (
"Matching route via " << rtentry->GetDestination () << 
" (Through " << rtentry->GetGateway () << 
") at the end");
 
  416           NS_LOG_LOGIC (
"Find source specific multicast route" << *i);
 
  424               mrtentry = Create<Ipv6MulticastRoute> ();
 
  425               mrtentry->SetGroup (route->
GetGroup ());
 
  426               mrtentry->SetOrigin (route->
GetOrigin ());
 
  452   uint32_t shortestMetric = 0xffffffff;
 
  458       uint32_t metric = it->second;
 
  468       if (metric > shortestMetric)
 
  472       shortestMetric = metric;
 
  594   uint32_t iif = 
m_ipv6->GetInterfaceForDevice (idev);
 
  608           mcb (idev, mrtentry, p, header); 
 
  619   if (
m_ipv6->IsForwarding (iif) == 
false)
 
  621       NS_LOG_LOGIC (
"Forwarding disabled for this interface");
 
  634       NS_LOG_LOGIC (
"Found unicast destination- calling unicast callback");
 
  635       ucb (idev, rtentry, p, header);  
 
  640       NS_LOG_LOGIC (
"Did not find unicast destination- returning false");
 
  647   for (uint32_t j = 0; j < 
m_ipv6->GetNAddresses (i); j++)
 
  660                                  m_ipv6->GetAddress (i, j).GetPrefix (), i);
 
  673       if (it->first->GetInterface () == i)
 
  687   if (!
m_ipv6->IsUp (interface))
 
  703   if (!
m_ipv6->IsUp (interface))
 
  715       if (it->first->GetInterface () == interface
 
  716           && it->first->IsNetwork ()
 
  717           && it->first->GetDestNetwork () == networkAddress
 
  718           && it->first->GetDestNetworkPrefix () == networkMask)
 
  732   NS_LOG_INFO (
this << dst << mask << nextHop << interface << prefixToUse);
 
  762           if (dst == entry && prefix == mask && rtentry->
GetInterface () == interface)
 
bool IsMatch(Ipv6Address a, Ipv6Address b) const 
If the Address match the type. 
 
bool IsAny() const 
If the IPv6 address is the "Any" address. 
 
static const uint32_t MAX_TTL
Maximum Time-To-Live (TTL). 
 
Unit
The unit to use to interpret a number representing time. 
 
Smart pointer class similar to boost::intrusive_ptr. 
 
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by "...
 
Ipv6Address GetPrefixToUse() const 
Get the prefix to use (for multihomed link). 
 
virtual ~Ipv6StaticRouting()
 
SocketErrno
Enumeration of the possible errors returned by a socket. 
 
NetworkRoutes m_networkRoutes
the forwarding table for network. 
 
bool RemoveMulticastRoute(Ipv6Address origin, Ipv6Address group, uint32_t inputInterface)
Remove a static multicast route. 
 
bool IsLinkLocalMulticast() const 
If the IPv6 address is link-local multicast (ff02::/16). 
 
Ipv6Prefix GetDestNetworkPrefix() const 
Get the destination prefix. 
 
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system. 
 
static Ipv6RoutingTableEntry CreateNetworkRouteTo(Ipv6Address network, Ipv6Prefix networkPrefix, Ipv6Address nextHop, uint32_t interface)
Create a route to a network. 
 
virtual void NotifyRemoveRoute(Ipv6Address dst, Ipv6Prefix mask, Ipv6Address nextHop, uint32_t interface, Ipv6Address prefixToUse=Ipv6Address::GetZero())
Notify route removing. 
 
virtual void NotifyAddRoute(Ipv6Address dst, Ipv6Prefix mask, Ipv6Address nextHop, uint32_t interface, Ipv6Address prefixToUse=Ipv6Address::GetZero())
Notify a new route. 
 
A record of an IPv6 multicast route. 
 
virtual void SetIpv6(Ptr< Ipv6 > ipv6)
Typically, invoked directly or indirectly from ns3::Ipv6::SetRoutingProtocol. 
 
virtual Ptr< Ipv6Route > RouteOutput(Ptr< Packet > p, const Ipv6Header &header, Ptr< NetDevice > oif, Socket::SocketErrno &sockerr)
Query routing cache for an existing route, for an outbound packet. 
 
uint32_t GetInputInterface() const 
Get the input interface address. 
 
bool IsLinkLocal() const 
If the IPv6 address is a link-local address (fe80::/64). 
 
std::list< Ipv6MulticastRoutingTableEntry * >::const_iterator MulticastRoutesCI
Const Iterator for container for the multicast routes. 
 
bool IsNull(void) const 
Check for null implementation. 
 
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file...
 
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name. 
 
IPv6 address associated with an interface. 
 
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO. 
 
virtual void DoDispose(void)
Destructor implementation. 
 
#define NS_LOG_FUNCTION_NOARGS()
Output the name of the function. 
 
std::list< std::pair< Ipv6RoutingTableEntry *, uint32_t > >::iterator NetworkRoutesI
Iterator for container for the network routes. 
 
uint32_t GetNOutputInterfaces() const 
Get the number of output interfaces of this route. 
 
static Ipv6MulticastRoutingTableEntry CreateMulticastRoute(Ipv6Address origin, Ipv6Address group, uint32_t inputInterface, std::vector< uint32_t > outputInterfaces)
Create a multicast route. 
 
static Ipv6Prefix GetZero()
Get the zero prefix ( /0). 
 
uint32_t GetNMulticastRoutes() const 
Get the number of entries in the multicast routing table. 
 
void AddHostRouteTo(Ipv6Address dest, Ipv6Address nextHop, uint32_t interface, Ipv6Address prefixToUse=Ipv6Address("::"), uint32_t metric=0)
Add route to host. 
 
static TypeId GetTypeId()
The interface Id associated with this class. 
 
Ipv6Address GetDestNetwork() const 
Get the destination network. 
 
Ipv6Address GetAddress() const 
Get the IPv6 address. 
 
A record of an IPv6 route. 
 
NS_ASSERT_MSG(false,"Ipv4AddressGenerator::MaskToIndex(): Impossible")
 
Ptr< Ipv6 > m_ipv6
Ipv6 reference. 
 
uint32_t GetMetric(uint32_t index) const 
Get a metric for route from the static unicast routing table. 
 
virtual void NotifyInterfaceDown(uint32_t interface)
Notify when specified interface goes DOWN. 
 
Ptr< Ipv6Route > LookupStatic(Ipv6Address dest, Ptr< NetDevice >=0)
Lookup in the forwarding table for destination. 
 
static Ipv6Address GetZero()
Get the 0 (::) Ipv6Address. 
 
void AddMulticastRoute(Ipv6Address origin, Ipv6Address group, uint32_t inputInterface, std::vector< uint32_t > outputInterfaces)
Add a multicast route for a given multicast source and group. 
 
virtual void NotifyRemoveAddress(uint32_t interface, Ipv6InterfaceAddress address)
Notify when specified interface add an address. 
 
Ipv6Address GetOrigin() const 
Get the source of this route. 
 
bool IsHost() const 
Is the route entry correspond to a host ? 
 
void AddNetworkRouteTo(Ipv6Address network, Ipv6Prefix networkPrefix, Ipv6Address nextHop, uint32_t interface, uint32_t metric=0)
Add route to network. 
 
Ipv6Prefix GetPrefix() const 
Get the IPv6 prefix. 
 
virtual bool RouteInput(Ptr< const Packet > p, const Ipv6Header &header, Ptr< const NetDevice > idev, UnicastForwardCallback ucb, MulticastForwardCallback mcb, LocalDeliverCallback lcb, ErrorCallback ecb)
Route an input packet (to be forwarded or locally delivered) 
 
virtual void NotifyInterfaceUp(uint32_t interface)
Notify when specified interface goes UP. 
 
Static routing protocol for IP version 6 stacks. 
 
uint32_t GetOutputInterface(uint32_t n) const 
Get a specified output interface. 
 
Every class exported by the ns3 library is enclosed in the ns3 namespace. 
 
static const uint32_t IF_ANY
Any interface magic number. 
 
Ipv6RoutingTableEntry GetDefaultRoute()
Get the default route. 
 
bool IsMulticast() const 
If the IPv6 address is multicast (ff00::/8). 
 
Ipv6Address GetGateway() const 
Get the gateway. 
 
uint32_t GetInterface() const 
Get the interface index. 
 
NS_LOG_LOGIC("Net device "<< nd<< " is not bridged")
 
Ipv6RoutingTableEntry GetRoute(uint32_t i) const 
Get a specified route. 
 
Describes an IPv6 address. 
 
void RemoveRoute(uint32_t i)
Remove a route from the routing table. 
 
void SetDefaultRoute(Ipv6Address nextHop, uint32_t interface, Ipv6Address prefixToUse=Ipv6Address("::"), uint32_t metric=0)
Set the default route. 
 
Ipv6Address GetGroup() const 
Get the group. 
 
static Ipv6Prefix GetOnes()
Get the "all-1" IPv6 mask (ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff). 
 
TimeWithUnit As(const enum Unit unit) const 
Attach a unit to a Time, to facilitate output in a specific unit. 
 
#define NS_LOG_WARN(msg)
Use NS_LOG to output a message of level LOG_WARN. 
 
Ipv6Address GetDest() const 
Get the destination. 
 
virtual void DoDispose()
Dispose this object. 
 
void SetDefaultMulticastRoute(uint32_t outputInterface)
Set the default multicast route. 
 
static std::string FindName(Ptr< Object > object)
Given a pointer to an object, look to see if that object has a name associated with it and...
 
virtual void NotifyAddAddress(uint32_t interface, Ipv6InterfaceAddress address)
Notify when specified interface add an address. 
 
std::list< std::pair< Ipv6RoutingTableEntry *, uint32_t > >::const_iterator NetworkRoutesCI
Const Iterator for container for the network routes. 
 
Describes an IPv6 prefix. 
 
bool IsGateway() const 
Is it the gateway ? 
 
Time Now(void)
create an ns3::Time instance which contains the current simulation time. 
 
uint8_t GetPrefixLength() const 
Get prefix length. 
 
virtual void PrintRoutingTable(Ptr< OutputStreamWrapper > stream, Time::Unit unit=Time::S) const 
Print the Routing Table entries. 
 
MulticastRoutes m_multicastRoutes
the forwarding table for multicast. 
 
uint32_t GetNRoutes() const 
Get the number or entries in the routing table. 
 
Ipv6MulticastRoutingTableEntry GetMulticastRoute(uint32_t i) const 
Get the specified multicast route. 
 
Ipv6Address CombinePrefix(Ipv6Prefix const &prefix)
Combine this address with a prefix. 
 
Abstract base class for IPv6 routing protocols. 
 
a unique identifier for an interface. 
 
TypeId SetParent(TypeId tid)
Set the parent TypeId. 
 
std::ostream * GetStream(void)
Return a pointer to an ostream previously set in the wrapper. 
 
bool HasNetworkDest(Ipv6Address dest, uint32_t interfaceIndex)
If the destination is already present in network destination list. 
 
std::list< Ipv6MulticastRoutingTableEntry * >::iterator MulticastRoutesI
Iterator for container for the multicast routes.