40 #include <sys/types.h> 42 #include "ns3/callback.h" 43 #include "ns3/object.h" 46 #include "ns3/buffer.h" 47 #include "ns3/packet.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" 407 uint16_t fragmentOffset, uint16_t identification,
bool saveEntry);
559 std::vector<Ipv4Address> &nodeList,
void SendRerrWhenBreaksLinkToNextHop(Ipv4Address nextHop, uint8_t protocol)
Send the route error message when the link breaks to the next hop.
uint32_t m_stabilityDecrFactor
The initial decrease factor for link cache.
void SetDownTarget(IpL4Protocol::DownTargetCallback callback)
This method allows a caller to set the current down target callback set for this L4 protocol (IPv4 ca...
void UseExtends(DsrRouteCacheEntry::IP_VECTOR rt)
Extends the lifetime of a route cache entry.
void SetRequestTable(Ptr< dsr::DsrRreqTable > r)
Set the node.
std::string m_cacheType
The type of route cache.
Simulation virtual time values and global simulation resolution.
maintain the gratuitous reply
DsrRouteCacheEntry class for entries in the route cache.
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.
uint32_t m_maxSendBuffLen
The maximum number of packets that we allow a routing protocol to buffer.
void ScheduleInterRequest(Ptr< Packet > packet)
Schedule the intermediate route request.
uint32_t m_stabilityIncrFactor
The initial increase factor for link cache.
A simple virtual Timer class.
bool LookupRoute(Ipv4Address id, DsrRouteCacheEntry &rt)
Lookup route cache entry with destination address dst See also DsrRouteCache::LookupRoute.
void SendInitialRequest(Ipv4Address source, Ipv4Address destination, uint8_t protocol)
Broadcast the route request packet in subnet.
void SendBuffTimerExpire()
The send buffer timer expire.
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
Time m_passiveAckTimeout
The timeout value for passive acknowledge.
std::map< std::string, uint32_t > m_macToNodeIdMap
The map of mac address to node id.
uint32_t m_discoveryHopLimit
Maximum hops to go for route request.
uint32_t GetPriority(DsrMessageType messageType)
Set the priority of the packet in network queue.
Ptr< Ipv4 > m_ip
The ip ptr.
Forward calls to a chain of Callback.
TracedCallback< const DsrOptionSRHeader & > m_txPacketTrace
packet trace callback
Ptr< dsr::DsrRouteCache > GetRouteCache() const
Get the route cache.
void DeleteAllRoutesIncludeLink(Ipv4Address errorSrc, Ipv4Address unreachNode, Ipv4Address node)
Delete all the routes which includes the link from next hop address that has just been notified as un...
Time m_maxRequestPeriod
The max request period.
void PrintVector(std::vector< Ipv4Address > &vec)
Print the route vector.
uint32_t m_maxEntriesEachDst
Max number of route entries to save for each destination.
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.
Ipv4Address SearchNextHop(Ipv4Address ipv4Address, std::vector< Ipv4Address > &vec)
Get the next hop of the route.
void CancelPacketAllTimer(DsrMaintainBuffEntry &mb)
Cancel all the packet timers.
void(* Time)(Time oldValue, Time newValue)
TracedValue callback signature for Time.
bool IsLinkCache()
Checks if the link is cached in the route cache See also DsrRouteCache::IsLinkCache.
Time m_linkAckTimeout
The timeout value for link acknowledge.
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.
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.
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.
Time m_gratReplyHoldoff
The max gratuitous reply hold off time.
a polymophic address class
uint32_t m_maxMaintainLen
Max # of entries for maintenance buffer.
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.
std::vector< Ipv4Address > m_finalRoute
The route cache.
static TypeId GetTypeId()
Get the type identificator.
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.
bool AddRoute(DsrRouteCacheEntry &rt)
Add route cache entry if it doesn't yet exist in route cache See also DsrRouteCache::AddRoute.
DsrMaintainBuffer m_maintainBuffer
The declaration of maintain buffer.
Time m_maxNetworkDelay
Maximum network delay.
Ptr< dsr::DsrRreqTable > GetRequestTable() const
Get the request table.
uint16_t m_ackId
The ack id assigned to each acknowledge.
DsrGraReply m_graReply
The gratuitous route reply.
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.
Ipv4Address m_broadcast
The broadcast IP address.
uint32_t m_numPriorityQueues
The number of priority queues used.
uint32_t m_broadcastJitter
The max time to delay route request broadcast.
void ScheduleLinkPacketRetry(DsrMaintainBuffEntry &mb, uint8_t protocol)
Schedule the packet retransmission based on link-layer acknowledgment.
void SetNode(Ptr< Node > node)
Set the node.
static const uint8_t PROT_NUMBER
Define the dsr protocol number.
uint32_t m_requestId
The id assigned to each route request.
DsrErrorBuffer m_errorBuffer
The error buffer to save the error messages.
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.
uint32_t m_requestTableIds
The request table identifiers.
bool AddRoute_Link(DsrRouteCacheEntry::IP_VECTOR nodelist, Ipv4Address source)
dd route link to cache See also DsrRouteCache::AddRoute_Link
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.
bool UpdateRouteEntry(Ipv4Address dst)
Update route cache entry if it has been recently used and successfully delivered the data packet...
Time m_minLifeTime
The min life time.
std::vector< Ipv4Address > IP_VECTOR
Define the vector to hold Ip address.
Time m_useExtends
The use extension of the life time for link cache.
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.
Time m_blacklistTimeout
The black list time out.
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.
std::map< Ipv4Address, Timer > m_addressReqTimer
Map IP address + RREQ timer.
void SetPassiveBuffer(Ptr< dsr::DsrPassiveBuffer > r)
Set the node.
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.
Time m_initStability
The initial stability value for link cache.
Time m_requestPeriod
The base time interval between route requests.
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.
Ptr< Node > m_node
The node ptr.
void CallCancelPacketTimer(uint16_t ackId, Ipv4Header const &ipv4Header, Ipv4Address realSrc, Ipv4Address realDst)
Call the cancel packet retransmission timer function.
uint32_t m_passiveRetries
uint32_t m_maxNetworkSize
Maximum network queue size.
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...
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.
Ptr< NetDevice > GetNetDeviceFromContext(std::string context)
Get the netdevice from the context.
uint32_t m_maxMaintRexmt
Maximum number of retransmissions of data packets.
Ptr< dsr::DsrPassiveBuffer > GetPassiveBuffer() const
Get the passive buffer.
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.
Time m_retransIncr
the increase time for retransmission timer when face network congestion
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.
L4 Protocol abstract base class.
std::vector< Ipv4Address > m_clearList
The node that is clear to send packet to.
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.
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.
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.
uint32_t m_maxCacheLen
Max # of cache entries for route cache.
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.
void CheckSendBuffer()
Check the send buffer of packets with route when send buffer timer expire.
std::map< uint32_t, Ptr< dsr::DsrNetworkQueue > > m_priorityQueue
priority queues
std::map< PassiveKey, uint32_t > m_passiveCnt
Map packet key + passive forward counts.
Ipv4 addresses are stored in host order in this class.
virtual void NotifyNewAggregate()
Notify all Objects aggregated to this one of a new Object being aggregated.
TracedCallback< Ptr< const Packet > > m_dropTrace
The trace for drop, receive and send data packets.
std::map< PassiveKey, Timer > m_passiveAckTimer
The timer for passive acknowledgment.
Ptr< Node > GetNode() const
Get the node.
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.
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.
void SetRouteCache(Ptr< dsr::DsrRouteCache > r)
Set the route cache.
bool m_subRoute
Whether to save sub route or not.
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.
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.
DsrNetworkQueue m_networkQueue
The network queue.
Time m_maxRreqTime
Max time for caching the route request entry.
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.
bool FindSourceEntry(Ipv4Address src, Ipv4Address dst, uint16_t id)
Find the source request entry in the route request queue, return false if not found.
Ptr< UniformRandomVariable > m_uniformRandomVariable
Provides uniform random variables.
Ptr< Node > GetNodeWithAddress(Ipv4Address ipv4Address)
Get the node with give ip address.
DsrOptionList_t m_options
List of DSR Options supported.
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.
std::map< LinkKey, uint32_t > m_linkCnt
Map packet key + link forward counts.
std::map< NetworkKey, uint32_t > m_addressForwardCnt
Map network key + forward counts.
a unique identifier for an interface.
Time m_nonpropRequestTimeout
The non-propagation request timeout.
std::map< Ipv4Address, Timer > m_nonPropReqTimer
Map IP address + RREQ timer.
bool m_linkAck
define if we use link acknowledgement or not
std::vector< std::string > GetElementsFromContext(std::string context)
Get the elements from the tracing context.
Ptr< dsr::DsrRreqTable > m_rreqTable
A "drop-front" queue used by the routing layer to cache route request sent.
Ptr< dsr::DsrPassiveBuffer > m_passiveBuffer
A "drop-front" queue used by the routing layer to cache route request sent.
std::list< Ptr< DsrOptions > > DsrOptionList_t
Define the list to hold DSR options.
IpL4Protocol::DownTargetCallback m_downTarget
The callback for down layer.
DsrSendBuffer m_sendBuffer
The send buffer.
Time m_maxMaintainTime
Time out for maintenance buffer.
void CancelRreqTimer(Ipv4Address dst, bool isRemove)
Cancel the route request timer.
virtual ~DsrRouting()
Destructor.