16#define NS_LOG_APPEND_CONTEXT \
19 std::clog << "[node " << m_ipv4->GetObject<Node>()->GetId() << "] "; \
24#include "ns3/adhoc-wifi-mac.h"
25#include "ns3/boolean.h"
26#include "ns3/inet-socket-address.h"
28#include "ns3/pointer.h"
29#include "ns3/random-variable-stream.h"
30#include "ns3/string.h"
31#include "ns3/trace-source-accessor.h"
32#include "ns3/udp-header.h"
33#include "ns3/udp-l4-protocol.h"
34#include "ns3/udp-socket-factory.h"
35#include "ns3/wifi-mpdu.h"
36#include "ns3/wifi-net-device.h"
76 static TypeId tid =
TypeId(
"ns3::aodv::DeferredRouteOutputTag")
121 void Print(std::ostream& os)
const override
123 os <<
"DeferredRouteOutputTag: output interface = " <<
m_oif;
142 m_activeRouteTimeout(
Seconds(3)),
145 m_netTraversalTime(
Time((2 * m_netDiameter) * m_nodeTraversalTime)),
146 m_pathDiscoveryTime(
Time(2 * m_netTraversalTime)),
147 m_myRouteTimeout(
Time(2 *
std::max(m_pathDiscoveryTime, m_activeRouteTimeout))),
149 m_allowedHelloLoss(2),
150 m_deletePeriod(
Time(5 *
std::max(m_activeRouteTimeout, m_helloInterval))),
152 m_blackListTimeout(
Time(m_rreqRetries * m_netTraversalTime)),
155 m_destinationOnly(false),
156 m_gratuitousReply(true),
157 m_enableHello(false),
158 m_routingTable(m_deletePeriod),
159 m_queue(m_maxQueueLen, m_maxQueueTime),
162 m_rreqIdCache(m_pathDiscoveryTime),
163 m_dpd(m_pathDiscoveryTime),
164 m_nb(m_helloInterval),
167 m_htimer(
Timer::CANCEL_ON_DESTROY),
168 m_rreqRateLimitTimer(
Timer::CANCEL_ON_DESTROY),
169 m_rerrRateLimitTimer(
Timer::CANCEL_ON_DESTROY),
179 TypeId(
"ns3::aodv::RoutingProtocol")
181 .SetGroupName(
"Aodv")
183 .AddAttribute(
"HelloInterval",
184 "HELLO messages emission interval.",
188 .AddAttribute(
"TtlStart",
189 "Initial TTL value for RREQ.",
193 .AddAttribute(
"TtlIncrement",
194 "TTL increment for each attempt using the expanding ring search for RREQ "
199 .AddAttribute(
"TtlThreshold",
200 "Maximum TTL value for expanding ring search, TTL = NetDiameter is used "
201 "beyond this value.",
205 .AddAttribute(
"TimeoutBuffer",
206 "Provide a buffer for the timeout.",
210 .AddAttribute(
"RreqRetries",
211 "Maximum number of retransmissions of RREQ to discover a route",
215 .AddAttribute(
"RreqRateLimit",
216 "Maximum number of RREQ per second.",
220 .AddAttribute(
"RerrRateLimit",
221 "Maximum number of RERR per second.",
225 .AddAttribute(
"NodeTraversalTime",
226 "Conservative estimate of the average one hop traversal time for packets "
227 "and should include "
228 "queuing delays, interrupt processing times and transfer times.",
234 "Period of our waiting for the neighbour's RREP_ACK = 10 ms + NodeTraversalTime",
238 .AddAttribute(
"ActiveRouteTimeout",
239 "Period of time during which the route is considered to be valid",
243 .AddAttribute(
"MyRouteTimeout",
244 "Value of lifetime field in RREP generating by this node = 2 * "
245 "max(ActiveRouteTimeout, PathDiscoveryTime)",
249 .AddAttribute(
"BlackListTimeout",
250 "Time for which the node is put into the blacklist = RreqRetries * "
255 .AddAttribute(
"DeletePeriod",
256 "DeletePeriod is intended to provide an upper bound on the time for "
257 "which an upstream node A "
258 "can have a neighbor B as an active next hop for destination D, while B "
259 "has invalidated the route to D."
260 " = 5 * max (HelloInterval, ActiveRouteTimeout)",
264 .AddAttribute(
"NetDiameter",
265 "Net diameter measures the maximum possible number of hops between two "
266 "nodes in the network",
272 "Estimate of the average net traversal time = 2 * NodeTraversalTime * NetDiameter",
278 "Estimate of maximum time needed to find route in network = 2 * NetTraversalTime",
282 .AddAttribute(
"MaxQueueLen",
283 "Maximum number of packets that we allow a routing protocol to buffer.",
288 .AddAttribute(
"MaxQueueTime",
289 "Maximum time packets can be queued (in seconds)",
294 .AddAttribute(
"AllowedHelloLoss",
295 "Number of hello messages which may be loss for valid link.",
299 .AddAttribute(
"GratuitousReply",
300 "Indicates whether a gratuitous RREP should be unicast to the node "
301 "originated route discovery.",
306 .AddAttribute(
"DestinationOnly",
307 "Indicates only the destination may respond to this RREQ.",
312 .AddAttribute(
"EnableHello",
313 "Indicates whether a hello messages enable.",
318 .AddAttribute(
"EnableBroadcast",
319 "Indicates whether a broadcast data packets forwarding enable.",
324 .AddAttribute(
"UniformRv",
325 "Access to the underlying UniformRandomVariable",
356 iter->first->Close();
363 iter->first->Close();
373 <<
"; Time: " <<
Now().
As(unit)
375 <<
", AODV Routing table" << std::endl;
378 *stream->GetStream() << std::endl;
431 NS_LOG_DEBUG(
"Exist route to " << route->GetDestination() <<
" from interface "
432 << route->GetSource());
433 if (oif && route->GetOutputDevice() != oif)
450 if (!p->PeekPacketTag(tag))
452 p->AddPacketTag(tag);
470 NS_LOG_LOGIC(
"Add packet " << p->GetUid() <<
" to queue. Protocol "
510 if (p->PeekPacketTag(tag))
539 NS_LOG_DEBUG(
"Duplicated packet " << p->GetUid() <<
" from " << origin
553 NS_LOG_ERROR(
"Unable to deliver packet locally due to null callback "
554 << p->GetUid() <<
" from " << origin);
564 p->PeekHeader(udpHeader);
578 ucb(route, packet, header);
582 NS_LOG_DEBUG(
"No route to forward broadcast. Drop packet " << p->GetUid());
587 NS_LOG_DEBUG(
"TTL exceeded. Drop packet " << p->GetUid());
611 NS_LOG_ERROR(
"Unable to deliver packet locally due to null callback "
612 << p->GetUid() <<
" from " << origin);
646 NS_LOG_LOGIC(route->GetSource() <<
" forwarding to " << dst <<
" from " << origin
647 <<
" packet " << p->GetUid());
671 ucb(route, p, header);
679 NS_LOG_DEBUG(
"Drop packet " << p->GetUid() <<
" because no route to forward it.");
684 NS_LOG_LOGIC(
"route not found to " << dst <<
". Send RERR message.");
685 NS_LOG_DEBUG(
"Drop packet " << p->GetUid() <<
" because no route to forward it.");
723 if (l3->GetNAddresses(i) > 1)
725 NS_LOG_WARN(
"AODV does not work with more then one address per each interface.");
737 socket->BindToNetDevice(l3->GetNetDevice(i));
739 socket->SetAllowBroadcast(
true);
740 socket->SetIpRecvTtl(
true);
747 socket->BindToNetDevice(l3->GetNetDevice(i));
749 socket->SetAllowBroadcast(
true);
750 socket->SetIpRecvTtl(
true);
765 if (l3->GetInterface(i)->GetArpCache())
782 mac->TraceConnectWithoutContext(
"DroppedMpdu",
806 mac->TraceDisconnectWithoutContext(
"DroppedMpdu",
844 if (l3->GetNAddresses(i) == 1)
859 socket->BindToNetDevice(l3->GetNetDevice(i));
861 socket->SetAllowBroadcast(
true);
868 socket->BindToNetDevice(l3->GetNetDevice(i));
870 socket->SetAllowBroadcast(
true);
871 socket->SetIpRecvTtl(
true);
890 NS_LOG_LOGIC(
"AODV does not work with more then one address per each interface. Ignore "
909 unicastSocket->Close();
914 if (l3->GetNAddresses(i))
923 socket->BindToNetDevice(l3->GetNetDevice(i));
925 socket->SetAllowBroadcast(
true);
926 socket->SetIpRecvTtl(
true);
933 socket->BindToNetDevice(l3->GetNetDevice(i));
935 socket->SetAllowBroadcast(
true);
936 socket->SetIpRecvTtl(
true);
963 NS_LOG_LOGIC(
"Remove address not participating in AODV operation");
1015 rt->SetSource(addr);
1022 rt->SetSource(j->second.GetLocal());
1026 rt->SetOutputDevice(
m_lo);
1132 packet->AddPacketTag(tag);
1133 packet->AddHeader(rreqHeader);
1135 packet->AddHeader(tHeader);
1186 uint16_t backoffFactor = rt.
GetRreqCnt() - 1;
1187 NS_LOG_LOGIC(
"Applying binary exponential backoff factor " << backoffFactor);
1199 Ptr<Packet> packet = socket->RecvFrom(sourceAddress);
1215 NS_ASSERT_MSG(
false,
"Received a packet from an unknown socket");
1217 NS_LOG_DEBUG(
"AODV node " <<
this <<
" received a AODV packet from " << sender <<
" to "
1222 packet->RemoveHeader(tHeader);
1225 NS_LOG_DEBUG(
"AODV message " << packet->GetUid() <<
" with unknown type received: "
1226 << tHeader.
Get() <<
". Drop");
1229 switch (tHeader.
Get())
1272 NS_LOG_FUNCTION(
this <<
"sender " << sender <<
" receiver " << receiver);
1317 p->RemoveHeader(rreqHeader);
1401 NS_LOG_DEBUG(
"Neighbor:" << src <<
" not found in routing table. Creating an entry");
1427 NS_LOG_LOGIC(receiver <<
" receive RREQ with hop count "
1429 << rreqHeader.
GetId() <<
" to destination " << rreqHeader.
GetDst());
1481 p->RemovePacketTag(tag);
1484 NS_LOG_DEBUG(
"TTL exceeded. Drop RREQ origin " << src <<
" destination " << dst);
1495 packet->AddPacketTag(ttl);
1496 packet->AddHeader(rreqHeader);
1498 packet->AddHeader(tHeader);
1541 packet->AddPacketTag(tag);
1542 packet->AddHeader(rrepHeader);
1544 packet->AddHeader(tHeader);
1582 packet->AddPacketTag(tag);
1583 packet->AddHeader(rrepHeader);
1585 packet->AddHeader(tHeader);
1602 packetToDst->AddPacketTag(gratTag);
1603 packetToDst->AddHeader(gratRepHeader);
1605 packetToDst->AddHeader(type);
1608 NS_LOG_LOGIC(
"Send gratuitous RREP " << packet->GetUid());
1622 packet->AddPacketTag(tag);
1623 packet->AddHeader(h);
1624 packet->AddHeader(typeHeader);
1637 p->RemoveHeader(rrepHeader);
1752 p->RemovePacketTag(tag);
1755 NS_LOG_DEBUG(
"TTL exceeded. Drop RREP destination " << dst <<
" origin "
1763 packet->AddPacketTag(ttl);
1764 packet->AddHeader(rrepHeader);
1766 packet->AddHeader(tHeader);
1833 p->RemoveHeader(rerrHeader);
1834 std::map<Ipv4Address, uint32_t> dstWithNextHopSrc;
1835 std::map<Ipv4Address, uint32_t> unreachable;
1837 std::pair<Ipv4Address, uint32_t> un;
1840 for (
auto i = dstWithNextHopSrc.begin(); i != dstWithNextHopSrc.end(); ++i)
1842 if (i->first == un.first)
1844 unreachable.insert(un);
1849 std::vector<Ipv4Address> precursors;
1850 for (
auto i = unreachable.begin(); i != unreachable.end();)
1858 packet->AddPacketTag(tag);
1859 packet->AddHeader(rerrHeader);
1860 packet->AddHeader(typeHeader);
1878 packet->AddPacketTag(tag);
1879 packet->AddHeader(rerrHeader);
1880 packet->AddHeader(typeHeader);
1905 NS_LOG_LOGIC(
"route discovery to " << dst <<
" has been attempted RreqRetries ("
1910 NS_LOG_DEBUG(
"Route not found. Drop all packets with dst " << dst);
1922 NS_LOG_DEBUG(
"Route down. Stop search. Drop packet with destination " << dst);
1995 packet->AddPacketTag(tag);
1996 packet->AddHeader(helloHeader);
1998 packet->AddHeader(tHeader);
2023 if (p->RemovePacketTag(tag) && tag.
GetInterface() != -1 &&
2034 ucb(route, p, header);
2043 std::vector<Ipv4Address> precursors;
2044 std::map<Ipv4Address, uint32_t> unreachable;
2054 for (
auto i = unreachable.begin(); i != unreachable.end();)
2063 packet->AddPacketTag(tag);
2064 packet->AddHeader(rerrHeader);
2065 packet->AddHeader(typeHeader);
2083 packet->AddPacketTag(tag);
2084 packet->AddHeader(rerrHeader);
2085 packet->AddHeader(typeHeader);
2088 unreachable.insert(std::make_pair(nextHop, toNextHop.
GetSeqNo()));
2115 packet->AddPacketTag(tag);
2116 packet->AddHeader(rerrHeader);
2122 NS_LOG_LOGIC(
"Unicast RERR to the source of the data transmission");
2153 if (precursors.empty())
2170 if (precursors.size() == 1)
2185 precursors.front());
2193 std::vector<Ipv4InterfaceAddress> ifaces;
2195 for (
auto i = precursors.begin(); i != precursors.end(); ++i)
2198 std::find(ifaces.begin(), ifaces.end(), toPrecursor.
GetInterface()) == ifaces.end())
2204 for (
auto i = ifaces.begin(); i != ifaces.end(); ++i)
2208 NS_LOG_LOGIC(
"Broadcast RERR message from interface " << i->GetLocal());
2275 NS_LOG_DEBUG(
"Starting at time " << startTime <<
"ms");
a polymophic address class
Wifi MAC high model for an ad-hoc Wifi MAC.
bool IsNull() const
Check for null implementation.
Ipv4Address GetIpv4() const
static InetSocketAddress ConvertFrom(const Address &address)
Returns an InetSocketAddress which corresponds to the input Address.
Ipv4 addresses are stored in host order in this class.
static Ipv4Address GetLoopback()
static Ipv4Address GetBroadcast()
virtual int32_t GetInterfaceForAddress(Ipv4Address address) const =0
Return the interface number of the interface that has been assigned the specified IP address.
virtual bool IsForwarding(uint32_t interface) const =0
virtual Ipv4InterfaceAddress GetAddress(uint32_t interface, uint32_t addressIndex) const =0
Because addresses can be removed, the addressIndex is not guaranteed to be static across calls to thi...
virtual Ptr< NetDevice > GetNetDevice(uint32_t interface)=0
virtual bool IsDestinationAddress(Ipv4Address address, uint32_t iif) const =0
Determine whether address and interface corresponding to received packet can be accepted for local de...
virtual int32_t GetInterfaceForDevice(Ptr< const NetDevice > device) const =0
virtual uint32_t GetNInterfaces() const =0
a class to store IPv4 address information on an interface
Ipv4Mask GetMask() const
Get the network mask.
Ipv4Address GetLocal() const
Get the local address.
Ipv4Address GetBroadcast() const
Get the broadcast address.
Implement the IPv4 layer.
a class to represent an Ipv4 address mask
static Ipv4Mask GetOnes()
Abstract base class for IPv4 routing protocols.
Ptr< T > GetObject() const
Get a pointer to the requested aggregated Object.
virtual void DoInitialize()
Initialize() implementation.
virtual void DoDispose()
Destructor implementation.
Smart pointer class similar to boost::intrusive_ptr.
static EventId Schedule(const Time &delay, FUNC f, Ts &&... args)
Schedule an event to expire after delay.
static Time Now()
Return the current simulation virtual time.
static EventId ScheduleNow(FUNC f, Ts &&... args)
Schedule an event to expire Now.
static Time GetMaximumSimulationTime()
Get the maximum representable simulation time.
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...
SocketErrno
Enumeration of the possible errors returned by a socket.
This class implements a tag that carries the socket-specific TTL of a packet to the IP layer.
void SetTtl(uint8_t ttl)
Set the tag's TTL.
uint8_t GetTtl() const
Get the tag's TTL.
Hold variables of type string.
TAG_BUFFER_INLINE uint32_t ReadU32()
TAG_BUFFER_INLINE void WriteU32(uint32_t v)
tag a set of bytes in a packet
Simulation virtual time values and global simulation resolution.
TimeWithUnit As(const Unit unit=Time::AUTO) const
Attach a unit to a Time, to facilitate output in a specific unit.
Unit
The unit to use to interpret a number representing time.
A simple virtual Timer class.
void SetDelay(const Time &delay)
Time GetDelayLeft() const
void SetArguments(Ts... args)
@ CANCEL_ON_DESTROY
This policy cancels the event from the destructor of the Timer or from Suspend().
void Cancel()
Cancel the currently-running event if there is one.
void Schedule()
Schedule a new event using the currently-configured delay, function, and arguments.
a unique identifier for an interface.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
static const uint8_t PROT_NUMBER
protocol number (0x11)
static TypeId GetTypeId()
Get the type ID.
Hold an unsigned integer type.
Hold together all Wifi-related objects.
Tag used by AODV implementation.
uint32_t GetSerializedSize() const override
TypeId GetInstanceTypeId() const override
Get the most derived TypeId for this Object.
static TypeId GetTypeId()
Get the type ID.
void Deserialize(TagBuffer i) override
int32_t GetInterface() const
Get the output interface.
int32_t m_oif
Positive if output device is fixed in RouteOutput.
void SetInterface(int32_t oif)
Set the output interface.
void Serialize(TagBuffer i) const override
DeferredRouteOutputTag(int32_t o=-1)
Constructor.
void Print(std::ostream &os) const override
bool IsDuplicate(Ptr< const Packet > p, const Ipv4Header &header)
Check if the packet is a duplicate.
bool IsDuplicate(Ipv4Address addr, uint32_t id)
Check that entry (addr, id) exists in cache.
void ScheduleTimer()
Schedule m_ntimer.
void Clear()
Remove all entries.
void Update(Ipv4Address addr, Time expire)
Update expire time for entry with address addr, if it exists, else add new entry.
Callback< void, const WifiMacHeader & > GetTxErrorCallback() const
Get callback to ProcessTxError.
void SetCallback(Callback< void, Ipv4Address > cb)
Set link failure callback.
void DelArpCache(Ptr< ArpCache > a)
Don't use given ARP cache any more (interface is down)
void AddArpCache(Ptr< ArpCache > a)
Add ARP cache to be used to allow layer 2 notifications processing.
Ipv4Header GetIpv4Header() const
Get IPv4 header.
Ptr< const Packet > GetPacket() const
Get packet from entry.
UnicastForwardCallback GetUnicastForwardCallback() const
Get unicast forward callback.
bool Dequeue(Ipv4Address dst, QueueEntry &entry)
Return first found (the earliest) entry for given destination.
void SetMaxQueueLen(uint32_t len)
Set maximum queue length.
void SetQueueTimeout(Time t)
Set queue timeout.
void DropPacketWithDst(Ipv4Address dst)
Remove all packets with destination IP address dst.
bool Enqueue(QueueEntry &entry)
Push entry in queue, if there is no entry with the same packet and destination address in queue.
Ptr< Ipv4Route > LoopbackRoute(const Ipv4Header &header, Ptr< NetDevice > oif) const
Create loopback route for given header.
uint32_t m_requestId
Broadcast ID.
void RecvAodv(Ptr< Socket > socket)
Receive and process control packet.
void UpdateRouteToNeighbor(Ipv4Address sender, Ipv4Address receiver)
Update neighbor record.
Timer m_rerrRateLimitTimer
RERR rate limit timer.
Time m_lastBcastTime
Keep track of the last bcast time.
void RecvReply(Ptr< Packet > p, Ipv4Address my, Ipv4Address src)
Receive RREP.
bool m_enableBroadcast
Indicates whether a a broadcast data packets forwarding enable.
void SendHello()
Send hello.
bool GetBroadcastEnable() const
Get broadcast enable flag.
bool UpdateRouteLifeTime(Ipv4Address addr, Time lt)
Set lifetime field in routing table entry to the maximum of existing lifetime and lt,...
void RerrRateLimitTimerExpire()
Reset RERR count and schedule RERR rate limit timer with delay 1 sec.
Time m_blackListTimeout
Time for which the node is put into the blacklist.
void RecvReplyAck(Ipv4Address neighbor)
Receive RREP_ACK.
std::map< Ptr< Socket >, Ipv4InterfaceAddress > m_socketSubnetBroadcastAddresses
Raw subnet directed broadcast socket per each IP interface, map socket -> iface address (IP.
Time m_maxQueueTime
The maximum period of time that a routing protocol is allowed to buffer a packet for.
Time m_activeRouteTimeout
Period of time during which the route is considered to be valid.
std::map< Ipv4Address, Timer > m_addressReqTimer
Map IP address + RREQ timer.
uint32_t GetMaxQueueLen() const
Get the maximum queue length.
void DeferredRouteOutput(Ptr< const Packet > p, const Ipv4Header &header, UnicastForwardCallback ucb, ErrorCallback ecb)
Queue packet and send route request.
void SendTo(Ptr< Socket > socket, Ptr< Packet > packet, Ipv4Address destination)
Send packet to destination socket.
DuplicatePacketDetection m_dpd
Handle duplicated broadcast/multicast packets.
Time m_netTraversalTime
Estimate of the average net traversal time.
void DoDispose() override
Destructor implementation.
void SendRequest(Ipv4Address dst)
Send RREQ.
Time m_pathDiscoveryTime
Estimate of maximum time needed to find route in network.
bool m_gratuitousReply
Indicates whether a gratuitous RREP should be unicast to the node originated route discovery.
uint16_t m_rerrCount
Number of RERRs used for RERR rate control.
void HelloTimerExpire()
Schedule next send of hello message.
void NotifyTxError(WifiMacDropReason reason, Ptr< const WifiMpdu > mpdu)
Notify that an MPDU was dropped.
RoutingTable m_routingTable
Routing table.
uint16_t m_rreqRateLimit
Maximum number of RREQ per second.
Ptr< NetDevice > m_lo
Loopback device used to defer RREQ until packet will be fully formed.
uint32_t m_netDiameter
Net diameter measures the maximum possible number of hops between two nodes in the network.
uint32_t m_maxQueueLen
The maximum number of packets that we allow a routing protocol to buffer.
uint16_t m_ttlThreshold
Maximum TTL value for expanding ring search, TTL = NetDiameter is used beyond this value.
Ptr< UniformRandomVariable > m_uniformRandomVariable
Provides uniform random variables.
void SetMaxQueueTime(Time t)
Set the maximum queue time.
uint16_t m_ttlIncrement
TTL increment for each attempt using the expanding ring search for RREQ dissemination.
Time m_myRouteTimeout
Value of lifetime field in RREP generating by this node.
uint16_t m_timeoutBuffer
Provide a buffer for the timeout.
void PrintRoutingTable(Ptr< OutputStreamWrapper > stream, Time::Unit unit=Time::S) const override
Print the Routing Table entries.
Ptr< Socket > FindSocketWithInterfaceAddress(Ipv4InterfaceAddress iface) const
Find unicast socket with local interface address iface.
void NotifyInterfaceDown(uint32_t interface) override
void SetBroadcastEnable(bool f)
Set broadcast enable flag.
void SendPacketFromQueue(Ipv4Address dst, Ptr< Ipv4Route > route)
Forward packet from route request queue.
uint32_t m_allowedHelloLoss
Number of hello messages which may be loss for valid link.
bool IsMyOwnAddress(Ipv4Address src)
Test whether the provided address is assigned to an interface on this node.
void SetMaxQueueLen(uint32_t len)
Set the maximum queue length.
void ScheduleRreqRetry(Ipv4Address dst)
Repeated attempts by a source node at route discovery for a single destination use the expanding ring...
void SendReplyByIntermediateNode(RoutingTableEntry &toDst, RoutingTableEntry &toOrigin, bool gratRep)
Send RREP by intermediate node.
std::map< Ptr< Socket >, Ipv4InterfaceAddress > m_socketAddresses
Raw unicast socket per each IP interface, map socket -> iface address (IP + mask)
void SetGratuitousReplyFlag(bool f)
Set gratuitous reply flag.
bool RouteInput(Ptr< const Packet > p, const Ipv4Header &header, Ptr< const NetDevice > idev, const UnicastForwardCallback &ucb, const MulticastForwardCallback &mcb, const LocalDeliverCallback &lcb, const ErrorCallback &ecb) override
Route an input packet (to be forwarded or locally delivered)
void Start()
Start protocol operation.
uint16_t m_rreqCount
Number of RREQs used for RREQ rate control.
IdCache m_rreqIdCache
Handle duplicated RREQ.
~RoutingProtocol() override
Time m_deletePeriod
DeletePeriod is intended to provide an upper bound on the time for which an upstream node A can have ...
void NotifyRemoveAddress(uint32_t interface, Ipv4InterfaceAddress address) override
void SendRerrWhenNoRouteToForward(Ipv4Address dst, uint32_t dstSeqNo, Ipv4Address origin)
Send RERR message when no route to forward input packet.
Time m_helloInterval
Every HelloInterval the node checks whether it has sent a broadcast within the last HelloInterval.
void AckTimerExpire(Ipv4Address neighbor, Time blacklistTimeout)
Mark link to neighbor node as unidirectional for blacklistTimeout.
void SetHelloEnable(bool f)
Set hello enable.
bool m_destinationOnly
Indicates only the destination may respond to this RREQ.
void SetIpv4(Ptr< Ipv4 > ipv4) override
static TypeId GetTypeId()
Get the type ID.
void SetDestinationOnlyFlag(bool f)
Set destination only flag.
bool GetDestinationOnlyFlag() const
Get destination only flag.
void SendRerrMessage(Ptr< Packet > packet, std::vector< Ipv4Address > precursors)
Forward RERR.
uint16_t m_ttlStart
Initial TTL value for RREQ.
uint32_t m_rreqRetries
Maximum number of retransmissions of RREQ with TTL = NetDiameter to discover a route.
uint32_t m_seqNo
Request sequence number.
bool m_enableHello
Indicates whether a hello messages enable.
Neighbors m_nb
Handle neighbors.
bool Forwarding(Ptr< const Packet > p, const Ipv4Header &header, UnicastForwardCallback ucb, ErrorCallback ecb)
If route exists and is valid, forward packet.
int64_t AssignStreams(int64_t stream)
Assign a fixed random variable stream number to the random variables used by this model.
static const uint32_t AODV_PORT
UDP Port for AODV control traffic.
Timer m_rreqRateLimitTimer
RREQ rate limit timer.
Time GetMaxQueueTime() const
Get maximum queue time.
void NotifyAddAddress(uint32_t interface, Ipv4InterfaceAddress address) override
RoutingProtocol()
constructor
Time m_nodeTraversalTime
NodeTraversalTime is a conservative estimate of the average one hop traversal time for packets and sh...
uint16_t m_rerrRateLimit
Maximum number of REER per second.
void RecvRequest(Ptr< Packet > p, Ipv4Address receiver, Ipv4Address src)
Receive RREQ.
Ptr< Socket > FindSubnetBroadcastSocketWithInterfaceAddress(Ipv4InterfaceAddress iface) const
Find subnet directed broadcast socket with local interface address iface.
void DoInitialize() override
Initialize() implementation.
bool GetHelloEnable() const
Get hello enable flag.
void SendRerrWhenBreaksLinkToNextHop(Ipv4Address nextHop)
Initiate RERR.
void RouteRequestTimerExpire(Ipv4Address dst)
Handle route discovery process.
void NotifyInterfaceUp(uint32_t interface) override
bool GetGratuitousReplyFlag() const
Get gratuitous reply flag.
void RecvError(Ptr< Packet > p, Ipv4Address src)
Receive RERR.
Ptr< Ipv4Route > RouteOutput(Ptr< Packet > p, const Ipv4Header &header, Ptr< NetDevice > oif, Socket::SocketErrno &sockerr) override
Query routing cache for an existing route, for an outbound packet.
Time m_nextHopWait
Period of our waiting for the neighbour's RREP_ACK.
void SendReplyAck(Ipv4Address neighbor)
Send RREP_ACK.
Ptr< Ipv4 > m_ipv4
IP protocol.
void RreqRateLimitTimerExpire()
Reset RREQ count and schedule RREQ rate limit timer with delay 1 sec.
void ProcessHello(const RrepHeader &rrepHeader, Ipv4Address receiverIfaceAddr)
Process hello message.
Timer m_htimer
Hello timer.
void SendReply(const RreqHeader &rreqHeader, const RoutingTableEntry &toOrigin)
Send RREP.
RequestQueue m_queue
A "drop-front" queue used by the routing layer to buffer packets to which it does not have a route.
Timer m_ackTimer
RREP_ACK timer.
void SetHop(uint16_t hop)
Set the number of hops.
bool InsertPrecursor(Ipv4Address id)
Insert precursor in precursor list if it doesn't yet exist in the list.
Ptr< NetDevice > GetOutputDevice() const
Get output device.
uint8_t GetRreqCnt() const
Get the RREQ count.
Ipv4InterfaceAddress GetInterface() const
Get the Ipv4InterfaceAddress.
void SetNextHop(Ipv4Address nextHop)
Set next hop address.
void SetLifeTime(Time lt)
Set the lifetime.
bool IsUnidirectional() const
Get the unidirectional flag.
void GetPrecursors(std::vector< Ipv4Address > &prec) const
Inserts precursors in output parameter prec if they do not yet exist in vector.
RouteFlags GetFlag() const
Get the route flags.
Ipv4Address GetNextHop() const
Get next hop address.
void IncrementRreqCnt()
Increment the RREQ count.
void SetSeqNo(uint32_t sn)
Set the sequence number.
void SetInterface(Ipv4InterfaceAddress iface)
Set the Ipv4InterfaceAddress.
void SetRreqCnt(uint8_t n)
Set the RREQ count.
void SetOutputDevice(Ptr< NetDevice > dev)
Set output device.
Ipv4Address GetDestination() const
Get destination address function.
uint16_t GetHop() const
Get the number of hops.
void SetValidSeqNo(bool s)
Set the valid sequence number.
uint32_t GetSeqNo() const
Get the sequence number.
bool GetValidSeqNo() const
Get the valid sequence number.
void SetFlag(RouteFlags flag)
Set the route flags.
Time GetLifeTime() const
Get the lifetime.
Ptr< Ipv4Route > GetRoute() const
Get route function.
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 LookupValidRoute(Ipv4Address dst, RoutingTableEntry &rt)
Lookup route in VALID state.
void Purge()
Delete all outdated entries and invalidate valid entry if Lifetime is expired.
bool Update(RoutingTableEntry &rt)
Update routing table.
bool AddRoute(RoutingTableEntry &r)
Add routing table entry if it doesn't yet exist in routing table.
void Print(Ptr< OutputStreamWrapper > stream, Time::Unit unit=Time::S) const
Print routing table.
bool LookupRoute(Ipv4Address dst, RoutingTableEntry &rt)
Lookup routing table entry with destination address dst.
void DeleteAllRoutesFromInterface(Ipv4InterfaceAddress iface)
Delete all route from interface with address iface.
void Clear()
Delete all entries from routing table.
void InvalidateRoutesWithDst(const std::map< Ipv4Address, uint32_t > &unreachable)
Update routing entries with this destination as follows:
bool MarkLinkAsUnidirectional(Ipv4Address neighbor, Time blacklistTimeout)
Mark entry as unidirectional (e.g.
bool DeleteRoute(Ipv4Address dst)
Delete routing table entry with destination address dst, if it exists.
@ AODVTYPE_RREP
AODVTYPE_RREP.
@ AODVTYPE_RREP_ACK
AODVTYPE_RREP_ACK.
@ AODVTYPE_RERR
AODVTYPE_RERR.
@ AODVTYPE_RREQ
AODVTYPE_RREQ.
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
#define NS_ASSERT_MSG(condition, message)
At runtime, in debugging builds, if this condition is not true, the program prints the message to out...
Ptr< const AttributeAccessor > MakePointerAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
Ptr< AttributeChecker > MakePointerChecker()
Create a PointerChecker for a type.
#define NS_ABORT_MSG_UNLESS(cond, msg)
Abnormal program termination if a condition is false, with a message.
#define NS_LOG_ERROR(msg)
Use NS_LOG to output a message of level LOG_ERROR.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
#define NS_LOG_LOGIC(msg)
Use NS_LOG to output a message of level LOG_LOGIC.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
#define NS_LOG_WARN(msg)
Use NS_LOG to output a message of level LOG_WARN.
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Ptr< T > Create(Ts &&... args)
Create class instances by constructors with varying numbers of arguments and return them by Ptr.
Time Now()
create an ns3::Time instance which contains the current simulation time.
Time MicroSeconds(uint64_t value)
Construct a Time in the indicated unit.
Time Seconds(double value)
Construct a Time in the indicated unit.
Time MilliSeconds(uint64_t value)
Construct a Time in the indicated unit.
WifiMacDropReason
The reason why an MPDU was dropped.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Ptr< const AttributeChecker > MakeBooleanChecker()
Ptr< const AttributeChecker > MakeUintegerChecker()
Ptr< const AttributeAccessor > MakeTimeAccessor(T1 a1)
Callback< R, Args... > MakeCallback(R(T::*memPtr)(Args...), OBJ objPtr)
Build Callbacks for class method members which take varying numbers of arguments and potentially retu...
Ptr< const AttributeAccessor > MakeUintegerAccessor(T1 a1)
Ptr< const AttributeAccessor > MakeBooleanAccessor(T1 a1)
Ptr< T1 > ConstCast(const Ptr< T2 > &p)
Cast a Ptr.
Ptr< const AttributeChecker > MakeTimeChecker()
Helper to make an unbounded Time checker.