|
A Discrete-Event Network Simulator
|
API
|
Go to the documentation of this file.
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,
Time m_maxRequestPeriod
The max request period.
a unique identifier for an interface.
uint32_t m_maxSendBuffLen
The maximum number of packets that we allow a routing protocol to buffer.
uint32_t m_maxEntriesEachDst
Max number of route entries to save for each destination.
Ptr< dsr::DsrRreqTable > m_rreqTable
A "drop-front" queue used by the routing layer to cache route request sent.
void PriorityScheduler(uint32_t priority, bool continueWithFirst)
This function is called to schedule sending packets from the network queue by priority.
Time m_maxCacheTime
Max time for caching the route cache entry.
DsrMaintainBuffer m_maintainBuffer
The declaration of maintain buffer.
Ptr< UniformRandomVariable > m_uniformRandomVariable
Provides uniform random variables.
DsrSendBuffer m_sendBuffer
The send buffer.
uint16_t GetIDfromIP(Ipv4Address address)
Get the node id from ip address.
virtual ~DsrRouting()
Destructor.
uint32_t m_graReplyTableSize
Set the gratuitous reply table size.
DsrErrorBuffer m_errorBuffer
The error buffer to save the error messages.
Ptr< Ipv4Route > m_ipv4Route
Ipv4 Route.
void SendBuffTimerExpire()
The send buffer timer expire.
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.
void ScheduleLinkPacketRetry(DsrMaintainBuffEntry &mb, uint8_t protocol)
Schedule the packet retransmission based on link-layer acknowledgment.
void RouteRequestTimerExpire(Ptr< Packet > packet, std::vector< Ipv4Address > address, uint32_t requestId, uint8_t protocol)
Handle route discovery timer.
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.
void NetworkScheduleTimerExpire(DsrMaintainBuffEntry &mb, uint8_t protocol)
This function deals with packet retransmission timer expire using network acknowledgment.
DsrNetworkQueue m_networkQueue
The network queue.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
DsrRouteCacheEntry class for entries in the route cache.
bool LookupRoute(Ipv4Address id, DsrRouteCacheEntry &rt)
Lookup route cache entry with destination address dst See also DsrRouteCache::LookupRoute.
std::vector< Ipv4Address > m_addresses
The bind ipv4 addresses with next hop, src, destination address in sequence.
void CancelPacketAllTimer(DsrMaintainBuffEntry &mb)
Cancel all the packet timers.
std::vector< Ipv4Address > m_clearList
The node that is clear to send packet to.
uint32_t m_maxRreqId
The max number of request ids for a single destination.
Time m_nodeTraversalTime
Time estimated for packet to travel between two nodes.
Ipv4Address GetIPfromMAC(Mac48Address address)
Get the Ip address from mac address.
Time m_passiveAckTimeout
The timeout value for passive acknowledge.
uint32_t m_tryPassiveAcks
Maximum number of packet transmission using passive acknowledgment.
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.
std::vector< std::string > GetElementsFromContext(std::string context)
Get the elements from the tracing context.
uint16_t AddAckReqHeader(Ptr< Packet > &packet, Ipv4Address nextHop)
This function is called to add ack request header for network acknowledgement.
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.
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.
Ipv4 addresses are stored in host order in this class.
uint32_t m_passiveRetries
void LinkScheduleTimerExpire(DsrMaintainBuffEntry &mb, uint8_t protocol)
This function deals with packet retransmission timer expire using link acknowledgment.
std::vector< Ipv4Address > m_finalRoute
The route cache.
Ipv4Address SearchNextHop(Ipv4Address ipv4Address, std::vector< Ipv4Address > &vec)
Get the next hop of the route.
Time m_linkAckTimeout
The timeout value for link acknowledge.
void SendInitialRequest(Ipv4Address source, Ipv4Address destination, uint8_t protocol)
Broadcast the route request packet in subnet.
Ipv4Address m_mainAddress
Our own Ip address.
bool AddRoute_Link(DsrRouteCacheEntry::IP_VECTOR nodelist, Ipv4Address source)
dd route link to cache See also DsrRouteCache::AddRoute_Link
void CancelNetworkPacketTimer(DsrMaintainBuffEntry &mb)
Cancel the network packet retransmission timer for a specific maintenance entry.
uint32_t m_maxCacheLen
Max # of cache entries for route cache.
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,...
A simple virtual Timer class.
int64_t AssignStreams(int64_t stream)
Assign a fixed random variable stream number to the random variables used by this model.
Ptr< dsr::DsrRouteCache > GetRouteCache() const
Get the route cache.
void SendGratuitousReply(Ipv4Address replyTo, Ipv4Address replyFrom, std::vector< Ipv4Address > &nodeList, uint8_t protocol)
Send the gratuitous reply.
void PrintVector(std::vector< Ipv4Address > &vec)
Print the route vector.
DSR Maintain Buffer Entry.
std::map< Ipv4Address, Timer > m_addressReqTimer
Map IP address + RREQ timer.
maintain the gratuitous reply
uint32_t m_numPriorityQueues
The number of priority queues used.
Time m_sendBuffInterval
how often to check send buffer
Time m_gratReplyHoldoff
The max gratuitous reply hold off time.
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.
Ptr< dsr::DsrRreqTable > GetRequestTable() const
Get the request table.
bool IsLinkCache()
Checks if the link is cached in the route cache See also DsrRouteCache::IsLinkCache.
Time m_retransIncr
the increase time for retransmission timer when face network congestion
Ptr< Ipv4L3Protocol > m_ipv4
Ipv4l3Protocol.
virtual void NotifyNewAggregate()
Notify all Objects aggregated to this one of a new Object being aggregated.
Ptr< dsr::DsrPassiveBuffer > GetPassiveBuffer() const
Get the passive buffer.
a polymophic address class
std::vector< Ipv4Address > IP_VECTOR
Define the vector to hold Ip address.
Ptr< dsr::DsrPassiveBuffer > m_passiveBuffer
A "drop-front" queue used by the routing layer to cache route request sent.
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
Ptr< Node > GetNodeWithAddress(Ipv4Address ipv4Address)
Get the node with give ip address.
void ScheduleRreqRetry(Ptr< Packet > packet, std::vector< Ipv4Address > address, bool nonProp, uint32_t requestId, uint8_t protocol)
Schedule the route request retry.
static const uint8_t PROT_NUMBER
Define the dsr protocol number.
std::map< PassiveKey, Timer > m_passiveAckTimer
The timer for passive acknowledgment.
uint32_t m_requestId
The id assigned to each route request.
void SetPassiveBuffer(Ptr< dsr::DsrPassiveBuffer > r)
Set the node.
uint32_t m_discoveryHopLimit
Maximum hops to go for route request.
uint32_t m_maxMaintRexmt
Maximum number of retransmissions of data packets.
void SetNode(Ptr< Node > node)
Set the node.
uint8_t m_maxSalvageCount
Maximum # times to salvage a packet.
static TypeId GetTypeId()
Get the type identificator.
Time m_maxMaintainTime
Time out for maintenance buffer.
void SalvagePacket(Ptr< const Packet > packet, Ipv4Address source, Ipv4Address dst, uint8_t protocol)
Salvage the packet which has been transmitted for 3 times.
virtual enum IpL4Protocol::RxStatus Receive(Ptr< Packet > p, Ipv4Header const &header, Ptr< Ipv4Interface > incomingInterface)
bool UpdateRouteEntry(Ipv4Address dst)
Update route cache entry if it has been recently used and successfully delivered the data packet.
bool AddRoute(DsrRouteCacheEntry &rt)
Add route cache entry if it doesn't yet exist in route cache See also DsrRouteCache::AddRoute.
Simulation virtual time values and global simulation resolution.
void CancelPassivePacketTimer(DsrMaintainBuffEntry &mb)
Cancel the passive packet retransmission timer for a specific maintenance entry.
void SetDownTarget6(IpL4Protocol::DownTargetCallback6 callback)
This method allows a caller to set the current down target callback set for this L4 protocol (IPv6 ca...
Time m_blacklistTimeout
The black list time out.
void PacketNewRoute(Ptr< Packet > packet, Ipv4Address source, Ipv4Address destination, uint8_t protocol)
When route vector corrupted, originate a new packet, normally not happening.
std::list< Ptr< DsrOptions > > DsrOptionList_t
Define the list to hold DSR options.
Time m_minLifeTime
The min life time.
std::map< LinkKey, Timer > m_linkAckTimer
The timer for link acknowledgment.
void Insert(Ptr< dsr::DsrOptions > option)
Insert a new Dsr Option.
void SendPacket(Ptr< Packet > packet, Ipv4Address source, Ipv4Address nextHop, uint8_t protocol)
This function is called by when really sending out the packet.
DsrOptionList_t m_options
List of DSR Options supported.
Time m_initStability
The initial stability value for link cache.
std::string m_routeSortType
The type of route sort methods.
L4 Protocol abstract base class.
DsrGraReply m_graReply
The gratuitous route reply.
Ptr< Node > m_node
The node ptr.
void ScheduleNetworkPacketRetry(DsrMaintainBuffEntry &mb, bool isFirst, uint8_t protocol)
Schedule the packet retransmission based on network layer acknowledgment.
uint8_t segsLeft
The segment left value from SR header.
uint32_t m_broadcastJitter
The max time to delay route request broadcast.
void SetRequestTable(Ptr< dsr::DsrRreqTable > r)
Set the node.
Time m_nonpropRequestTimeout
The non-propagation request timeout.
bool SendRealDown(DsrNetworkQueueEntry &newEntry)
This function is called to send packets down stack.
uint16_t m_ackId
The ack id assigned to each acknowledge.
std::map< Ipv4Address, Timer > m_nonPropReqTimer
Map IP address + RREQ timer.
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_maxRreqTime
Max time for caching the route request entry.
IpL4Protocol::DownTargetCallback GetDownTarget(void) const
This method allows a caller to get the current down target callback set for this L4 protocol (IPv4 ca...
Timer m_sendBuffTimer
The send buffer timer.
std::string m_cacheType
The type of route cache.
IpL4Protocol::DownTargetCallback m_downTarget
The callback for down layer.
bool FindSourceEntry(Ipv4Address src, Ipv4Address dst, uint16_t id)
Find the source request entry in the route request queue, return false if not found.
std::map< PassiveKey, uint32_t > m_passiveCnt
Map packet key + passive forward counts.
Ipv4Address m_broadcast
The broadcast IP address.
uint32_t m_stabilityIncrFactor
The initial increase factor for link cache.
Ptr< NetDevice > GetNetDeviceFromContext(std::string context)
Get the netdevice from the context.
void CancelPacketTimerNextHop(Ipv4Address nextHop, uint8_t protocol)
Cancel the packet retransmission timer for a all maintenance entries with nextHop address.
Time m_sendBufferTimeout
The maximum period of time that a routing protocol is allowed to buffer a packet for.
Ptr< dsr::DsrRouteCache > m_routeCache
A "drop-front" queue used by the routing layer to cache routes found.
void SetDownTarget(IpL4Protocol::DownTargetCallback callback)
This method allows a caller to set the current down target callback set for this L4 protocol (IPv4 ca...
bool m_subRoute
Whether to save sub route or not.
Time m_maxNetworkDelay
Maximum network delay.
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.
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.
bool m_linkAck
define if we use link acknowledgement or not
void SchedulePassivePacketRetry(DsrMaintainBuffEntry &mb, uint8_t protocol)
Schedule the packet retransmission based on passive acknowledgment.
void CallCancelPacketTimer(uint16_t ackId, Ipv4Header const &ipv4Header, Ipv4Address realSrc, Ipv4Address realDst)
Call the cancel packet retransmission timer function.
std::map< NetworkKey, Timer > m_addressForwardTimer
Map network key + forward timer.
TracedCallback< Ptr< const Packet > > m_dropTrace
The trace for drop, receive and send data packets.
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.
Time m_useExtends
The use extension of the life time for link cache.
Ptr< Node > GetNode() const
Get the node.
void CancelLinkPacketTimer(DsrMaintainBuffEntry &mb)
Cancel the link packet retransmission timer for a specific maintenance entry.
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.
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.
uint32_t m_maxNetworkSize
Maximum network queue size.
void(* Time)(Time oldValue, Time newValue)
TracedValue callback signature for Time.
Forward calls to a chain of Callback.
void Scheduler(uint32_t priority)
This function is called to schedule sending packets from the network queue.
uint32_t m_requestTableSize
The max size of the request table size.
std::map< NetworkKey, uint32_t > m_addressForwardCnt
Map network key + forward counts.
uint32_t m_requestTableIds
The request table identifiers.
virtual void DoDispose(void)
Drop trace callback.
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.
void ScheduleInterRequest(Ptr< Packet > packet)
Schedule the intermediate route request.
Ptr< Ipv4 > m_ip
The ip ptr.
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.
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,...
TracedCallback< const DsrOptionSRHeader & > m_txPacketTrace
packet trace callback
void CancelRreqTimer(Ipv4Address dst, bool isRemove)
Cancel the route request timer.
IpL4Protocol::DownTargetCallback6 GetDownTarget6(void) const
This method allows a caller to get the current down target callback set for this L4 protocol (IPv6 ca...
Introspection did not find any typical Config paths.
Ptr< dsr::DsrOptions > GetOption(int optionNumber)
Get the option corresponding to optionNumber.
int GetProtocolNumber(void) const
Get the dsr protocol number.
void UseExtends(DsrRouteCacheEntry::IP_VECTOR rt)
Extends the lifetime of a route cache entry.
void SetRouteCache(Ptr< dsr::DsrRouteCache > r)
Set the route cache.
uint32_t GetPriority(DsrMessageType messageType)
Set the priority of the packet in network queue.
Time m_requestPeriod
The base time interval between route requests.
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...
uint32_t m_rreqRetries
Maximum number of retransmissions of RREQ with TTL = NetDiameter to discover a route.
std::map< std::string, uint32_t > m_macToNodeIdMap
The map of mac address to node id.
bool CancelPassiveTimer(Ptr< Packet > packet, Ipv4Address source, Ipv4Address destination, uint8_t segsLeft)
Cancel the passive timer.
void PassiveScheduleTimerExpire(DsrMaintainBuffEntry &mb, uint8_t protocol)
This function deals with packet retransmission timer expire using passive acknowledgment.
void IncreaseRetransTimer()
This function is called to increase the retransmission timer for data packet in the network queue.