A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
dsr-routing.h
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2011 Yufei Cheng
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License version 2 as
7  * published by the Free Software Foundation;
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  *
18  * Author: Yufei Cheng <yfcheng@ittc.ku.edu>
19  *
20  * James P.G. Sterbenz <jpgs@ittc.ku.edu>, director
21  * ResiliNets Research Group http://wiki.ittc.ku.edu/resilinets
22  * Information and Telecommunication Technology Center (ITTC)
23  * and Department of Electrical Engineering and Computer Science
24  * The University of Kansas Lawrence, KS USA.
25  *
26  * Work supported in part by NSF FIND (Future Internet Design) Program
27  * under grant CNS-0626918 (Postmodern Internet Architecture),
28  * NSF grant CNS-1050226 (Multilayer Network Resilience Analysis and Experimentation on GENI),
29  * US Department of Defense (DoD), and ITTC at The University of Kansas.
30  */
31 
32 #ifndef DSR_ROUTING_H
33 #define DSR_ROUTING_H
34 
35 #include <map>
36 #include <list>
37 #include <vector>
38 #include <stdint.h>
39 #include <cassert>
40 #include <sys/types.h>
41 
42 #include "ns3/callback.h"
43 #include "ns3/object.h"
44 #include "ns3/node.h"
45 #include "ns3/ptr.h"
46 #include "ns3/buffer.h"
47 #include "ns3/packet.h"
48 #include "ns3/ipv4.h"
49 #include "ns3/ip-l4-protocol.h"
50 #include "ns3/ipv4-l3-protocol.h"
51 #include "ns3/icmpv4-l4-protocol.h"
52 #include "ns3/ipv4-interface.h"
53 #include "ns3/ipv4-header.h"
54 #include "ns3/ipv4-address.h"
55 #include "ns3/traced-callback.h"
56 #include "ns3/random-variable-stream.h"
57 #include "ns3/ipv4-route.h"
58 #include "ns3/timer.h"
59 #include "ns3/net-device.h"
60 #include "ns3/output-stream-wrapper.h"
61 #include "ns3/wifi-mac.h"
62 #include "ns3/socket.h"
63 #include "ns3/event-garbage-collector.h"
64 #include "ns3/test.h"
65 
66 #include "dsr-network-queue.h"
67 #include "dsr-rcache.h"
68 #include "dsr-rreq-table.h"
69 #include "dsr-maintain-buff.h"
70 #include "dsr-passive-buff.h"
71 #include "dsr-option-header.h"
72 #include "dsr-fs-header.h"
73 #include "dsr-rsendbuff.h"
74 #include "dsr-errorbuff.h"
76 
77 namespace ns3 {
78 
79 class Packet;
80 class Node;
81 class Ipv4;
82 class Ipv4Address;
83 class Ipv4Header;
84 class Ipv4Interface;
85 class Ipv4L3Protocol;
86 class Time;
87 
88 namespace dsr {
89 
90 class DsrOptions;
95 class DsrRouting : public IpL4Protocol
96 {
97 public:
102  static TypeId GetTypeId ();
106  static const uint8_t PROT_NUMBER;
110  DsrRouting ();
114  virtual ~DsrRouting ();
119  Ptr<Node> GetNode () const;
124  void SetNode (Ptr<Node> node);
155 
157  //\{
158  bool IsLinkCache ();
160  bool LookupRoute (Ipv4Address id, RouteCacheEntry & rt);
161  bool AddRoute_Link (RouteCacheEntry::IP_VECTOR nodelist, Ipv4Address source);
162  bool AddRoute (RouteCacheEntry & rt);
163  void DeleteAllRoutesIncludeLink (Ipv4Address errorSrc, Ipv4Address unreachNode, Ipv4Address node);
164  bool UpdateRouteEntry (Ipv4Address dst);
165  bool FindSourceEntry (Ipv4Address src, Ipv4Address dst, uint16_t id);
166  //\}
167 
172  void ConnectCallbacks ();
178  Ptr<NetDevice> GetNetDeviceFromContext (std::string context);
184  std::vector<std::string> GetElementsFromContext (std::string context);
190  uint16_t GetIDfromIP (Ipv4Address address);
196  Ipv4Address GetIPfromID (uint16_t id);
212  void PrintVector (std::vector<Ipv4Address>& vec);
219  Ipv4Address SearchNextHop (Ipv4Address ipv4Address, std::vector<Ipv4Address>& vec);
224  int GetProtocolNumber (void) const;
228  void SendBuffTimerExpire ();
232  void CheckSendBuffer ();
236  void PacketNewRoute (Ptr<Packet> packet,
237  Ipv4Address source,
238  Ipv4Address destination,
239  uint8_t protocol);
247  Ptr<Ipv4Route> SetRoute (Ipv4Address nextHop, Ipv4Address srcAddress);
253  uint32_t GetPriority (DsrMessageType messageType);
257  void SendUnreachError (Ipv4Address unreachNode, Ipv4Address destination, Ipv4Address originalDst, uint8_t salvage, uint8_t protocol);
261  DsrOptionSRHeader &sourceRoute,
262  Ipv4Address nextHop,
263  uint8_t protocol,
264  Ptr<Ipv4Route> route);
268  void Send (Ptr<Packet> packet, Ipv4Address source,
269  Ipv4Address destination, uint8_t protocol, Ptr<Ipv4Route> route);
273  uint16_t AddAckReqHeader (Ptr<Packet> &packet, Ipv4Address nextHop);
277  void SendPacket (Ptr<Packet> packet, Ipv4Address source, Ipv4Address nextHop, uint8_t protocol);
281  void Scheduler (uint32_t priority);
285  void PriorityScheduler (uint32_t priority, bool continueWithFirst);
289  void IncreaseRetransTimer ();
293  bool SendRealDown (DsrNetworkQueueEntry & newEntry);
298  void SendPacketFromBuffer (DsrOptionSRHeader const &sourceRoute,
299  Ipv4Address nextHop,
300  uint8_t protocol);
304  bool PassiveEntryCheck (Ptr<Packet> packet, Ipv4Address source, Ipv4Address destination, uint8_t segsLeft,
305  uint16_t fragmentOffset, uint16_t identification, bool saveEntry);
306 
314  bool CancelPassiveTimer (Ptr<Packet> packet, Ipv4Address source, Ipv4Address destination, uint8_t segsLeft);
318  void CallCancelPacketTimer (uint16_t ackId, Ipv4Header const& ipv4Header, Ipv4Address realSrc, Ipv4Address realDst);
334  void CancelPacketTimerNextHop (Ipv4Address nextHop, uint8_t protocol);
338  void SalvagePacket (Ptr<const Packet> packet, Ipv4Address source, Ipv4Address dst, uint8_t protocol);
345  uint8_t protocol);
352  uint8_t protocol);
360  bool isFirst,
361  uint8_t protocol);
366  uint8_t protocol);
371  uint8_t protocol);
376  uint8_t protocol);
380  void ForwardPacket (Ptr<const Packet> packet,
381  DsrOptionSRHeader &sourceRoute,
382  Ipv4Header const& ipv4Header,
383  Ipv4Address source,
384  Ipv4Address destination,
385  Ipv4Address targetAddress,
386  uint8_t protocol,
387  Ptr<Ipv4Route> route);
391  void SendInitialRequest (Ipv4Address source,
392  Ipv4Address destination,
393  uint8_t protocol);
399  void SendErrorRequest (DsrOptionRerrUnreachHeader &rerr, uint8_t protocol);
405  void SendRequest (Ptr<Packet> packet,
406  Ipv4Address source);
411  void ScheduleInterRequest (Ptr<Packet> packet);
419  void SendGratuitousReply (Ipv4Address replyTo,
420  Ipv4Address replyFrom,
421  std::vector<Ipv4Address> &nodeList,
422  uint8_t protocol);
431  void SendReply (Ptr<Packet> packet,
432  Ipv4Address source,
433  Ipv4Address nextHop,
434  Ptr<Ipv4Route> route);
444  void ScheduleInitialReply (Ptr<Packet> packet,
445  Ipv4Address source,
446  Ipv4Address nextHop,
447  Ptr<Ipv4Route> route);
456  void ScheduleCachedReply (Ptr<Packet> packet,
457  Ipv4Address source,
458  Ipv4Address destination,
459  Ptr<Ipv4Route> route,
460  double hops);
471  void SendAck (uint16_t ackId,
472  Ipv4Address destination,
473  Ipv4Address realSrc,
474  Ipv4Address realDst,
475  uint8_t protocol,
476  Ptr<Ipv4Route> route);
487  Ipv4Header const &header,
488  Ptr<Ipv4Interface> incomingInterface);
489 
500  Ipv6Header const &header,
501  Ptr<Ipv6Interface> incomingInterface);
502 
519  uint8_t Process (Ptr<Packet>& packet, Ipv4Header const& ipv4Header, Ipv4Address dst, uint8_t *nextHeader, uint8_t protocol, bool& isDropped);
524  void Insert (Ptr<dsr::DsrOptions> option);
530  Ptr<dsr::DsrOptions> GetOption (int optionNumber);
536  void CancelRreqTimer (Ipv4Address dst, bool isRemove);
545  void ScheduleRreqRetry (Ptr<Packet> packet, std::vector<Ipv4Address> address, bool nonProp, uint32_t requestId, uint8_t protocol);
554  void RouteRequestTimerExpire (Ptr<Packet> packet, std::vector<Ipv4Address> address, uint32_t requestId, uint8_t protocol);
555 
564  int64_t AssignStreams (int64_t stream);
565 
566 protected:
567  /*
568  * * This function will notify other components connected to the node that a new stack member is now connected
569  * * This will be used to notify Layer 3 protocol of layer 4 protocol stack to connect them together.
570  * */
571  virtual void NotifyNewAggregate ();
575  virtual void DoDispose (void);
581 
582 private:
583 
584  void Start ();
589  void NotifyDataReceipt (std::string context, Ptr<const Packet> p);
593  void SendRerrWhenBreaksLinkToNextHop (Ipv4Address nextHop, uint8_t protocol);
604  bool PromiscReceive (Ptr<NetDevice> device, Ptr<const Packet> packet, uint16_t protocol, const Address &from,
605  const Address &to, NetDevice::PacketType packetType);
609  typedef std::list<Ptr<DsrOptions> > DsrOptionList_t;
614 
616 
618 
620 
622 
624 
625  uint8_t segsLeft;
626 
628 
629  uint32_t m_maxNetworkSize;
630 
632 
634 
636 
638 
640 
641  uint32_t m_sendRetries;
642 
643  uint32_t m_passiveRetries;
644 
645  uint32_t m_linkRetries;
646 
647  uint32_t m_rreqRetries;
648 
649  uint32_t m_maxMaintRexmt;
650 
652 
653  uint32_t m_maxSendBuffLen;
654 
656 
658 
660 
661  uint32_t m_maxMaintainLen;
662 
664 
665  uint32_t m_maxCacheLen;
666 
668 
670 
672 
674 
675  uint32_t m_requestId;
676 
677  uint16_t m_ackId;
678 
680 
681  uint32_t m_requestTableIds;
682 
683  uint32_t m_maxRreqId;
684 
686 
688 
689  uint32_t m_broadcastJitter;
690 
692 
693  uint32_t m_tryPassiveAcks;
694 
696 
697  uint32_t m_tryLinkAcks;
698 
700 
702 
704 
706 
708 
709  std::string m_cacheType;
710 
711  std::string m_routeSortType;
712 
714 
716 
718 
720 
722 
723  bool m_subRoute;
724 
726 
727  std::vector<Ipv4Address> m_finalRoute;
728 
729  std::map<Ipv4Address, Timer> m_addressReqTimer;
730 
731  std::map<Ipv4Address, Timer> m_nonPropReqTimer;
732 
733  std::map<NetworkKey, Timer> m_addressForwardTimer;
734 
735  std::map<NetworkKey, uint32_t> m_addressForwardCnt;
736 
737  std::map<PassiveKey, uint32_t> m_passiveCnt;
738 
739  std::map<PassiveKey, Timer> m_passiveAckTimer;
740 
741  std::map<LinkKey, uint32_t> m_linkCnt;
742 
743  std::map<LinkKey, Timer> m_linkAckTimer;
744 
746 
748 
750 
752 
753  bool m_linkAck;
754 
755  std::map<uint32_t, Ptr<dsr::DsrNetworkQueue> > m_priorityQueue;
756 
758 
760 
761  std::vector<Ipv4Address> m_clearList;
762 
763  std::vector<Ipv4Address> m_addresses;
764 
765  std::map <std::string, uint32_t> m_macToNodeIdMap;
766 
768 };
769 } /* namespace dsr */
770 } /* namespace ns3 */
771 
772 #endif /* DSR_ROUTING_H */
void SendRerrWhenBreaksLinkToNextHop(Ipv4Address nextHop, uint8_t protocol)
Send the route error message when the link breaks to the next hop.
uint32_t m_sendRetries
of retries have been sent for network acknowledgment
Definition: dsr-routing.h:641
uint32_t m_stabilityDecrFactor
The initial decrease factor for link cache.
Definition: dsr-routing.h:713
void SetDownTarget(IpL4Protocol::DownTargetCallback callback)
This method allows a caller to set the current down target callback set for this L4 protocol (IPv4 ca...
std::string m_cacheType
The type of route cache.
Definition: dsr-routing.h:709
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:79
Doxygen introspection did not find any typical Config paths.
Definition: ipv6-header.h:33
bool PassiveEntryCheck(Ptr< Packet > packet, Ipv4Address source, Ipv4Address destination, uint8_t segsLeft, uint16_t fragmentOffset, uint16_t identification, bool saveEntry)
Find the same passive entry.
void CancelLinkPacketTimer(MaintainBuffEntry &mb)
Cancel the link packet retransmission timer for a specific maintenance entry.
virtual void DoDispose(void)
Drop trace callback.
Definition: dsr-routing.cc:576
uint32_t m_maxSendBuffLen
The maximum number of packets that we allow a routing protocol to buffer.
Definition: dsr-routing.h:653
void ScheduleInterRequest(Ptr< Packet > packet)
Schedule the intermediate route request.
uint32_t m_stabilityIncrFactor
The initial increase factor for link cache.
Definition: dsr-routing.h:715
a simple Timer class
Definition: timer.h:45
void SendInitialRequest(Ipv4Address source, Ipv4Address destination, uint8_t protocol)
Broadcast the route request packet in subnet.
bool AddRoute(RouteCacheEntry &rt)
functions used to direct to route cache
Definition: dsr-routing.cc:691
void SendBuffTimerExpire()
The send buffer timer expire.
Definition: dsr-routing.cc:848
void Scheduler(uint32_t priority)
This function is called to schedule sending packets from the network queue.
void SalvagePacket(Ptr< const Packet > packet, Ipv4Address source, Ipv4Address dst, uint8_t protocol)
Salvage the packet which has been transmitted for 3 times.
Time m_sendBuffInterval
how often to check send buffer
Definition: dsr-routing.h:701
Time m_passiveAckTimeout
The timeout value for passive acknowledge.
Definition: dsr-routing.h:691
std::map< std::string, uint32_t > m_macToNodeIdMap
The map of mac address to node id.
Definition: dsr-routing.h:765
uint32_t m_discoveryHopLimit
Maximum hops to go for route request.
Definition: dsr-routing.h:633
uint32_t GetPriority(DsrMessageType messageType)
Set the priority of the packet in network queue.
Definition: dsr-routing.cc:836
Ptr< Ipv4 > m_ip
The ip ptr.
Definition: dsr-routing.h:619
forward calls to a chain of CallbackAn ns3::TracedCallback has almost exactly the same API as a norma...
uint32_t m_linkRetries
of retries have been sent for link acknowledgment
Definition: dsr-routing.h:645
TracedCallback< const DsrOptionSRHeader & > m_txPacketTrace
Definition: dsr-routing.h:580
void NetworkScheduleTimerExpire(MaintainBuffEntry &mb, uint8_t protocol)
This function deals with packet retransmission timer expire using network acknowledgment.
void DeleteAllRoutesIncludeLink(Ipv4Address errorSrc, Ipv4Address unreachNode, Ipv4Address node)
functions used to direct to route cache
Definition: dsr-routing.cc:699
Time m_maxRequestPeriod
The max request period.
Definition: dsr-routing.h:705
void PrintVector(std::vector< Ipv4Address > &vec)
Print the route vector.
Definition: dsr-routing.cc:733
uint32_t m_maxEntriesEachDst
Max number of route entries to save for each destination.
Definition: dsr-routing.h:671
Ptr< dsr::RouteCache > m_routeCache
A "drop-front" queue used by the routing layer to cache routes found.
Definition: dsr-routing.h:745
void IncreaseRetransTimer()
This function is called to increase the retransmission timer for data packet in the network queue...
Ipv4Address m_mainAddress
Our own Ip address.
Definition: dsr-routing.h:623
Ipv4Address SearchNextHop(Ipv4Address ipv4Address, std::vector< Ipv4Address > &vec)
Get the next hop of the route.
Definition: dsr-routing.cc:753
bool IsLinkCache()
functions used to direct to route cache
Definition: dsr-routing.cc:669
Time m_linkAckTimeout
The timeout value for link acknowledge.
Definition: dsr-routing.h:695
Doxygen introspection did not find any typical Config paths.
bool PromiscReceive(Ptr< NetDevice > device, Ptr< const Packet > packet, uint16_t protocol, const Address &from, const Address &to, NetDevice::PacketType packetType)
Promiscuous receive data packets destined to some other node.
uint32_t m_requestTableSize
The max size of the request table size.
Definition: dsr-routing.h:679
Source Route (SR) Message Format.
void ScheduleCachedReply(Ptr< Packet > packet, Ipv4Address source, Ipv4Address destination, Ptr< Ipv4Route > route, double hops)
Schedule the cached reply to a random start time to avoid possible route reply storm.
uint32_t m_tryLinkAcks
Maximum number of packet transmission using link acknowledgment.
Definition: dsr-routing.h:697
bool AddRoute_Link(RouteCacheEntry::IP_VECTOR nodelist, Ipv4Address source)
functions used to direct to route cache
Definition: dsr-routing.cc:684
void ForwardErrPacket(DsrOptionRerrUnreachHeader &rerr, DsrOptionSRHeader &sourceRoute, Ipv4Address nextHop, uint8_t protocol, Ptr< Ipv4Route > route)
This function is responsible for forwarding error packets along the route.
Time m_maxCacheTime
Max time for caching the route cache entry.
Definition: dsr-routing.h:667
Time m_gratReplyHoldoff
The max gratuitous reply hold off time.
Definition: dsr-routing.h:703
a polymophic address class
Definition: address.h:86
uint32_t m_maxMaintainLen
Max # of entries for maintainance buffer.
Definition: dsr-routing.h:661
void SendRequest(Ptr< Packet > packet, Ipv4Address source)
Forward the route request if the node is not the destination.
Ipv4Address GetIPfromID(uint16_t id)
Get the ip address from id.
Definition: dsr-routing.cc:820
std::vector< Ipv4Address > m_finalRoute
The route cache.
Definition: dsr-routing.h:727
static TypeId GetTypeId()
Get the type identificator.
Definition: dsr-routing.cc:106
int64_t AssignStreams(int64_t stream)
Assign a fixed random variable stream number to the random variables used by this model...
uint32_t m_graReplyTableSize
Set the gratuitous reply table size.
Definition: dsr-routing.h:707
Packet header for IPv4.
Definition: ipv4-header.h:31
void ConnectCallbacks()
Connect the callback for the tracing event.
Definition: dsr-routing.cc:456
Time m_maxNetworkDelay
Maximum network delay.
Definition: dsr-routing.h:631
uint16_t m_ackId
The ack id assigned to each acknowledge.
Definition: dsr-routing.h:677
Ptr< dsr::RreqTable > GetRequestTable() const
Get the request table.
Definition: dsr-routing.cc:632
void LinkScheduleTimerExpire(MaintainBuffEntry &mb, uint8_t protocol)
This function deals with packet retransmission timer expire using link acknowledgment.
void SendUnreachError(Ipv4Address unreachNode, Ipv4Address destination, Ipv4Address originalDst, uint8_t salvage, uint8_t protocol)
This function is responsible for sending error packets in case of break link to next hop...
Time m_sendBufferTimeout
The maximum period of time that a routing protocol is allowed to buffer a packet for.
Definition: dsr-routing.h:655
int GetProtocolNumber(void) const
Get the dsr protocol number.
Definition: dsr-routing.cc:797
std::vector< Ipv4Address > IP_VECTOR
Define the vector to hold Ip address.
Definition: dsr-rcache.h:177
Ipv4Address m_broadcast
The broadcast IP address.
Definition: dsr-routing.h:687
uint32_t m_numPriorityQueues
The number of priority queues used.
Definition: dsr-routing.h:751
DSR maintain buffer.
uint32_t m_broadcastJitter
The max time to delay route request broadcast.
Definition: dsr-routing.h:689
void SetNode(Ptr< Node > node)
Set the node.
Definition: dsr-routing.cc:600
static const uint8_t PROT_NUMBER
Define the dsr protocol number.
Definition: dsr-routing.h:106
uint32_t m_requestId
The id assigned to each route request.
Definition: dsr-routing.h:675
Ptr< dsr::RouteCache > GetRouteCache() const
Get the route cache.
Definition: dsr-routing.cc:619
void SetDownTarget6(IpL4Protocol::DownTargetCallback6 callback)
This method allows a caller to set the current down target callback set for this L4 protocol (IPv6 ca...
Ptr< Ipv4L3Protocol > m_ipv4
Ipv4l3Protocol.
Definition: dsr-routing.h:615
uint32_t m_requestTableIds
The request table identifiers.
Definition: dsr-routing.h:681
void CancelNetworkPacketTimer(MaintainBuffEntry &mb)
Cancel the network packet retransmission timer for a specific maintenance entry.
void SendReply(Ptr< Packet > packet, Ipv4Address source, Ipv4Address nextHop, Ptr< Ipv4Route > route)
Send the route reply back to the request originator with the cumulated route.
uint8_t segsLeft
The segment left value from SR header.
Definition: dsr-routing.h:625
DSR Network Queue Entry.
bool UpdateRouteEntry(Ipv4Address dst)
functions used to direct to route cache
Definition: dsr-routing.cc:704
Time m_minLifeTime
The min life time.
Definition: dsr-routing.h:719
Time m_useExtends
The use extension of the life time for link cache.
Definition: dsr-routing.h:721
Definition: dsr-rcache.h:174
GraReply m_graReply
The gratuitous route reply.
Definition: dsr-routing.h:757
void ScheduleInitialReply(Ptr< Packet > packet, Ipv4Address source, Ipv4Address nextHop, Ptr< Ipv4Route > route)
this is a generating the initial route reply from the destination address, a random delay time [0...
std::vector< Ipv4Address > m_addresses
The bind ipv4 addresses with next hop, src, destination address in sequence.
Definition: dsr-routing.h:763
Time m_blacklistTimeout
The black list time out.
Definition: dsr-routing.h:685
void SetPassiveBuffer(Ptr< dsr::PassiveBuffer > r)
Set the node.
Definition: dsr-routing.cc:638
std::map< NetworkKey, Timer > m_addressForwardTimer
Map network key + forward timer.
Definition: dsr-routing.h:733
std::map< Ipv4Address, Timer > m_addressReqTimer
Map IP address + RREQ timer.
Definition: dsr-routing.h:729
void SendPacketFromBuffer(DsrOptionSRHeader const &sourceRoute, Ipv4Address nextHop, uint8_t protocol)
This function is responsible for sending out data packets when have route, if no route found...
uint8_t m_maxSalvageCount
Maximum # times to salvage a packet.
Definition: dsr-routing.h:635
Time m_initStability
The initial stability value for link cache.
Definition: dsr-routing.h:717
Time m_requestPeriod
The base time interval between route requests.
Definition: dsr-routing.h:637
Ptr< dsr::DsrOptions > GetOption(int optionNumber)
Get the option corresponding to optionNumber.
uint16_t GetIDfromIP(Ipv4Address address)
Get the node id from ip address.
Definition: dsr-routing.cc:804
Ptr< Node > m_node
The node ptr.
Definition: dsr-routing.h:621
void CallCancelPacketTimer(uint16_t ackId, Ipv4Header const &ipv4Header, Ipv4Address realSrc, Ipv4Address realDst)
Call the cancel packet retransmission timer function.
void ScheduleNetworkPacketRetry(MaintainBuffEntry &mb, bool isFirst, uint8_t protocol)
Schedule the packet retransmission based on network layer acknowledgment.
uint32_t m_passiveRetries
of retries have been sent for passive acknowledgment
Definition: dsr-routing.h:643
uint32_t m_maxNetworkSize
Maximum network queue size.
Definition: dsr-routing.h:629
Ptr< Ipv4Route > SetRoute(Ipv4Address nextHop, Ipv4Address srcAddress)
Set the route to use for data packets, used by the option headers when sending data/control packets...
Definition: dsr-routing.cc:786
void Send(Ptr< Packet > packet, Ipv4Address source, Ipv4Address destination, uint8_t protocol, Ptr< Ipv4Route > route)
This function is called by higher layer protocol when sending packets.
uint8_t Process(Ptr< Packet > &packet, Ipv4Header const &ipv4Header, Ipv4Address dst, uint8_t *nextHeader, uint8_t protocol, bool &isDropped)
Process method Called from Ipv4L3Protocol::Receive.
uint32_t m_tryPassiveAcks
Maximum number of packet transmission using passive acknowledgment.
Definition: dsr-routing.h:693
Ptr< NetDevice > GetNetDeviceFromContext(std::string context)
Get the netdevice from the context.
Definition: dsr-routing.cc:548
ErrorBuffer m_errorBuffer
The error buffer to save the error messages.
Definition: dsr-routing.h:659
uint32_t m_maxMaintRexmt
Maximum number of retransmissions of data packets.
Definition: dsr-routing.h:649
uint16_t AddAckReqHeader(Ptr< Packet > &packet, Ipv4Address nextHop)
This function is called to add ack request header for network acknowledgement.
void PacketNewRoute(Ptr< Packet > packet, Ipv4Address source, Ipv4Address destination, uint8_t protocol)
When route vector corrupted, originate a new packet, normally not happening.
an EUI-48 address
Definition: mac48-address.h:41
Time m_retransIncr
the increase time for retransmission timer when face network congestion
Definition: dsr-routing.h:725
void ScheduleLinkPacketRetry(MaintainBuffEntry &mb, uint8_t protocol)
Schedule the packet retransmission based on link-layer acknowledgment.
void ForwardPacket(Ptr< const Packet > packet, DsrOptionSRHeader &sourceRoute, Ipv4Header const &ipv4Header, Ipv4Address source, Ipv4Address destination, Ipv4Address targetAddress, uint8_t protocol, Ptr< Ipv4Route > route)
Forward the packet using the route saved in the source route option header.
Ptr< dsr::PassiveBuffer > m_passiveBuffer
A "drop-front" queue used by the routing layer to cache route request sent.
Definition: dsr-routing.h:749
std::map< LinkKey, Timer > m_linkAckTimer
The timer for link acknowledgment.
Definition: dsr-routing.h:743
MaintainBuffer m_maintainBuffer
The declaration of maintain buffer.
Definition: dsr-routing.h:673
L4 Protocol abstract base class.
std::vector< Ipv4Address > m_clearList
The node that is clear to send packet to.
Definition: dsr-routing.h:761
void NotifyDataReceipt(std::string context, Ptr< const Packet > p)
Notify the data receipt.
Definition: dsr-routing.cc:463
DSR Maintain Buffer Entry.
void SendPacket(Ptr< Packet > packet, Ipv4Address source, Ipv4Address nextHop, uint8_t protocol)
This function is called by when really sending out the packet.
void ScheduleRreqRetry(Ptr< Packet > packet, std::vector< Ipv4Address > address, bool nonProp, uint32_t requestId, uint8_t protocol)
Schedule the route request retry.
IpL4Protocol::DownTargetCallback GetDownTarget(void) const
This method allows a caller to get the current down target callback set for this L4 protocol (IPv4 ca...
uint32_t m_maxRreqId
The max number of request ids for a single destination.
Definition: dsr-routing.h:683
virtual enum IpL4Protocol::RxStatus Receive(Ptr< Packet > p, Ipv4Header const &header, Ptr< Ipv4Interface > incomingInterface)
Ptr< dsr::PassiveBuffer > GetPassiveBuffer() const
Get the passive buffer.
Definition: dsr-routing.cc:645
uint32_t m_maxCacheLen
Max # of cache entries for route cache.
Definition: dsr-routing.h:665
std::string m_routeSortType
The type of route sort methods.
Definition: dsr-routing.h:711
void CheckSendBuffer()
Check the send buffer of packets with route when send buffer timer expire.
Definition: dsr-routing.cc:858
std::map< uint32_t, Ptr< dsr::DsrNetworkQueue > > m_priorityQueue
priority queues
Definition: dsr-routing.h:755
std::map< PassiveKey, uint32_t > m_passiveCnt
Map packet key + passive forward counts.
Definition: dsr-routing.h:737
Ipv4 addresses are stored in host order in this class.
Definition: ipv4-address.h:38
virtual void NotifyNewAggregate()
This method is invoked whenever two sets of objects are aggregated together.
Definition: dsr-routing.cc:331
TracedCallback< Ptr< const Packet > > m_dropTrace
The trace for drop, receive and send data packets.
Definition: dsr-routing.h:579
Ptr< dsr::RreqTable > m_rreqTable
A "drop-front" queue used by the routing layer to cache route request sent.
Definition: dsr-routing.h:747
DSR send buffer.
std::map< PassiveKey, Timer > m_passiveAckTimer
The timer for passive acknowledgment.
Definition: dsr-routing.h:739
void CancelPacketTimerNextHop(Ipv4Address nextHop, uint8_t protocol)
Cancel the packet retransmission timer for a all maintenance entries with nextHop address...
Ptr< Ipv4Route > m_ipv4Route
Ipv4 Route.
Definition: dsr-routing.h:617
void SendAck(uint16_t ackId, Ipv4Address destination, Ipv4Address realSrc, Ipv4Address realDst, uint8_t protocol, Ptr< Ipv4Route > route)
Send network layer acknowledgment back to the earlier hop to notify the receipt of data packet...
Time m_nodeTraversalTime
Time estimated for packet to travel between two nodes.
Definition: dsr-routing.h:651
void SetRequestTable(Ptr< dsr::RreqTable > r)
Set the node.
Definition: dsr-routing.cc:625
bool m_subRoute
Whether to save sub route or not.
Definition: dsr-routing.h:723
Route Error (RERR) Unreachable node address option Message Format.
bool CancelPassiveTimer(Ptr< Packet > packet, Ipv4Address source, Ipv4Address destination, uint8_t segsLeft)
Cancel the passive timer.
void Insert(Ptr< dsr::DsrOptions > option)
Insert a new Dsr Option.
Ipv4Address GetIPfromMAC(Mac48Address address)
Get the Ip address from mac address.
Definition: dsr-routing.cc:715
bool SendRealDown(DsrNetworkQueueEntry &newEntry)
This function is called to send packets down stack.
void RouteRequestTimerExpire(Ptr< Packet > packet, std::vector< Ipv4Address > address, uint32_t requestId, uint8_t protocol)
Handle route discovery timer.
uint32_t m_rreqRetries
Maximum number of retransmissions of RREQ with TTL = NetDiameter to discover a route.
Definition: dsr-routing.h:647
DsrNetworkQueue m_networkQueue
The network queue.
Definition: dsr-routing.h:759
Time m_maxRreqTime
Max time for caching the route request entry.
Definition: dsr-routing.h:669
void PriorityScheduler(uint32_t priority, bool continueWithFirst)
This function is called to schedule sending packets from the network queue by priority.
Timer m_sendBuffTimer
The send buffer timer.
Definition: dsr-routing.h:699
bool FindSourceEntry(Ipv4Address src, Ipv4Address dst, uint16_t id)
functions used to direct to route cache
Definition: dsr-routing.cc:709
RxStatus
Rx status codes.
Ptr< UniformRandomVariable > m_uniformRandomVariable
Provides uniform random variables.
Definition: dsr-routing.h:767
Ptr< Node > GetNodeWithAddress(Ipv4Address ipv4Address)
Get the node with give ip address.
Definition: dsr-routing.cc:652
void SetRouteCache(Ptr< dsr::RouteCache > r)
Set the route cache.
Definition: dsr-routing.cc:612
DsrOptionList_t m_options
List of DSR Options supported.
Definition: dsr-routing.h:613
void SendGratuitousReply(Ipv4Address replyTo, Ipv4Address replyFrom, std::vector< Ipv4Address > &nodeList, uint8_t protocol)
Send the gratuitous reply.
void SendErrorRequest(DsrOptionRerrUnreachHeader &rerr, uint8_t protocol)
Send the error request packet.
tuple address
Definition: first.py:37
void CancelPacketAllTimer(MaintainBuffEntry &mb)
Cancel all the packet timers.
PacketType
Packet types are used as they are in Linux.
Definition: net-device.h:274
DSR error buffer.
Ptr< Node > GetNode() const
Get the node.
Definition: dsr-routing.cc:606
SendBuffer m_sendBuffer
The send buffer.
Definition: dsr-routing.h:657
std::map< LinkKey, uint32_t > m_linkCnt
Map packet key + link forward counts.
Definition: dsr-routing.h:741
bool LookupRoute(Ipv4Address id, RouteCacheEntry &rt)
functions used to direct to route cache
Definition: dsr-routing.cc:679
IpL4Protocol::DownTargetCallback6 GetDownTarget6(void) const
This method allows a caller to get the current down target callback set for this L4 protocol (IPv6 ca...
std::map< NetworkKey, uint32_t > m_addressForwardCnt
Map network key + forward counts.
Definition: dsr-routing.h:735
Doxygen introspection did not find any typical Config paths.
Definition: dsr-routing.h:95
a unique identifier for an interface.
Definition: type-id.h:49
Time m_nonpropRequestTimeout
The non-propagation request timeout.
Definition: dsr-routing.h:639
std::map< Ipv4Address, Timer > m_nonPropReqTimer
Map IP address + RREQ timer.
Definition: dsr-routing.h:731
bool m_linkAck
define if we use link acknowledgement or not
Definition: dsr-routing.h:753
std::vector< std::string > GetElementsFromContext(std::string context)
Get the elements from the tracing context.
Definition: dsr-routing.cc:560
void PassiveScheduleTimerExpire(MaintainBuffEntry &mb, uint8_t protocol)
This function deals with packet retransmission timer expire using passive acknowledgment.
void CancelPassivePacketTimer(MaintainBuffEntry &mb)
Cancel the passive packet retransmission timer for a specific maintenance entry.
std::list< Ptr< DsrOptions > > DsrOptionList_t
Define the list to hold DSR options.
Definition: dsr-routing.h:609
IpL4Protocol::DownTargetCallback m_downTarget
The callback for down layer.
Definition: dsr-routing.h:627
DsrRouting()
Constructor.
Definition: dsr-routing.cc:290
void UseExtends(RouteCacheEntry::IP_VECTOR rt)
functions used to direct to route cache
Definition: dsr-routing.cc:674
maintain the gratuitous reply
Time m_maxMaintainTime
Time out for maintainance buffer.
Definition: dsr-routing.h:663
void CancelRreqTimer(Ipv4Address dst, bool isRemove)
Cancel the route request timer.
virtual ~DsrRouting()
Destructor.
Definition: dsr-routing.cc:325
void SchedulePassivePacketRetry(MaintainBuffEntry &mb, uint8_t protocol)
Schedule the packet retransmission based on passive acknowledgment.