28 #define NS_LOG_APPEND_CONTEXT \
29 if (m_ipv4) { std::clog << "[node " << m_ipv4->GetObject<Node> ()->GetId () << "] "; }
33 #include "ns3/boolean.h"
34 #include "ns3/random-variable-stream.h"
35 #include "ns3/inet-socket-address.h"
36 #include "ns3/trace-source-accessor.h"
37 #include "ns3/udp-socket-factory.h"
38 #include "ns3/wifi-net-device.h"
39 #include "ns3/adhoc-wifi-mac.h"
40 #include "ns3/string.h"
41 #include "ns3/pointer.h"
92 return sizeof(int32_t);
107 os <<
"DeferredRouteOutputTag: output interface = " <<
m_oif;
123 ActiveRouteTimeout (
Seconds (3)),
126 NetTraversalTime (
Time ((2 * NetDiameter) * NodeTraversalTime)),
127 PathDiscoveryTime (
Time (2 * NetTraversalTime)),
128 MyRouteTimeout (
Time (2 *
std::max (PathDiscoveryTime, ActiveRouteTimeout))),
130 AllowedHelloLoss (2),
131 DeletePeriod (
Time (5 *
std::max (ActiveRouteTimeout, HelloInterval))),
133 BlackListTimeout (
Time (RreqRetries * NetTraversalTime)),
136 DestinationOnly (false),
137 GratuitousReply (true),
139 m_routingTable (DeletePeriod),
140 m_queue (MaxQueueLen, MaxQueueTime),
143 m_rreqIdCache (PathDiscoveryTime),
144 m_dpd (PathDiscoveryTime),
145 m_nb (HelloInterval),
148 m_htimer (
Timer::CANCEL_ON_DESTROY),
149 m_rreqRateLimitTimer (
Timer::CANCEL_ON_DESTROY),
150 m_rerrRateLimitTimer (
Timer::CANCEL_ON_DESTROY),
159 static TypeId tid =
TypeId (
"ns3::aodv::RoutingProtocol")
161 .AddConstructor<RoutingProtocol> ()
162 .AddAttribute (
"HelloInterval",
"HELLO messages emission interval.",
166 .AddAttribute (
"RreqRetries",
"Maximum number of retransmissions of RREQ to discover a route",
169 MakeUintegerChecker<uint32_t> ())
170 .AddAttribute (
"RreqRateLimit",
"Maximum number of RREQ per second.",
173 MakeUintegerChecker<uint32_t> ())
174 .AddAttribute (
"RerrRateLimit",
"Maximum number of RERR per second.",
177 MakeUintegerChecker<uint32_t> ())
178 .AddAttribute (
"NodeTraversalTime",
"Conservative estimate of the average one hop traversal time for packets and should include "
179 "queuing delays, interrupt processing times and transfer times.",
183 .AddAttribute (
"NextHopWait",
"Period of our waiting for the neighbour's RREP_ACK = 10 ms + NodeTraversalTime",
187 .AddAttribute (
"ActiveRouteTimeout",
"Period of time during which the route is considered to be valid",
191 .AddAttribute (
"MyRouteTimeout",
"Value of lifetime field in RREP generating by this node = 2 * max(ActiveRouteTimeout, PathDiscoveryTime)",
195 .AddAttribute (
"BlackListTimeout",
"Time for which the node is put into the blacklist = RreqRetries * NetTraversalTime",
199 .AddAttribute (
"DeletePeriod",
"DeletePeriod is intended to provide an upper bound on the time for which an upstream node A "
200 "can have a neighbor B as an active next hop for destination D, while B has invalidated the route to D."
201 " = 5 * max (HelloInterval, ActiveRouteTimeout)",
205 .AddAttribute (
"NetDiameter",
"Net diameter measures the maximum possible number of hops between two nodes in the network",
208 MakeUintegerChecker<uint32_t> ())
209 .AddAttribute (
"NetTraversalTime",
"Estimate of the average net traversal time = 2 * NodeTraversalTime * NetDiameter",
213 .AddAttribute (
"PathDiscoveryTime",
"Estimate of maximum time needed to find route in network = 2 * NetTraversalTime",
217 .AddAttribute (
"MaxQueueLen",
"Maximum number of packets that we allow a routing protocol to buffer.",
221 MakeUintegerChecker<uint32_t> ())
222 .AddAttribute (
"MaxQueueTime",
"Maximum time packets can be queued (in seconds)",
227 .AddAttribute (
"AllowedHelloLoss",
"Number of hello messages which may be loss for valid link.",
230 MakeUintegerChecker<uint16_t> ())
231 .AddAttribute (
"GratuitousReply",
"Indicates whether a gratuitous RREP should be unicast to the node originated route discovery.",
236 .AddAttribute (
"DestinationOnly",
"Indicates only the destination may respond to this RREQ.",
241 .AddAttribute (
"EnableHello",
"Indicates whether a hello messages enable.",
246 .AddAttribute (
"EnableBroadcast",
"Indicates whether a broadcast data packets forwarding enable.",
251 .AddAttribute (
"UniformRv",
252 "Access to the underlying UniformRandomVariable",
255 MakePointerChecker<UniformRandomVariable> ())
284 iter->first->Close ();
290 iter->first->Close ();
369 uint32_t iif = (oif ?
m_ipv4->GetInterfaceForDevice (oif) : -1);
393 if(!result || ((rt.GetFlag () !=
IN_SEARCH) && result))
416 int32_t iif =
m_ipv4->GetInterfaceForDevice (idev);
452 NS_LOG_DEBUG (
"Duplicated packet " << p->
GetUid () <<
" from " << origin <<
". Drop.");
457 if (lcb.
IsNull () ==
false)
460 lcb (p, header, iif);
465 NS_LOG_ERROR (
"Unable to deliver packet locally due to null callback " << p->
GetUid () <<
" from " << origin);
479 ucb (route, packet, header);
495 if (
m_ipv4->IsDestinationAddress (dst, iif))
504 if (lcb.
IsNull () ==
false)
507 lcb (p, header, iif);
511 NS_LOG_ERROR (
"Unable to deliver packet locally due to null callback " << p->
GetUid () <<
" from " << origin);
558 ucb (route, p, header);
571 NS_LOG_LOGIC (
"route not found to "<< dst <<
". Send RERR message.");
610 if (l3->GetNAddresses (i) > 1)
612 NS_LOG_WARN (
"AODV does not work with more then one address per each interface.");
646 if (l3->GetInterface (i)->GetArpCache ())
676 mac->TraceDisconnectWithoutContext (
"TxErrHeader",
708 NS_LOG_FUNCTION (
this <<
" interface " << i <<
" address " << address);
712 if (l3->GetNAddresses (i) == 1)
752 NS_LOG_LOGIC (
"AODV does not work with more then one address per each interface. Ignore added address");
770 unicastSocket->
Close ();
775 if (l3->GetNAddresses (i))
818 NS_LOG_LOGIC (
"Remove address not participating in AODV operation");
868 int32_t
interface =
m_ipv4->GetInterfaceForAddress (addr);
869 if (oif ==
m_ipv4->GetNetDevice (static_cast<uint32_t> (interface)))
1013 NS_ASSERT_MSG (
false,
"Received a packet from an unknown socket");
1015 NS_LOG_DEBUG (
"AODV node " <<
this <<
" received a AODV packet from " << sender <<
" to " << receiver);
1022 NS_LOG_DEBUG (
"AODV message " << packet->
GetUid () <<
" with unknown type received: " << tHeader.
Get () <<
". Drop");
1025 switch (tHeader.
Get ())
1072 NS_LOG_FUNCTION (
this <<
"sender " << sender <<
" receiver " << receiver);
1078 m_ipv4->GetAddress (
m_ipv4->GetInterfaceForAddress (receiver), 0),
1092 m_ipv4->GetAddress (
m_ipv4->GetInterfaceForAddress (receiver), 0),
1118 uint32_t
id = rreqHeader.
GetId ();
1150 m_ipv4->GetAddress (
m_ipv4->GetInterfaceForAddress (receiver), 0), hop,
1178 NS_LOG_DEBUG (
"Neighbor:" << src <<
" not found in routing table. Creating an entry");
1181 m_ipv4->GetAddress (
m_ipv4->GetInterfaceForAddress (receiver), 0),
1200 <<
" ID " << rreqHeader.
GetId ()
1201 <<
" to destination " << rreqHeader.
GetDst ());
1208 NS_LOG_DEBUG (
"Send reply since I am the destination");
1288 packet->AddHeader (tHeader);
1303 if (toDst.
GetHop () == 1)
1334 packetToDst->AddHeader (type);
1389 m_ipv4->GetAddress (
m_ipv4->GetInterfaceForAddress (receiver), 0), hop,
1398 if (!toDst.GetValidSeqNo ())
1403 else if ((int32_t (rrepHeader.
GetDstSeqno ()) - int32_t (toDst.GetSeqNo ())) > 0)
1410 if ((rrepHeader.
GetDstSeqno () == toDst.GetSeqNo ()) && (toDst.GetFlag () !=
VALID))
1415 else if ((rrepHeader.
GetDstSeqno () == toDst.GetSeqNo ()) && (hop < toDst.GetHop ()))
1458 toDst.InsertPrecursor (toOrigin.
GetNextHop ());
1511 m_ipv4->GetAddress (
m_ipv4->GetInterfaceForAddress (receiver), 0),
1519 toNeighbor.SetValidSeqNo (
true);
1520 toNeighbor.SetFlag (
VALID);
1521 toNeighbor.SetOutputDevice (
m_ipv4->GetNetDevice (
m_ipv4->GetInterfaceForAddress (receiver)));
1522 toNeighbor.SetInterface (
m_ipv4->GetAddress (
m_ipv4->GetInterfaceForAddress (receiver), 0));
1523 toNeighbor.SetHop (1);
1524 toNeighbor.SetNextHop (rrepHeader.
GetDst ());
1539 std::map<Ipv4Address, uint32_t> dstWithNextHopSrc;
1540 std::map<Ipv4Address, uint32_t> unreachable;
1542 std::pair<Ipv4Address, uint32_t> un;
1545 for (std::map<Ipv4Address, uint32_t>::const_iterator i =
1546 dstWithNextHopSrc.begin (); i != dstWithNextHopSrc.end (); ++i)
1548 if (i->first == un.first)
1550 unreachable.insert (un);
1555 std::vector<Ipv4Address> precursors;
1556 for (std::map<Ipv4Address, uint32_t>::const_iterator i = unreachable.begin ();
1557 i != unreachable.end ();)
1566 rerrHeader.
Clear ();
1605 NS_LOG_LOGIC (
"route discovery to " << dst <<
" has been attempted RreqRetries (" <<
RreqRetries <<
") times");
1608 NS_LOG_DEBUG (
"Route not found. Drop all packets with dst " << dst);
1620 NS_LOG_DEBUG (
"Route down. Stop search. Drop packet with destination " << dst);
1689 packet->AddHeader (tHeader);
1718 NS_LOG_DEBUG (
"Output device doesn't match. Dropped.");
1725 ucb (route, p, header);
1734 std::vector<Ipv4Address> precursors;
1735 std::map<Ipv4Address, uint32_t> unreachable;
1743 for (std::map<Ipv4Address, uint32_t>::const_iterator i = unreachable.begin (); i
1744 != unreachable.end ();)
1754 rerrHeader.
Clear ();
1772 unreachable.insert (std::make_pair (nextHop, toNextHop.
GetSeqNo ()));
1789 <<
"; suppressing RERR");
1803 NS_LOG_LOGIC (
"Unicast RERR to the source of the data transmission");
1835 if (precursors.empty ())
1848 <<
"; suppressing RERR");
1852 if (precursors.size () == 1)
1867 std::vector<Ipv4InterfaceAddress> ifaces;
1869 for (std::vector<Ipv4Address>::const_iterator i = precursors.begin (); i != precursors.end (); ++i)
1872 std::find (ifaces.begin (), ifaces.end (), toPrecursor.
GetInterface ()) == ifaces.end ())
1878 for (std::vector<Ipv4InterfaceAddress>::const_iterator i = ifaces.begin (); i != ifaces.end (); ++i)
1882 NS_LOG_LOGIC (
"Broadcast RERR message from interface " << i->GetLocal ());
UnicastForwardCallback GetUnicastForwardCallback() const
uint32_t RemoveHeader(Header &header)
Deserialize and remove the header from the internal buffer.
static TypeId GetTypeId(void)
Get the type ID.
void SendReplyAck(Ipv4Address neighbor)
Send RREP_ACK.
static Ipv4Mask GetOnes(void)
void InvalidateRoutesWithDst(std::map< Ipv4Address, uint32_t > const &unreachable)
Update routing entries with this destinations as follows:
Simulation virtual time values and global simulation resolution.
bool MarkLinkAsUnidirectional(Ipv4Address neighbor, Time blacklistTimeout)
Mark entry as unidirectional (e.g.
Ipv4Address GetIpv4(void) const
static Ipv4Address GetAny(void)
void SetOutputDevice(Ptr< NetDevice > dev)
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by "...
void SetStream(int64_t stream)
Specifies the stream number for this RNG stream.
uint16_t m_rreqCount
Number of RREQs used for RREQ rate control.
SocketErrno
Enumeration of the possible errors returned by a socket.
AttributeValue implementation for Boolean.
Ipv4Mask GetMask(void) const
Get the network mask.
Time MaxQueueTime
The maximum period of time that a routing protocol is allowed to buffer a packet for.
bool LookupRoute(Ipv4Address dst, RoutingTableEntry &rt)
Lookup routing table entry with destination address dst.
void Clear()
Delete all entries from routing table.
void SendTo(Ptr< Socket > socket, Ptr< Packet > packet, Ipv4Address destination)
RoutingTable m_routingTable
Routing table.
Ipv4Header GetIpv4Header() const
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Ipv4Address GetLocal(void) const
Get the local address.
bool GetBroadcastEnable() const
Hold variables of type string.
virtual bool SetAllowBroadcast(bool allowBroadcast)=0
Configure whether broadcast datagram transmissions are allowed.
void SetDesinationOnlyFlag(bool f)
a class to represent an Ipv4 address mask
Ptr< const AttributeAccessor > MakeBooleanAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
Tag used by AODV implementation.
void AddPacketTag(const Tag &tag) const
Add a packet tag.
uint32_t MaxQueueLen
The maximum number of packets that we allow a routing protocol to buffer.
Ptr< Ipv4 > m_ipv4
IP protocol.
bool Update(RoutingTableEntry &rt)
Update routing table.
virtual void PrintRoutingTable(Ptr< OutputStreamWrapper > stream) const
Print the Routing Table entries.
uint64_t GetUid(void) const
Returns the packet's Uid.
Timer m_ackTimer
RREP_ACK timer.
bool Forwarding(Ptr< const Packet > p, const Ipv4Header &header, UnicastForwardCallback ucb, ErrorCallback ecb)
If route exists and valid, forward packet.
bool IsNull(void) const
Check for null implementation.
void SetMaxQueueLen(uint32_t len)
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file...
void DelArpCache(Ptr< ArpCache >)
Don't use given ARP cache any more (interface is down)
void SendHello()
Send hello.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Time MilliSeconds(uint64_t value)
Construct a Time in the indicated unit.
virtual void NotifyRemoveAddress(uint32_t interface, Ipv4InterfaceAddress address)
virtual void DoDispose()
Destructor implementation.
int64_t AssignStreams(int64_t stream)
Assign a fixed random variable stream number to the random variables used by this model...
void SetMaxQueueLen(uint32_t len)
Timer m_rreqRateLimitTimer
RREQ rate limit timer.
bool IsMulticast(void) const
virtual void DoDispose(void)
Destructor implementation.
Ptr< NetDevice > GetOutputDevice() const
Time NetTraversalTime
Estimate of the average net traversal time.
Neighbors m_nb
Handle neighbors.
void GetPrecursors(std::vector< Ipv4Address > &prec) const
Inserts precursors in vector prec if they does not yet exist in vector.
void SetGratuitousReplyFlag(bool f)
TAG_BUFFER_INLINE uint32_t ReadU32(void)
static EventId Schedule(Time const &time, MEM mem_ptr, OBJ obj)
Schedule an event to expire at the relative time "time" is reached.
void SetLifeTime(Time lt)
uint32_t RreqRetries
Maximum number of retransmissions of RREQ with TTL = NetDiameter to discover a route.
Time m_lastBcastTime
Keep track of the last bcast time.
RequestQueue m_queue
A "drop-front" queue used by the routing layer to buffer packets to which it does not have a route...
bool Enqueue(QueueEntry &entry)
Push entry in queue, if there is no entry with the same packet and destination address in queue...
uint32_t m_seqNo
Request sequence number.
void SetInterface(int32_t oif)
void ScheduleRreqRetry(Ipv4Address dst)
To reduce congestion in a network, repeated attempts by a source node at route discovery for a single...
Ptr< Socket > FindSocketWithInterfaceAddress(Ipv4InterfaceAddress iface) const
Find unicast socket with local interface address iface.
a polymophic address class
bool IsRunning(void) const
Ptr< Ipv4Route > LoopbackRoute(const Ipv4Header &header, Ptr< NetDevice > oif) const
Create loopback route for given header.
Ptr< const AttributeChecker > MakeTimeChecker(const Time min, const Time max)
Helper to make a Time checker with bounded range.
void SetSource(Ipv4Address src)
void RecvAodv(Ptr< Socket > socket)
Receive and process control packet.
virtual void SetIpv4(Ptr< Ipv4 > ipv4)
Ptr< NetDevice > GetOutputDevice(void) const
bool InsertPrecursor(Ipv4Address id)
Insert precursor in precursor list if it doesn't yet exist in the list.
double GetSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit.
void Print(Ptr< OutputStreamWrapper > stream) const
Print routing table.
bool DestinationOnly
Indicates only the destination may respond to this RREQ.
void SetRreqCnt(uint8_t n)
void RecvReplyAck(Ipv4Address neighbor)
Receive RREP_ACK.
bool PeekPacketTag(Tag &tag) const
Search a matching tag and call Tag::Deserialize if it is found.
bool IsDuplicate(Ptr< const Packet > p, const Ipv4Header &header)
Check that the packet is duplicated. If not, save information about this packet.
void SendPacketFromQueue(Ipv4Address dst, Ptr< Ipv4Route > route)
Forward packet from route request queue.
void DeferredRouteOutput(Ptr< const Packet > p, const Ipv4Header &header, UnicastForwardCallback ucb, ErrorCallback ecb)
Queue packet and send route request.
bool IsMyOwnAddress(Ipv4Address src)
Check that packet is send from own interface.
Ptr< const AttributeAccessor > MakePointerAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
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 RecvReply(Ptr< Packet > p, Ipv4Address my, Ipv4Address src)
Receive RREP.
void DeleteAllRoutesFromInterface(Ipv4InterfaceAddress iface)
Delete all route from interface with address iface.
void HelloTimerExpire()
Schedule next send of hello message.
AttributeValue implementation for Time.
void Schedule(void)
Schedule a new event using the currently-configured delay, function, and arguments.
Ipv4Address GetNextHop() const
void SetGateway(Ipv4Address gw)
bool UpdateRouteLifeTime(Ipv4Address addr, Time lt)
Set lifetime field in routing table entry to the maximum of existing lifetime and lt...
Hold an unsigned integer type.
void UpdateRouteToNeighbor(Ipv4Address sender, Ipv4Address receiver)
Update neighbor record.
Time HelloInterval
Every HelloInterval the node checks whether it has sent a broadcast within the last HelloInterval...
TAG_BUFFER_INLINE void WriteU32(uint32_t v)
bool GetDesinationOnlyFlag() const
bool IsBroadcast(void) const
void SetSeqNo(uint32_t sn)
uint16_t RreqRateLimit
Maximum number of RREQ per second.
void SetValidSeqNo(bool s)
int32_t m_oif
Positive if output device is fixed in RouteOutput.
virtual void NotifyAddAddress(uint32_t interface, Ipv4InterfaceAddress address)
Hold together all Wifi-related objects.
Callback< R > MakeCallback(R(T::*memPtr)(void), OBJ objPtr)
static TypeId GetTypeId(void)
void SetRecvCallback(Callback< void, Ptr< Socket > >)
Notify application when new data is available to be read.
Time GetMaxQueueTime() const
static Ptr< Socket > CreateSocket(Ptr< Node > node, TypeId tid)
This method wraps the creation of sockets that is performed on a given node by a SocketFactory specif...
void SendReplyByIntermediateNode(RoutingTableEntry &toDst, RoutingTableEntry &toOrigin, bool gratRep)
Send RREP by intermediate node.
Ipv4Address GetSource(void) const
void AddArpCache(Ptr< ArpCache >)
Add ARP cache to be used to allow layer 2 notifications processing.
Ptr< const Packet > GetPacket() const
Ipv4InterfaceAddress GetInterface() const
Callback< void, WifiMacHeader const & > GetTxErrorCallback() const
Get callback to ProcessTxError.
void SetDelay(const Time &delay)
void DropPacketWithDst(Ipv4Address dst)
Remove all packets with destination IP address dst.
#define NS_LOG_LOGIC(msg)
Use NS_LOG to output a message of level LOG_LOGIC.
uint16_t m_rerrCount
Number of RERRs used for RERR rate control.
Ipv4Address GetGateway(void) const
static Ipv4Address GetBroadcast(void)
void SetMaxQueueTime(Time t)
void GetListOfDestinationWithNextHop(Ipv4Address nextHop, std::map< Ipv4Address, uint32_t > &unreachable)
Lookup routing entries with next hop Address dst and not empty list of precursors.
bool GetHelloEnable() const
void SetInterface(Ipv4InterfaceAddress iface)
Ptr< Packet > Copy(void) const
performs a COW copy of the packet.
void SendRerrWhenNoRouteToForward(Ipv4Address dst, uint32_t dstSeqNo, Ipv4Address origin)
Send RERR message when no route to forward input packet.
tag a set of bytes in a packet
void Clear()
Remove all entries.
void SendRerrWhenBreaksLinkToNextHop(Ipv4Address nextHop)
Initiate RERR.
Time NodeTraversalTime
NodeTraversalTime is a conservative estimate of the average one hop traversal time for packets and sh...
Implement the Ipv4 layer.
virtual int Bind(const Address &address)=0
Allocate a local endpoint for this socket.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
std::map< Ptr< Socket >, Ipv4InterfaceAddress > m_socketSubnetBroadcastAddresses
Raw subnet directed broadcast socket per each IP interface, map socket -> iface address (IP + mask) ...
static InetSocketAddress ConvertFrom(const Address &address)
Returns an InetSocketAddress which corresponds to the input Address.
void SetFlag(RouteFlags flag)
bool GetGratuitousReplyFlag() const
Ptr< const AttributeChecker > MakeBooleanChecker(void)
Time ActiveRouteTimeout
Period of time during which the route is considered to be valid.
Ptr< Socket > FindSubnetBroadcastSocketWithInterfaceAddress(Ipv4InterfaceAddress iface) const
Find subnet directed broadcast socket with local interface address iface.
void RecvRequest(Ptr< Packet > p, Ipv4Address receiver, Ipv4Address src)
Receive RREQ.
std::map< Ptr< Socket >, Ipv4InterfaceAddress > m_socketAddresses
Raw unicast socket per each IP interface, map socket -> iface address (IP + mask) ...
static EventId ScheduleNow(MEM mem_ptr, OBJ obj)
Schedule an event to expire Now.
Ptr< const AttributeAccessor > MakeTimeAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
uint32_t GetSerializedSize() const
void Update(Ipv4Address addr, Time expire)
Update expire time for entry with address addr, if it exists, else add new entry. ...
static Time Now(void)
Return the current simulation virtual time.
void SetOutputDevice(Ptr< NetDevice > outputDevice)
Equivalent in Linux to dst_entry.dev.
void ProcessHello(RrepHeader const &rrepHeader, Ipv4Address receiverIfaceAddr)
Process hello message.
static Ipv4Address GetLoopback(void)
virtual void NotifyInterfaceUp(uint32_t interface)
DuplicatePacketDetection m_dpd
Handle duplicated broadcast/multicast packets.
int32_t GetInterface() const
bool EnableBroadcast
Indicates whether a a broadcast data packets forwarding enable.
virtual void BindToNetDevice(Ptr< NetDevice > netdevice)
Bind a socket to specific device.
void RecvError(Ptr< Packet > p, Ipv4Address src)
Receive RERR from node with address src.
void RreqRateLimitTimerExpire()
Reset RREQ count and schedule RREQ rate limit timer with delay 1 sec.
#define NS_ASSERT_MSG(condition, message)
At runtime, in debugging builds, if this condition is not true, the program prints the message to out...
void Serialize(TagBuffer i) const
Time PathDiscoveryTime
Estimate of maximum time needed to find route in network.
Ipv4Address GetDestination(void) const
Time BlackListTimeout
Time for which the node is put into the blacklist.
void SetHop(uint16_t hop)
Ipv4 addresses are stored in host order in this class.
Time NextHopWait
Period of our waiting for the neighbour's RREP_ACK.
Time DeletePeriod
DeletePeriod is intended to provide an upper bound on the time for which an upstream node A can have ...
Ipv4Address GetBroadcast(void) const
Get the broadcast address.
virtual void NotifyInterfaceDown(uint32_t interface)
virtual ~RoutingProtocol()
Time MyRouteTimeout
Value of lifetime field in RREP generating by this node.
a class to store IPv4 address information on an interface
#define NS_LOG_WARN(msg)
Use NS_LOG to output a message of level LOG_WARN.
uint32_t GetSeqNo() const
void SetQueueTimeout(Time t)
bool AddRoute(RoutingTableEntry &r)
Add routing table entry if it doesn't yet exist in routing table.
bool RemovePacketTag(Tag &tag)
Remove a packet tag.
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Time Seconds(double value)
Construct a Time in the indicated unit.
void Cancel(void)
Cancel the currently-running event if there is one.
uint32_t AllowedHelloLoss
Number of hello messages which may be loss for valid link.
void SendRerrMessage(Ptr< Packet > packet, std::vector< Ipv4Address > precursors)
Forward RERR.
bool IsDuplicate(Ipv4Address addr, uint32_t id)
Check that entry (addr, id) exists in cache. Add entry, if it doesn't exist.
void SetCallback(Callback< void, Ipv4Address > cb)
Handle link failure callback.
void Print(std::ostream &os) const
void SendReply(RreqHeader const &rreqHeader, RoutingTableEntry const &toOrigin)
Send RREP.
Abstract base class for IPv4 routing protocols.
void SetNextHop(Ipv4Address nextHop)
uint32_t NetDiameter
Net diameter measures the maximum possible number of hops between two nodes in the network...
Timer m_rerrRateLimitTimer
RERR rate limit timer.
virtual int SendTo(Ptr< Packet > p, uint32_t flags, const Address &toAddress)=0
Send data to a specified peer.
void AckTimerExpire(Ipv4Address neighbor, Time blacklistTimeout)
Mark link to neighbor node as unidirectional for blacklistTimeout.
std::map< Ipv4Address, Timer > m_addressReqTimer
Map IP address + RREQ timer.
Ptr< Ipv4Route > GetRoute() const
Time MicroSeconds(uint64_t value)
Construct a Time in the indicated unit.
bool GratuitousReply
Indicates whether a gratuitous RREP should be unicast to the node originated route discovery...
#define NS_LOG_ERROR(msg)
Use NS_LOG to output a message of level LOG_ERROR.
uint16_t RerrRateLimit
Maximum number of REER per second.
Ptr< UniformRandomVariable > m_uniformRandomVariable
Provides uniform random variables.
void SendRequest(Ipv4Address dst)
Send RREQ.
bool Dequeue(Ipv4Address dst, QueueEntry &entry)
Return first found (the earliest) entry for given destination.
void RerrRateLimitTimerExpire()
Reset RERR count and schedule RERR rate limit timer with delay 1 sec.
virtual Ptr< Packet > RecvFrom(uint32_t maxSize, uint32_t flags, Address &fromAddress)=0
Read a single packet from the socket and retrieve the sender address.
DeferredRouteOutputTag(int32_t o=-1)
IdCache m_rreqIdCache
Handle duplicated RREQ.
void RouteRequestTimerExpire(Ipv4Address dst)
Handle route discovery process.
TypeId GetInstanceTypeId() const
Get the most derived TypeId for this Object.
void Start()
Start protocol operation.
void SetHelloEnable(bool f)
virtual int Close(void)=0
Close a socket.
bool LookupValidRoute(Ipv4Address dst, RoutingTableEntry &rt)
Lookup route in VALID state.
Time GetDelayLeft(void) const
static TypeId GetTypeId()
This policy cancels the event from the destructor of the Timer to verify that the event has already e...
void SetAttribute(std::string name, const AttributeValue &value)
Set a single attribute, raising fatal errors if unsuccessful.
bool IsUnidirectional() const
void SetBroadcastEnable(bool f)
bool DeleteRoute(Ipv4Address dst)
Delete routing table entry with destination address dst, if it exists.
Ptr< const AttributeAccessor > MakeUintegerAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
void Purge()
Delete all outdated entries and invalidate valid entry if Lifetime is expired.
a unique identifier for an interface.
Timer m_htimer
Hello timer.
Ptr< NetDevice > m_lo
Loopback device used to defer RREQ until packet will be fully formed.
RouteFlags GetFlag() const
void Deserialize(TagBuffer i)
uint32_t m_requestId
Broadcast ID.
Ipv4Address GetDestination() const
TypeId SetParent(TypeId tid)
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.
uint8_t GetRreqCnt() const
static Time GetMaximumSimulationTime(void)
Get the maximum representable simulation time.
std::ostream * GetStream(void)
Return a pointer to an ostream previously set in the wrapper.
uint32_t GetMaxQueueLen() const
void AddHeader(const Header &header)
Add header to this packet.
void SetDestination(Ipv4Address dest)
void ScheduleTimer()
Schedule m_ntimer.
bool GetValidSeqNo() const
static const uint32_t AODV_PORT
UDP Port for AODV control traffic.
bool EnableHello
Indicates whether a hello messages enable.