#include <ipv4-static-routing.h>
Inherits ns3::Ipv4RoutingProtocol.
Public Member Functions | |
void | AddHostRouteTo (Ipv4Address dest, Ipv4Address nextHop, uint32_t interface) |
Add a host route to the static routing table. | |
void | AddHostRouteTo (Ipv4Address dest, uint32_t interface) |
Add a host route to the static routing table. | |
void | AddNetworkRouteTo (Ipv4Address network, Ipv4Mask networkMask, Ipv4Address nextHop, uint32_t interface) |
Add a network route to the static routing table. | |
void | AddNetworkRouteTo (Ipv4Address network, Ipv4Mask networkMask, uint32_t interface) |
Add a network route to the static routing table. | |
void | SetDefaultRoute (Ipv4Address nextHop, uint32_t interface) |
Add a default route to the static routing table. | |
uint32_t | GetNRoutes (void) |
Get the number of individual unicast routes that have been added to the routing table. | |
Ipv4RoutingTableEntry | GetDefaultRoute (void) |
Get the default route from the static routing table. | |
Ipv4RoutingTableEntry | GetRoute (uint32_t i) |
Get a route from the static unicast routing table. | |
void | RemoveRoute (uint32_t i) |
Remove a route from the static unicast routing table. | |
void | AddMulticastRoute (Ipv4Address origin, Ipv4Address group, uint32_t inputInterface, std::vector< uint32_t > outputInterfaces) |
Add a multicast route to the static routing table. | |
void | SetDefaultMulticastRoute (uint32_t outputInterface) |
Add a default multicast route to the static routing table. | |
uint32_t | GetNMulticastRoutes (void) const |
Get the number of individual multicast routes that have been added to the routing table. | |
Ipv4MulticastRoutingTableEntry | GetMulticastRoute (uint32_t i) const |
Get a route from the static multicast routing table. | |
bool | RemoveMulticastRoute (Ipv4Address origin, Ipv4Address group, uint32_t inputInterface) |
Remove a route from the static multicast routing table. | |
void | RemoveMulticastRoute (uint32_t index) |
Remove a route from the static multicast routing table. | |
Static Public Member Functions | |
static TypeId | GetTypeId (void) |
This method returns the TypeId associated to ns3::Ipv4StaticRouting. | |
Protected Member Functions | |
virtual void | DoDispose (void) |
This class provides a basic set of methods for inserting static unicast and multicast routes into the Ipv4 routing system. This particular protocol is designed to be inserted into an Ipv4ListRouting protocol and at present cannot be inserted as the only routing protocol into Ipv4 (i.e. it must be added to an Ipv4ListRouting).
The Ipv4StaticRouting class inherits from the abstract base class Ipv4RoutingProtocol that defines the interface methods that a routing protocol must support.
void ns3::Ipv4StaticRouting::AddHostRouteTo | ( | Ipv4Address | dest, | |
uint32_t | interface | |||
) |
Add a host route to the static routing table.
dest | The Ipv4Address destination for this route. | |
interface | The network interface index used to send packets to the destination. |
void ns3::Ipv4StaticRouting::AddHostRouteTo | ( | Ipv4Address | dest, | |
Ipv4Address | nextHop, | |||
uint32_t | interface | |||
) |
Add a host route to the static routing table.
dest | The Ipv4Address destination for this route. | |
nextHop | The Ipv4Address of the next hop in the route. | |
interface | The network interface index used to send packets to the destination. |
void ns3::Ipv4StaticRouting::AddMulticastRoute | ( | Ipv4Address | origin, | |
Ipv4Address | group, | |||
uint32_t | inputInterface, | |||
std::vector< uint32_t > | outputInterfaces | |||
) |
Add a multicast route to the static routing table.
A multicast route must specify an origin IP address, a multicast group and an input network interface index as conditions and provide a vector of output network interface indices over which packets matching the conditions are sent.
Typically there are two main types of multicast routes: routes of the first kind are used during forwarding. All of the conditions must be exlicitly provided. The second kind of routes are used to get packets off of a local node. The difference is in the input interface. Routes for forwarding will always have an explicit input interface specified. Routes off of a node will always set the input interface to a wildcard specified by the index Ipv4RoutingProtocol::INTERFACE_ANY.
For routes off of a local node wildcards may be used in the origin and multicast group addresses. The wildcard used for Ipv4Adresses is that address returned by Ipv4Address::GetAny () -- typically "0.0.0.0". Usage of a wildcard allows one to specify default behavior to varying degrees.
For example, making the origin address a wildcard, but leaving the multicast group specific allows one (in the case of a node with multiple interfaces) to create different routes using different output interfaces for each multicast group.
If the origin and multicast addresses are made wildcards, you have created essentially a default multicast address that can forward to multiple interfaces. Compare this to the actual default multicast address that is limited to specifying a single output interface for compatibility with existing functionality in other systems.
origin | The Ipv4Address of the origin of packets for this route. May be Ipv4Address:GetAny for open groups. | |
group | The Ipv4Address of the multicast group or this route. | |
inputInterface | The input network interface index over which to expect packets destined for this route. May be Ipv4RoutingProtocol::INTERFACE_ANY for packets of local origin. | |
outputInterfaces | A vector of network interface indices used to specify how to send packets to the destination(s). |
void ns3::Ipv4StaticRouting::AddNetworkRouteTo | ( | Ipv4Address | network, | |
Ipv4Mask | networkMask, | |||
uint32_t | interface | |||
) |
Add a network route to the static routing table.
network | The Ipv4Address network for this route. | |
networkMask | The Ipv4Mask to extract the network. | |
interface | The network interface index used to send packets to the destination. |
void ns3::Ipv4StaticRouting::AddNetworkRouteTo | ( | Ipv4Address | network, | |
Ipv4Mask | networkMask, | |||
Ipv4Address | nextHop, | |||
uint32_t | interface | |||
) |
Add a network route to the static routing table.
network | The Ipv4Address network for this route. | |
networkMask | The Ipv4Mask to extract the network. | |
nextHop | The next hop in the route to the destination network. | |
interface | The network interface index used to send packets to the destination. |
virtual void ns3::Ipv4StaticRouting::DoDispose | ( | void | ) | [protected, virtual] |
This method is called by Object::Dispose or by the object's destructor, whichever comes first.
Subclasses are expected to implement their real destruction code in an overriden version of this method and chain up to their parent's implementation once they are done. i.e., for simplicity, the destructor of every subclass should be empty and its content should be moved to the associated DoDispose method.
Reimplemented from ns3::Object.
Ipv4RoutingTableEntry ns3::Ipv4StaticRouting::GetDefaultRoute | ( | void | ) |
Get the default route from the static routing table.
Ipv4MulticastRoutingTableEntry ns3::Ipv4StaticRouting::GetMulticastRoute | ( | uint32_t | i | ) | const |
Get a route from the static multicast routing table.
Externally, the multicast static routing table appears simply as a table with n entries.
i | The index (into the routing table) of the multicast route to retrieve. |
uint32_t ns3::Ipv4StaticRouting::GetNMulticastRoutes | ( | void | ) | const |
Get the number of individual multicast routes that have been added to the routing table.
uint32_t ns3::Ipv4StaticRouting::GetNRoutes | ( | void | ) |
Get the number of individual unicast routes that have been added to the routing table.
Ipv4RoutingTableEntry ns3::Ipv4StaticRouting::GetRoute | ( | uint32_t | i | ) |
Get a route from the static unicast routing table.
Externally, the unicast static routing table appears simply as a table with n entries. The one sublety of note is that if a default route has been set it will appear as the zeroth entry in the table. This means that if you add only a default route, the table will have one entry that can be accessed either by explicity calling GetDefaultRoute () or by calling GetRoute (0).
Similarly, if the default route has been set, calling RemoveRoute (0) will remove the default route.
i | The index (into the routing table) of the route to retrieve. If the default route has been set, it will occupy index zero. |
static TypeId ns3::Ipv4StaticRouting::GetTypeId | ( | void | ) | [static] |
This method returns the TypeId associated to ns3::Ipv4StaticRouting.
No Attributes defined for this type.
No TraceSources defined for this type.
Reimplemented from ns3::Object.
void ns3::Ipv4StaticRouting::RemoveMulticastRoute | ( | uint32_t | index | ) |
Remove a route from the static multicast routing table.
Externally, the multicast static routing table appears simply as a table with n entries.
index | The index (into the multicast routing table) of the route to remove. |
Ipv4StaticRouting::AddRoute
bool ns3::Ipv4StaticRouting::RemoveMulticastRoute | ( | Ipv4Address | origin, | |
Ipv4Address | group, | |||
uint32_t | inputInterface | |||
) |
Remove a route from the static multicast routing table.
Externally, the multicast static routing table appears simply as a table with n entries. This method causes the multicast routing table to be searched for the first route that matches the parameters and removes it.
Wildcards may be provided to this function, but the wildcards are used to exacly match wildcards in the routes (see AddMulticastRoute). That is, calling RemoveMulticastRoute with the origin set to "0.0.0.0" will not remove routes with any address in the origin, but will only remove routes with "0.0.0.0" set as the the origin.
origin | The IP address specified as the origin of packets for the route. | |
group | The IP address specified as the multicast group addres of the route. | |
inputInterface | The network interface index specified as the expected input interface for the route. |
void ns3::Ipv4StaticRouting::RemoveRoute | ( | uint32_t | i | ) |
Remove a route from the static unicast routing table.
Externally, the unicast static routing table appears simply as a table with n entries. The one sublety of note is that if a default route has been set it will appear as the zeroth entry in the table. This means that if the default route has been set, calling RemoveRoute (0) will remove the default route.
i | The index (into the routing table) of the route to remove. If the default route has been set, it will occupy index zero. |
Ipv4StaticRouting::AddRoute
void ns3::Ipv4StaticRouting::SetDefaultMulticastRoute | ( | uint32_t | outputInterface | ) |
Add a default multicast route to the static routing table.
This is the multicast equivalent of the unicast version SetDefaultRoute. We tell the routing system what to do in the case where a specific route to a destination multicast group is not found. The system forwards packets out the specified interface in the hope that "something out there" knows better how to route the packet. This method is only used in initially sending packets off of a host. The default multicast route is not consulted during forwarding -- exact routes must be specified using AddMulticastRoute for that case.
Since we're basically sending packets to some entity we think may know better what to do, we don't pay attention to "subtleties" like origin address, nor do we worry about forwarding out multiple interfaces. If the default multicast route is set, it is returned as the selected route from LookupStatic irrespective of origin or multicast group if another specific route is not found.
outputInterface | The network interface index used to specify where to send packets in the case of unknown routes. |
void ns3::Ipv4StaticRouting::SetDefaultRoute | ( | Ipv4Address | nextHop, | |
uint32_t | interface | |||
) |
Add a default route to the static routing table.
This method tells the routing system what to do in the case where a specific route to a destination is not found. The system forwards packets to the specified node in the hope that it knows better how to route the packet.
If the default route is set, it is returned as the selected route from LookupStatic irrespective of destination address if no specific route is found.
nextHop | The Ipv4Address to send packets to in the hope that they will be forwarded correctly. | |
interface | The network interface index used to send packets. |
Ipv4StaticRouting::Lookup