|
A Discrete-Event Network Simulator
|
API
|
Go to the documentation of this file.
23 #ifndef OLSR_AGENT_IMPL_H
24 #define OLSR_AGENT_IMPL_H
31 #include "ns3/object.h"
32 #include "ns3/packet.h"
34 #include "ns3/socket.h"
35 #include "ns3/event-garbage-collector.h"
36 #include "ns3/random-variable-stream.h"
37 #include "ns3/timer.h"
38 #include "ns3/traced-callback.h"
40 #include "ns3/ipv4-routing-protocol.h"
41 #include "ns3/ipv4-static-routing.h"
73 class RoutingProtocol;
86 friend class ::OlsrMprTestCase;
243 std::map<Ipv4Address, RoutingTableEntry>
m_table;
void RemoveNeighborTuple(const NeighborTuple &tuple)
Removes a neighbor tuple from the Neighbor Set.
a unique identifier for an interface.
OlsrState m_state
Internal state with all needed data structs.
void AddIfaceAssocTuple(const IfaceAssocTuple &tuple)
Adds an interface association tuple to the Interface Association Set.
virtual ~RoutingProtocol(void)
virtual void SetIpv4(Ptr< Ipv4 > ipv4)
Timer m_midTimer
Timer for the MID message.
void NeighborLoss(const LinkTuple &tuple)
Performs all actions needed when a neighbor loss occurs.
virtual void NotifyRemoveAddress(uint32_t interface, Ipv4InterfaceAddress address)
virtual void NotifyAddAddress(uint32_t interface, Ipv4InterfaceAddress address)
void Nb2hopTupleTimerExpire(Ipv4Address neighborMainAddr, Ipv4Address twoHopNeighborAddr)
Removes 2_hop neighbor tuple_ if expired.
Callback< void, Ptr< Ipv4MulticastRoute >, Ptr< const Packet >, const Ipv4Header & > MulticastForwardCallback
Callback for multicast packets to be forwarded.
void SendQueuedMessages(void)
Creates as many OLSR packets as needed in order to send all buffered OLSR messages.
SocketErrno
Enumeration of the possible errors returned by a socket.
Ptr< Ipv4StaticRouting > m_routingTableAssociation
Associations from an Ipv4StaticRouting instance.
uint16_t GetPacketSequenceNumber(void)
Increments packet sequence number and returns the new value.
An Interface Association Tuple.
void LinkTupleUpdated(const LinkTuple &tuple, uint8_t willingness)
This function is invoked when a link tuple is updated.
void HnaTimerExpire(void)
Sends an HNA message (if the node has associated hosts/networks) and reschedules the HNA timer.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
void ProcessHello(const olsr::MessageHeader &msg, const Ipv4Address &receiverIface, const Ipv4Address &senderIface)
Processes a HELLO message following RFC 3626 specification.
uint16_t m_packetSequenceNumber
Packets sequence number counter.
OLSR routing protocol for IPv4.
static TypeId GetTypeId(void)
Get the type ID.
TracedCallback< const PacketHeader &, const MessageList & > m_rxPacketTrace
Rx packet trace.
void SendMid(void)
Creates a new OLSR MID message which is buffered for being sent later on.
void LinkSensing(const olsr::MessageHeader &msg, const olsr::MessageHeader::Hello &hello, const Ipv4Address &receiverIface, const Ipv4Address &senderIface)
Updates Link Set according to a new received HELLO message (following RFC 3626 specification).
Ptr< Ipv4 > m_ipv4
IPv4 object the routing is linked to.
Ipv4 addresses are stored in host order in this class.
virtual bool RouteInput(Ptr< const Packet > p, const Ipv4Header &header, Ptr< const NetDevice > idev, UnicastForwardCallback ucb, MulticastForwardCallback mcb, LocalDeliverCallback lcb, ErrorCallback ecb)
Route an input packet (to be forwarded or locally delivered)
void Dump(void)
Dump the neighbor table, two-hop neighbor table, and routing table to logging output (NS_LOG_DEBUG lo...
void RemoveMprSelectorTuple(const MprSelectorTuple &tuple)
Removes an MPR selector tuple from the MPR Selector Set.
std::set< Ipv4Address > MprSet
MPR Set type.
const NeighborSet & GetNeighbors(void) const
Get the one hop neighbors.
static const uint16_t OLSR_PORT_NUMBER
port number (698)
A record of an IPv4 routing table entry for Ipv4GlobalRouting and Ipv4StaticRouting.
std::vector< TwoHopNeighborTuple > TwoHopNeighborSet
2-hop Neighbor Set type.
std::map< Ptr< Socket >, Ipv4InterfaceAddress > m_sendSockets
Container of sockets and the interfaces they are opened onto.
void SendHello(void)
Creates a new OLSR HELLO message which is buffered for being sent later on.
Ipv4Address nextAddr
Address of the next hop.
void RemoveEntry(const Ipv4Address &dest)
Deletes the entry whose destination address is given.
void SendHna(void)
Creates a new OLSR HNA message which is buffered for being sent later on.
Ptr< Ipv4StaticRouting > m_hnaRoutingTable
Routing table for HNA routes.
std::vector< MessageHeader > MessageList
A simple virtual Timer class.
Callback< void, Ptr< Ipv4Route >, Ptr< const Packet >, const Ipv4Header & > UnicastForwardCallback
Callback for unicast packets to be forwarded.
This class encapsulates all data structures needed for maintaining internal state of an OLSR node.
void MidTimerExpire(void)
Sends a MID message (if the node has more than one interface) and resets the MID timer.
Smart pointer class similar to boost::intrusive_ptr.
Ptr< const Ipv4StaticRouting > GetRoutingTableAssociation(void) const
Returns the internal HNA table.
virtual void NotifyInterfaceDown(uint32_t interface)
Callback< void, Ptr< const Packet >, const Ipv4Header &, uint32_t > LocalDeliverCallback
Callback for packets to be locally delivered.
void TopologyTupleTimerExpire(Ipv4Address destAddr, Ipv4Address lastAddr)
Removes topology tuple_ if expired.
void AddHostNetworkAssociation(Ipv4Address networkAddr, Ipv4Mask netmask)
Injects the specified (networkAddr, netmask) tuple in the list of local HNA associations to be sent b...
Time m_tcInterval
TC messages' emission interval.
Ipv4Address GetMainAddress(Ipv4Address iface_addr) const
Gets the main address associated with a given interface address.
MprSet GetMprSet(void) const
Gets the MPR set.
virtual NS_DEPRECATED_3_34 Ptr< Ipv4 > GetIpv4(void) const
a class to store IPv4 address information on an interface
void AssociationTupleTimerExpire(Ipv4Address gatewayAddr, Ipv4Address networkAddr, Ipv4Mask netmask)
Removes association tuple_ if expired.
void ProcessMid(const olsr::MessageHeader &msg, const Ipv4Address &senderIface)
Processes a MID message following RFC 3626 specification.
virtual void DoInitialize(void)
Initialize() implementation.
void AddEntry(const Ipv4Address &dest, const Ipv4Address &next, uint32_t interface, uint32_t distance)
Adds a new entry into the routing table.
Testcase for MPR computation mechanism.
TracedCallback< const PacketHeader &, const MessageList & > m_txPacketTrace
Tx packet trace.
const MprSelectorSet & GetMprSelectors(void) const
Gets the MPR selectors.
void AddNeighborTuple(const NeighborTuple &tuple)
Adds a neighbor tuple to the Neighbor Set.
void RemoveLinkTuple(const LinkTuple &tuple)
Removes a link tuple from the Link Set.
bool UsesNonOlsrOutgoingInterface(const Ipv4RoutingTableEntry &route)
Tests whether or not the specified route uses a non-OLSR outgoing interface.
std::vector< NeighborTuple > NeighborSet
Neighbor Set type.
void LinkTupleTimerExpire(Ipv4Address neighborIfaceAddr)
Removes tuple_ if expired.
void LinkTupleAdded(const LinkTuple &tuple, uint8_t willingness)
Adds a link tuple.
An object that tracks scheduled events and automatically cancels them when it is destroyed.
void RoutingTableComputation(void)
Creates the routing table of the node following RFC 3626 hints.
Simulation virtual time values and global simulation resolution.
void RecvOlsr(Ptr< Socket > socket)
Receive an OLSR message.
An OLSR's routing table entry.
void ForwardDefault(olsr::MessageHeader olsrMessage, DuplicateTuple *duplicated, const Ipv4Address &localIface, const Ipv4Address &senderAddress)
OLSR's default forwarding algorithm.
Timer m_queuedMessagesTimer
timer for throttling outgoing messages
void SetRoutingTableAssociation(Ptr< Ipv4StaticRouting > routingTable)
Associates the specified Ipv4StaticRouting routing table to the OLSR routing protocol.
int Degree(NeighborTuple const &tuple)
This auxiliary function (defined in RFC 3626) is used for calculating the MPR Set.
int64_t AssignStreams(int64_t stream)
Assign a fixed random variable stream number to the random variables used by this model.
std::vector< RoutingTableEntry > GetRoutingTableEntries(void) const
Get the routing table entries.
uint32_t interface
Interface index.
uint16_t m_ansn
Advertised Neighbor Set sequence number.
Abstract base class for IPv4 routing protocols.
void RemoveDuplicateTuple(const DuplicateTuple &tuple)
Removes a duplicate tuple from the Duplicate Set.
bool m_linkTupleTimerFirstTime
Flag to indicate if it is the first time the LinkTupleTimer fires.
Timer m_hnaTimer
Timer for the HNA message.
void HelloTimerExpire(void)
Sends a HELLO message and reschedules the HELLO timer.
void IncrementAnsn(void)
Increments the ANSN counter.
void RemoveAssociationTuple(const AssociationTuple &tuple)
Removes a host network association tuple to the Association Set.
std::vector< TopologyTuple > TopologySet
Topology Set type.
void PopulateTwoHopNeighborSet(const olsr::MessageHeader &msg, const olsr::MessageHeader::Hello &hello)
Updates the 2-hop Neighbor Set according to the information contained in a new received HELLO message...
Ipv4Address destAddr
Address of the destination node.
uint16_t GetMessageSequenceNumber(void)
Increments message sequence number and returns the new value.
void Clear(void)
Clears the routing table and frees the memory assigned to each one of its entries.
void ProcessTc(const olsr::MessageHeader &msg, const Ipv4Address &senderIface)
Processes a TC message following RFC 3626 specification.
void MprComputation(void)
Computates MPR set of a node following RFC 3626 hints.
const TopologySet & GetTopologySet(void) const
Gets the topology set.
void RemoveIfaceAssocTuple(const IfaceAssocTuple &tuple)
Removed an interface association tuple to the Interface Association Set.
Time m_hnaInterval
HNA messages' emission interval.
void AddTopologyTuple(const TopologyTuple &tuple)
Adds a topology tuple to the Topology Set.
void SetInterfaceExclusions(std::set< uint32_t > exceptions)
Set the interfaces to be excluded.
const OlsrState & GetOlsrState(void) const
Gets the underlying OLSR state object.
std::set< uint32_t > GetInterfaceExclusions(void) const
Get the excluded interfaces.
Ptr< Socket > m_recvSocket
Receiving socket.
virtual void NotifyInterfaceUp(uint32_t interface)
Time m_midInterval
MID messages' emission interval.
void SendTc(void)
Creates a new OLSR TC message which is buffered for being sent later on.
void PopulateMprSelectorSet(const olsr::MessageHeader &msg, const olsr::MessageHeader::Hello &hello)
Updates the MPR Selector Set according to the information contained in a new received HELLO message (...
Ptr< UniformRandomVariable > m_uniformRandomVariable
Provides uniform random variables.
uint8_t m_willingness
Willingness for forwarding packets on behalf of other nodes.
virtual void PrintRoutingTable(Ptr< OutputStreamWrapper > stream, Time::Unit unit=Time::S) const
Print the Routing Table entries.
void(* PacketTxRxTracedCallback)(const PacketHeader &header, const MessageList &messages)
TracedCallback signature for Packet transmit and receive events.
uint16_t m_messageSequenceNumber
Messages sequence number counter.
void RemoveTwoHopNeighborTuple(const TwoHopNeighborTuple &tuple)
Removes a 2-hop neighbor tuple from the 2-hop Neighbor Set.
void IfaceAssocTupleTimerExpire(Ipv4Address ifaceAddr)
Removes interface association tuple_ if expired.
a class to represent an Ipv4 address mask
olsr::MessageList m_queuedMessages
A list of pending messages which are buffered awaiting for being sent.
void RemoveHostNetworkAssociation(Ipv4Address networkAddr, Ipv4Mask netmask)
Removes the specified (networkAddr, netmask) tuple from the list of local HNA associations to be sent...
void(* TableChangeTracedCallback)(uint32_t size)
TracedCallback signature for routing table computation.
TracedCallback< uint32_t > m_routingTableChanged
Routing table chanes challback.
void MprSelTupleTimerExpire(Ipv4Address mainAddr)
Removes MPR selector tuple_ if expired.
void AddAssociationTuple(const AssociationTuple &tuple)
Adds a host network association tuple to the Association Set.
std::vector< MprSelectorTuple > MprSelectorSet
MPR Selector Set type.
Ipv4Address m_mainAddress
the node main address.
std::set< uint32_t > m_interfaceExclusions
Set of interfaces excluded by OSLR.
Forward calls to a chain of Callback.
void QueueMessage(const olsr::MessageHeader &message, Time delay)
Enques an OLSR message which will be sent with a delay of (0, delay].
void PopulateNeighborSet(const olsr::MessageHeader &msg, const olsr::MessageHeader::Hello &hello)
Updates the Neighbor Set according to the information contained in a new received HELLO message (foll...
void SendPacket(Ptr< Packet > packet, const MessageList &containedMessages)
Send an OLSR message.
uint32_t distance
Distance in hops to the destination.
Timer m_helloTimer
Timer for the HELLO message.
Callback< void, Ptr< const Packet >, const Ipv4Header &, Socket::SocketErrno > ErrorCallback
Callback for routing errors (e.g., no route found)
bool IsMyOwnAddress(const Ipv4Address &a) const
Check that address is one of my interfaces.
const TwoHopNeighborSet & GetTwoHopNeighbors(void) const
Get the two hop neighbors.
bool FindSendEntry(const RoutingTableEntry &entry, RoutingTableEntry &outEntry) const
Finds the appropriate entry which must be used in order to forward a data packet to a next hop (given...
void AddTwoHopNeighborTuple(const TwoHopNeighborTuple &tuple)
Adds a 2-hop neighbor tuple to the 2-hop Neighbor Set.
void AddMprSelectorTuple(const MprSelectorTuple &tuple)
Adds an MPR selector tuple to the MPR Selector Set.
Time m_helloInterval
HELLO messages' emission interval.
EventGarbageCollector m_events
Running events.
std::map< Ipv4Address, RoutingTableEntry > m_table
Data structure for the routing table.
void SetMainInterface(uint32_t interface)
Set the OLSR main address to the first address on the indicated interface.
#define NS_DEPRECATED_3_34
Tag for things deprecated in version ns-3.34.
void DupTupleTimerExpire(Ipv4Address address, uint16_t sequenceNumber)
Removes tuple if expired.
Timer m_tcTimer
Timer for the TC message.
uint32_t GetSize(void) const
Returns the routing table size.
bool Lookup(const Ipv4Address &dest, RoutingTableEntry &outEntry) const
Looks up an entry for the specified destination address.
void ProcessHna(const olsr::MessageHeader &msg, const Ipv4Address &senderIface)
Processes a HNA message following RFC 3626 specification.
Unit
The unit to use to interpret a number representing time.
void TcTimerExpire(void)
Sends a TC message (if there exists any MPR selector) and reschedules the TC timer.
virtual void DoDispose(void)
Destructor implementation.
void AddDuplicateTuple(const DuplicateTuple &tuple)
Adds a duplicate tuple to the Duplicate Set.
void RemoveTopologyTuple(const TopologyTuple &tuple)
Removes a topology tuple to the Topology Set.
virtual Ptr< Ipv4Route > RouteOutput(Ptr< Packet > p, const Ipv4Header &header, Ptr< NetDevice > oif, Socket::SocketErrno &sockerr)
Query routing cache for an existing route, for an outbound packet.