A Discrete-Event Network Simulator
API
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 ();
162  bool AddRoute (DsrRouteCacheEntry & 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 
173  Ptr<NetDevice> GetNetDeviceFromContext (std::string context);
179  std::vector<std::string> GetElementsFromContext (std::string context);
185  uint16_t GetIDfromIP (Ipv4Address address);
191  Ipv4Address GetIPfromID (uint16_t id);
208  void PrintVector (std::vector<Ipv4Address>& vec);
215  Ipv4Address SearchNextHop (Ipv4Address ipv4Address, std::vector<Ipv4Address>& vec);
220  int GetProtocolNumber (void) const;
224  void SendBuffTimerExpire ();
228  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);
262  void SendUnreachError (Ipv4Address unreachNode, Ipv4Address destination, Ipv4Address originalDst, uint8_t salvage, uint8_t protocol);
271  DsrOptionSRHeader &sourceRoute,
272  Ipv4Address nextHop,
273  uint8_t protocol,
274  Ptr<Ipv4Route> route);
283  void Send (Ptr<Packet> packet, Ipv4Address source,
284  Ipv4Address destination, uint8_t protocol, Ptr<Ipv4Route> route);
291  uint16_t AddAckReqHeader (Ptr<Packet> &packet, Ipv4Address nextHop);
299  void SendPacket (Ptr<Packet> packet, Ipv4Address source, Ipv4Address nextHop, uint8_t protocol);
304  void Scheduler (uint32_t priority);
310  void PriorityScheduler (uint32_t priority, bool continueWithFirst);
314  void IncreaseRetransTimer ();
320  bool SendRealDown (DsrNetworkQueueEntry & newEntry);
328  void SendPacketFromBuffer (DsrOptionSRHeader const &sourceRoute,
329  Ipv4Address nextHop,
330  uint8_t protocol);
342  bool PassiveEntryCheck (Ptr<Packet> packet, Ipv4Address source, Ipv4Address destination, uint8_t segsLeft,
343  uint16_t fragmentOffset, uint16_t identification, bool saveEntry);
344 
358  bool CancelPassiveTimer (Ptr<Packet> packet, Ipv4Address source, Ipv4Address destination, uint8_t segsLeft);
366  void CallCancelPacketTimer (uint16_t ackId, Ipv4Header const& ipv4Header, Ipv4Address realSrc, Ipv4Address realDst);
387  void CancelPacketTimerNextHop (Ipv4Address nextHop, uint8_t protocol);
395  void SalvagePacket (Ptr<const Packet> packet, Ipv4Address source, Ipv4Address dst, uint8_t protocol);
402  uint8_t protocol);
409  uint8_t protocol);
417  bool isFirst,
418  uint8_t protocol);
425  uint8_t protocol);
432  uint8_t protocol);
439  uint8_t protocol);
451  void ForwardPacket (Ptr<const Packet> packet,
452  DsrOptionSRHeader &sourceRoute,
453  Ipv4Header const& ipv4Header,
454  Ipv4Address source,
455  Ipv4Address destination,
456  Ipv4Address targetAddress,
457  uint8_t protocol,
458  Ptr<Ipv4Route> route);
465  void SendInitialRequest (Ipv4Address source,
466  Ipv4Address destination,
467  uint8_t protocol);
473  void SendErrorRequest (DsrOptionRerrUnreachHeader &rerr, uint8_t protocol);
479  void SendRequest (Ptr<Packet> packet,
480  Ipv4Address source);
485  void ScheduleInterRequest (Ptr<Packet> packet);
493  void SendGratuitousReply (Ipv4Address replyTo,
494  Ipv4Address replyFrom,
495  std::vector<Ipv4Address> &nodeList,
496  uint8_t protocol);
505  void SendReply (Ptr<Packet> packet,
506  Ipv4Address source,
507  Ipv4Address nextHop,
508  Ptr<Ipv4Route> route);
518  void ScheduleInitialReply (Ptr<Packet> packet,
519  Ipv4Address source,
520  Ipv4Address nextHop,
521  Ptr<Ipv4Route> route);
531  void ScheduleCachedReply (Ptr<Packet> packet,
532  Ipv4Address source,
533  Ipv4Address destination,
534  Ptr<Ipv4Route> route,
535  double hops);
546  void SendAck (uint16_t ackId,
547  Ipv4Address destination,
548  Ipv4Address realSrc,
549  Ipv4Address realDst,
550  uint8_t protocol,
551  Ptr<Ipv4Route> route);
562  Ipv4Header const &header,
563  Ptr<Ipv4Interface> incomingInterface);
564 
575  Ipv6Header const &header,
576  Ptr<Ipv6Interface> incomingInterface);
577 
594  uint8_t Process (Ptr<Packet>& packet, Ipv4Header const& ipv4Header, Ipv4Address dst, uint8_t *nextHeader, uint8_t protocol, bool& isDropped);
599  void Insert (Ptr<dsr::DsrOptions> option);
605  Ptr<dsr::DsrOptions> GetOption (int optionNumber);
611  void CancelRreqTimer (Ipv4Address dst, bool isRemove);
620  void ScheduleRreqRetry (Ptr<Packet> packet, std::vector<Ipv4Address> address, bool nonProp, uint32_t requestId, uint8_t protocol);
629  void RouteRequestTimerExpire (Ptr<Packet> packet, std::vector<Ipv4Address> address, uint32_t requestId, uint8_t protocol);
630 
639  int64_t AssignStreams (int64_t stream);
640 
641 protected:
642  /*
643  * * This function will notify other components connected to the node that a new stack member is now connected
644  * * This will be used to notify Layer 3 protocol of layer 4 protocol stack to connect them together.
645  * */
646  virtual void NotifyNewAggregate ();
650  virtual void DoDispose (void);
656 
657 private:
658  void Start ();
664  void SendRerrWhenBreaksLinkToNextHop (Ipv4Address nextHop, uint8_t protocol);
675  bool PromiscReceive (Ptr<NetDevice> device, Ptr<const Packet> packet, uint16_t protocol, const Address &from,
676  const Address &to, NetDevice::PacketType packetType);
680  typedef std::list<Ptr<DsrOptions> > DsrOptionList_t;
685 
687 
689 
691 
693 
695 
696  uint8_t segsLeft;
697 
699 
700  uint32_t m_maxNetworkSize;
701 
703 
705 
707 
709 
711 
712  uint32_t m_sendRetries;
713 
714  uint32_t m_passiveRetries;
715 
716  uint32_t m_linkRetries;
717 
718  uint32_t m_rreqRetries;
719 
720  uint32_t m_maxMaintRexmt;
721 
723 
724  uint32_t m_maxSendBuffLen;
725 
727 
729 
731 
732  uint32_t m_maxMaintainLen;
733 
735 
736  uint32_t m_maxCacheLen;
737 
739 
741 
743 
745 
746  uint32_t m_requestId;
747 
748  uint16_t m_ackId;
749 
751 
752  uint32_t m_requestTableIds;
753 
754  uint32_t m_maxRreqId;
755 
757 
759 
760  uint32_t m_broadcastJitter;
761 
763 
764  uint32_t m_tryPassiveAcks;
765 
767 
768  uint32_t m_tryLinkAcks;
769 
771 
773 
775 
777 
779 
780  std::string m_cacheType;
781 
782  std::string m_routeSortType;
783 
785 
787 
789 
791 
793 
794  bool m_subRoute;
795 
797 
798  std::vector<Ipv4Address> m_finalRoute;
799 
800  std::map<Ipv4Address, Timer> m_addressReqTimer;
801 
802  std::map<Ipv4Address, Timer> m_nonPropReqTimer;
803 
804  std::map<NetworkKey, Timer> m_addressForwardTimer;
805 
806  std::map<NetworkKey, uint32_t> m_addressForwardCnt;
807 
808  std::map<PassiveKey, uint32_t> m_passiveCnt;
809 
810  std::map<PassiveKey, Timer> m_passiveAckTimer;
811 
812  std::map<LinkKey, uint32_t> m_linkCnt;
813 
814  std::map<LinkKey, Timer> m_linkAckTimer;
815 
817 
819 
821 
823 
824  bool m_linkAck;
825 
826  std::map<uint32_t, Ptr<dsr::DsrNetworkQueue> > m_priorityQueue;
827 
829 
831 
832  std::vector<Ipv4Address> m_clearList;
833 
834  std::vector<Ipv4Address> m_addresses;
835 
836  std::map <std::string, uint32_t> m_macToNodeIdMap;
837 
839 };
840 } /* namespace dsr */
841 } /* namespace ns3 */
842 
843 #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:712
uint32_t m_stabilityDecrFactor
The initial decrease factor for link cache.
Definition: dsr-routing.h:784
void SetDownTarget(IpL4Protocol::DownTargetCallback callback)
This method allows a caller to set the current down target callback set for this L4 protocol (IPv4 ca...
DSR send buffer.
void UseExtends(DsrRouteCacheEntry::IP_VECTOR rt)
functions used to direct to route cache
Definition: dsr-routing.cc:647
void SetRequestTable(Ptr< dsr::DsrRreqTable > r)
Set the node.
Definition: dsr-routing.cc:598
std::string m_cacheType
The type of route cache.
Definition: dsr-routing.h:780
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:102
maintain the gratuitous reply
DsrRouteCacheEntry class for entries in the route cache.
Definition: dsr-rcache.h:220
Packet header for IPv6.
Definition: ipv6-header.h:34
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.
virtual void DoDispose(void)
Drop trace callback.
Definition: dsr-routing.cc:549
uint32_t m_maxSendBuffLen
The maximum number of packets that we allow a routing protocol to buffer.
Definition: dsr-routing.h:724
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:786
A simple Timer class.
Definition: timer.h:73
bool LookupRoute(Ipv4Address id, DsrRouteCacheEntry &rt)
functions used to direct to route cache
Definition: dsr-routing.cc:652
void SendInitialRequest(Ipv4Address source, Ipv4Address destination, uint8_t protocol)
Broadcast the route request packet in subnet.
void SendBuffTimerExpire()
The send buffer timer expire.
Definition: dsr-routing.cc:821
void Scheduler(uint32_t priority)
This function is called to schedule sending packets from the network queue.
DSR Maintain Buffer Entry.
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:772
Time m_passiveAckTimeout
The timeout value for passive acknowledge.
Definition: dsr-routing.h:762
std::map< std::string, uint32_t > m_macToNodeIdMap
The map of mac address to node id.
Definition: dsr-routing.h:836
uint32_t m_discoveryHopLimit
Maximum hops to go for route request.
Definition: dsr-routing.h:704
uint32_t GetPriority(DsrMessageType messageType)
Set the priority of the packet in network queue.
Definition: dsr-routing.cc:809
Ptr< Ipv4 > m_ip
The ip ptr.
Definition: dsr-routing.h:690
Forward calls to a chain of Callback.
uint32_t m_linkRetries
of retries have been sent for link acknowledgment
Definition: dsr-routing.h:716
TracedCallback< const DsrOptionSRHeader & > m_txPacketTrace
packet trace callback
Definition: dsr-routing.h:655
Ptr< dsr::DsrRouteCache > GetRouteCache() const
Get the route cache.
Definition: dsr-routing.cc:592
void DeleteAllRoutesIncludeLink(Ipv4Address errorSrc, Ipv4Address unreachNode, Ipv4Address node)
functions used to direct to route cache
Definition: dsr-routing.cc:672
Time m_maxRequestPeriod
The max request period.
Definition: dsr-routing.h:776
void PrintVector(std::vector< Ipv4Address > &vec)
Print the route vector.
Definition: dsr-routing.cc:706
uint32_t m_maxEntriesEachDst
Max number of route entries to save for each destination.
Definition: dsr-routing.h:742
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:694
Ipv4Address SearchNextHop(Ipv4Address ipv4Address, std::vector< Ipv4Address > &vec)
Get the next hop of the route.
Definition: dsr-routing.cc:726
void CancelPacketAllTimer(DsrMaintainBuffEntry &mb)
Cancel all the packet timers.
void(* Time)(Time oldValue, Time newValue)
TracedValue callback signature for Time.
Definition: nstime.h:740
bool IsLinkCache()
functions used to direct to route cache
Definition: dsr-routing.cc:642
Time m_linkAckTimeout
The timeout value for link acknowledge.
Definition: dsr-routing.h:766
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.
DSR error buffer.
uint32_t m_requestTableSize
The max size of the request table size.
Definition: dsr-routing.h:750
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:768
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:738
Time m_gratReplyHoldoff
The max gratuitous reply hold off time.
Definition: dsr-routing.h:774
a polymophic address class
Definition: address.h:90
uint32_t m_maxMaintainLen
Max # of entries for maintenance buffer.
Definition: dsr-routing.h:732
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:793
std::vector< Ipv4Address > m_finalRoute
The route cache.
Definition: dsr-routing.h:798
static TypeId GetTypeId()
Get the type identificator.
Definition: dsr-routing.cc:108
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:778
bool AddRoute(DsrRouteCacheEntry &rt)
functions used to direct to route cache
Definition: dsr-routing.cc:664
DsrMaintainBuffer m_maintainBuffer
The declaration of maintain buffer.
Definition: dsr-routing.h:744
Packet header for IPv4.
Definition: ipv4-header.h:33
Time m_maxNetworkDelay
Maximum network delay.
Definition: dsr-routing.h:702
Ptr< dsr::DsrRreqTable > GetRequestTable() const
Get the request table.
Definition: dsr-routing.cc:605
uint16_t m_ackId
The ack id assigned to each acknowledge.
Definition: dsr-routing.h:748
DsrGraReply m_graReply
The gratuitous route reply.
Definition: dsr-routing.h:828
void CancelPassivePacketTimer(DsrMaintainBuffEntry &mb)
Cancel the passive packet retransmission timer for a specific maintenance entry.
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:726
Ipv4Address m_broadcast
The broadcast IP address.
Definition: dsr-routing.h:758
uint32_t m_numPriorityQueues
The number of priority queues used.
Definition: dsr-routing.h:822
uint32_t m_broadcastJitter
The max time to delay route request broadcast.
Definition: dsr-routing.h:760
void ScheduleLinkPacketRetry(DsrMaintainBuffEntry &mb, uint8_t protocol)
Schedule the packet retransmission based on link-layer acknowledgment.
void SetNode(Ptr< Node > node)
Set the node.
Definition: dsr-routing.cc:573
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:746
DsrErrorBuffer m_errorBuffer
The error buffer to save the error messages.
Definition: dsr-routing.h:730
void NetworkScheduleTimerExpire(DsrMaintainBuffEntry &mb, uint8_t protocol)
This function deals with packet retransmission timer expire using network acknowledgment.
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:686
uint32_t m_requestTableIds
The request table identifiers.
Definition: dsr-routing.h:752
bool AddRoute_Link(DsrRouteCacheEntry::IP_VECTOR nodelist, Ipv4Address source)
functions used to direct to route cache
Definition: dsr-routing.cc:657
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:696
DSR Network Queue Entry.
bool UpdateRouteEntry(Ipv4Address dst)
functions used to direct to route cache
Definition: dsr-routing.cc:677
Time m_minLifeTime
The min life time.
Definition: dsr-routing.h:790
std::vector< Ipv4Address > IP_VECTOR
Define the vector to hold Ip address.
Definition: dsr-rcache.h:223
Time m_useExtends
The use extension of the life time for link cache.
Definition: dsr-routing.h:792
void SchedulePassivePacketRetry(DsrMaintainBuffEntry &mb, uint8_t protocol)
Schedule the packet retransmission based on passive acknowledgment.
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:834
Time m_blacklistTimeout
The black list time out.
Definition: dsr-routing.h:756
IpL4Protocol::DownTargetCallback GetDownTarget(void) const
This method allows a caller to get the current down target callback set for this L4 protocol (IPv4 ca...
std::map< NetworkKey, Timer > m_addressForwardTimer
Map network key + forward timer.
Definition: dsr-routing.h:804
std::map< Ipv4Address, Timer > m_addressReqTimer
Map IP address + RREQ timer.
Definition: dsr-routing.h:800
void SetPassiveBuffer(Ptr< dsr::DsrPassiveBuffer > r)
Set the node.
Definition: dsr-routing.cc:611
void LinkScheduleTimerExpire(DsrMaintainBuffEntry &mb, uint8_t protocol)
This function deals with packet retransmission timer expire using link acknowledgment.
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:706
Time m_initStability
The initial stability value for link cache.
Definition: dsr-routing.h:788
Time m_requestPeriod
The base time interval between route requests.
Definition: dsr-routing.h:708
Every class exported by the ns3 library is enclosed in the ns3 namespace.
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:777
Ptr< Node > m_node
The node ptr.
Definition: dsr-routing.h:692
address
Definition: first.py:37
void CallCancelPacketTimer(uint16_t ackId, Ipv4Header const &ipv4Header, Ipv4Address realSrc, Ipv4Address realDst)
Call the cancel packet retransmission timer function.
uint32_t m_passiveRetries
of retries have been sent for passive acknowledgment
Definition: dsr-routing.h:714
uint32_t m_maxNetworkSize
Maximum network queue size.
Definition: dsr-routing.h:700
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:759
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:764
Ptr< NetDevice > GetNetDeviceFromContext(std::string context)
Get the netdevice from the context.
Definition: dsr-routing.cc:522
uint32_t m_maxMaintRexmt
Maximum number of retransmissions of data packets.
Definition: dsr-routing.h:720
Ptr< dsr::DsrPassiveBuffer > GetPassiveBuffer() const
Get the passive buffer.
Definition: dsr-routing.cc:618
void CancelLinkPacketTimer(DsrMaintainBuffEntry &mb)
Cancel the link packet retransmission timer for a specific maintenance entry.
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:43
Time m_retransIncr
the increase time for retransmission timer when face network congestion
Definition: dsr-routing.h:796
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.
std::map< LinkKey, Timer > m_linkAckTimer
The timer for link acknowledgment.
Definition: dsr-routing.h:814
L4 Protocol abstract base class.
std::vector< Ipv4Address > m_clearList
The node that is clear to send packet to.
Definition: dsr-routing.h:832
IpL4Protocol::DownTargetCallback6 GetDownTarget6(void) const
This method allows a caller to get the current down target callback set for this L4 protocol (IPv6 ca...
void SendPacket(Ptr< Packet > packet, Ipv4Address source, Ipv4Address nextHop, uint8_t protocol)
This function is called by when really sending out the packet.
int GetProtocolNumber(void) const
Get the dsr protocol number.
Definition: dsr-routing.cc:770
void ScheduleRreqRetry(Ptr< Packet > packet, std::vector< Ipv4Address > address, bool nonProp, uint32_t requestId, uint8_t protocol)
Schedule the route request retry.
uint32_t m_maxRreqId
The max number of request ids for a single destination.
Definition: dsr-routing.h:754
virtual enum IpL4Protocol::RxStatus Receive(Ptr< Packet > p, Ipv4Header const &header, Ptr< Ipv4Interface > incomingInterface)
Ptr< dsr::DsrRouteCache > m_routeCache
A "drop-front" queue used by the routing layer to cache routes found.
Definition: dsr-routing.h:816
uint32_t m_maxCacheLen
Max # of cache entries for route cache.
Definition: dsr-routing.h:736
void PassiveScheduleTimerExpire(DsrMaintainBuffEntry &mb, uint8_t protocol)
This function deals with packet retransmission timer expire using passive acknowledgment.
std::string m_routeSortType
The type of route sort methods.
Definition: dsr-routing.h:782
void CheckSendBuffer()
Check the send buffer of packets with route when send buffer timer expire.
Definition: dsr-routing.cc:831
std::map< uint32_t, Ptr< dsr::DsrNetworkQueue > > m_priorityQueue
priority queues
Definition: dsr-routing.h:826
std::map< PassiveKey, uint32_t > m_passiveCnt
Map packet key + passive forward counts.
Definition: dsr-routing.h:808
Ipv4 addresses are stored in host order in this class.
Definition: ipv4-address.h:40
virtual void NotifyNewAggregate()
Notify all Objects aggregated to this one of a new Object being aggregated.
Definition: dsr-routing.cc:397
TracedCallback< Ptr< const Packet > > m_dropTrace
The trace for drop, receive and send data packets.
Definition: dsr-routing.h:654
std::map< PassiveKey, Timer > m_passiveAckTimer
The timer for passive acknowledgment.
Definition: dsr-routing.h:810
Ptr< Node > GetNode() const
Get the node.
Definition: dsr-routing.cc:579
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:688
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:722
void SetRouteCache(Ptr< dsr::DsrRouteCache > r)
Set the route cache.
Definition: dsr-routing.cc:585
bool m_subRoute
Whether to save sub route or not.
Definition: dsr-routing.h:794
Route Error (RERR) Unreachable node address option Message Format.
void ScheduleNetworkPacketRetry(DsrMaintainBuffEntry &mb, bool isFirst, uint8_t protocol)
Schedule the packet retransmission based on network layer acknowledgment.
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:688
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.
void CancelNetworkPacketTimer(DsrMaintainBuffEntry &mb)
Cancel the network packet retransmission timer for a specific maintenance entry.
uint32_t m_rreqRetries
Maximum number of retransmissions of RREQ with TTL = NetDiameter to discover a route.
Definition: dsr-routing.h:718
DsrNetworkQueue m_networkQueue
The network queue.
Definition: dsr-routing.h:830
Time m_maxRreqTime
Max time for caching the route request entry.
Definition: dsr-routing.h:740
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:770
bool FindSourceEntry(Ipv4Address src, Ipv4Address dst, uint16_t id)
functions used to direct to route cache
Definition: dsr-routing.cc:682
RxStatus
Rx status codes.
Ptr< UniformRandomVariable > m_uniformRandomVariable
Provides uniform random variables.
Definition: dsr-routing.h:838
Ptr< Node > GetNodeWithAddress(Ipv4Address ipv4Address)
Get the node with give ip address.
Definition: dsr-routing.cc:625
DsrOptionList_t m_options
List of DSR Options supported.
Definition: dsr-routing.h:684
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.
PacketType
Packet types are used as they are in Linux.
Definition: net-device.h:296
std::map< LinkKey, uint32_t > m_linkCnt
Map packet key + link forward counts.
Definition: dsr-routing.h:812
std::map< NetworkKey, uint32_t > m_addressForwardCnt
Map network key + forward counts.
Definition: dsr-routing.h:806
a unique identifier for an interface.
Definition: type-id.h:58
Time m_nonpropRequestTimeout
The non-propagation request timeout.
Definition: dsr-routing.h:710
std::map< Ipv4Address, Timer > m_nonPropReqTimer
Map IP address + RREQ timer.
Definition: dsr-routing.h:802
bool m_linkAck
define if we use link acknowledgement or not
Definition: dsr-routing.h:824
std::vector< std::string > GetElementsFromContext(std::string context)
Get the elements from the tracing context.
Definition: dsr-routing.cc:534
Ptr< dsr::DsrRreqTable > m_rreqTable
A "drop-front" queue used by the routing layer to cache route request sent.
Definition: dsr-routing.h:818
Ptr< dsr::DsrPassiveBuffer > m_passiveBuffer
A "drop-front" queue used by the routing layer to cache route request sent.
Definition: dsr-routing.h:820
std::list< Ptr< DsrOptions > > DsrOptionList_t
Define the list to hold DSR options.
Definition: dsr-routing.h:680
IpL4Protocol::DownTargetCallback m_downTarget
The callback for down layer.
Definition: dsr-routing.h:698
DsrRouting()
Constructor.
Definition: dsr-routing.cc:356
DsrSendBuffer m_sendBuffer
The send buffer.
Definition: dsr-routing.h:728
Time m_maxMaintainTime
Time out for maintenance buffer.
Definition: dsr-routing.h:734
void CancelRreqTimer(Ipv4Address dst, bool isRemove)
Cancel the route request timer.
virtual ~DsrRouting()
Destructor.
Definition: dsr-routing.cc:391