author | Mitch Watrous <watrous@u.washington.edu> |
Sun, 02 Jun 2013 09:27:30 -0700 | |
changeset 9821 | c5b83fec4d30 |
parent 9719 | 4031f7fdce5c |
child 10405 | 45c8fceae24e |
permissions | -rw-r--r-- |
8751 | 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" |
|
8753 | 49 |
#include "ns3/ip-l4-protocol.h" |
8751 | 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" |
|
8976
4df4e7cd077f
Replace src/dsr usage of RandomVariable with RandomVariableStream
Mitch Watrous
parents:
8756
diff
changeset
|
56 |
#include "ns3/random-variable-stream.h" |
8751 | 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 |
||
8752 | 66 |
#include "dsr-network-queue.h" |
8751 | 67 |
#include "dsr-rcache.h" |
68 |
#include "dsr-rreq-table.h" |
|
69 |
#include "dsr-maintain-buff.h" |
|
9293
854e085e1a01
bug 1608: DSR network ack and bug 1609: DSR route request table
Yufei Cheng <yfcheng@ittc.ku.edu>
parents:
9253
diff
changeset
|
70 |
#include "dsr-passive-buff.h" |
8751 | 71 |
#include "dsr-option-header.h" |
72 |
#include "dsr-fs-header.h" |
|
73 |
#include "dsr-rsendbuff.h" |
|
8752 | 74 |
#include "dsr-errorbuff.h" |
8751 | 75 |
#include "dsr-gratuitous-reply-table.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; |
|
91 |
/** |
|
92 |
* \class DsrRouting |
|
93 |
* \brief Dsr Routing base |
|
94 |
*/ |
|
8753 | 95 |
class DsrRouting : public IpL4Protocol |
8751 | 96 |
{ |
97 |
public: |
|
98 |
/** |
|
99 |
* \brief Get the type identificator. |
|
100 |
* \return type identificator |
|
101 |
*/ |
|
102 |
static TypeId GetTypeId (); |
|
103 |
/** |
|
104 |
* \brief Define the dsr protocol number. |
|
105 |
*/ |
|
106 |
static const uint8_t PROT_NUMBER; |
|
107 |
/** |
|
108 |
* \brief Constructor. |
|
109 |
*/ |
|
110 |
DsrRouting (); |
|
111 |
/** |
|
112 |
* \brief Destructor. |
|
113 |
*/ |
|
114 |
virtual ~DsrRouting (); |
|
115 |
/** |
|
116 |
* \brief Get the node. |
|
117 |
* \return the node |
|
118 |
*/ |
|
119 |
Ptr<Node> GetNode () const; |
|
120 |
/** |
|
121 |
* \brief Set the node. |
|
122 |
* \param node the node to set |
|
123 |
*/ |
|
124 |
void SetNode (Ptr<Node> node); |
|
125 |
/** |
|
126 |
* \brief Set the route cache. |
|
127 |
* \param the route cache to set |
|
128 |
*/ |
|
129 |
void SetRouteCache (Ptr<dsr::RouteCache> r); |
|
130 |
/** |
|
131 |
* \brief Get the route cache. |
|
132 |
* \return the route cache |
|
133 |
*/ |
|
134 |
Ptr<dsr::RouteCache> GetRouteCache () const; |
|
135 |
/** |
|
136 |
* \brief Set the node. |
|
137 |
* \param the request table to set |
|
138 |
*/ |
|
139 |
void SetRequestTable (Ptr<dsr::RreqTable> r); |
|
140 |
/** |
|
141 |
* \brief Get the request table. |
|
142 |
* \return the request table |
|
143 |
*/ |
|
144 |
Ptr<dsr::RreqTable> GetRequestTable () const; |
|
9293
854e085e1a01
bug 1608: DSR network ack and bug 1609: DSR route request table
Yufei Cheng <yfcheng@ittc.ku.edu>
parents:
9253
diff
changeset
|
145 |
/** |
854e085e1a01
bug 1608: DSR network ack and bug 1609: DSR route request table
Yufei Cheng <yfcheng@ittc.ku.edu>
parents:
9253
diff
changeset
|
146 |
* \brief Set the node. |
854e085e1a01
bug 1608: DSR network ack and bug 1609: DSR route request table
Yufei Cheng <yfcheng@ittc.ku.edu>
parents:
9253
diff
changeset
|
147 |
* \param the passive buffer to set |
854e085e1a01
bug 1608: DSR network ack and bug 1609: DSR route request table
Yufei Cheng <yfcheng@ittc.ku.edu>
parents:
9253
diff
changeset
|
148 |
*/ |
854e085e1a01
bug 1608: DSR network ack and bug 1609: DSR route request table
Yufei Cheng <yfcheng@ittc.ku.edu>
parents:
9253
diff
changeset
|
149 |
void SetPassiveBuffer (Ptr<dsr::PassiveBuffer> r); |
854e085e1a01
bug 1608: DSR network ack and bug 1609: DSR route request table
Yufei Cheng <yfcheng@ittc.ku.edu>
parents:
9253
diff
changeset
|
150 |
/** |
854e085e1a01
bug 1608: DSR network ack and bug 1609: DSR route request table
Yufei Cheng <yfcheng@ittc.ku.edu>
parents:
9253
diff
changeset
|
151 |
* \brief Get the passive buffer |
854e085e1a01
bug 1608: DSR network ack and bug 1609: DSR route request table
Yufei Cheng <yfcheng@ittc.ku.edu>
parents:
9253
diff
changeset
|
152 |
* \return the passive buffer |
854e085e1a01
bug 1608: DSR network ack and bug 1609: DSR route request table
Yufei Cheng <yfcheng@ittc.ku.edu>
parents:
9253
diff
changeset
|
153 |
*/ |
854e085e1a01
bug 1608: DSR network ack and bug 1609: DSR route request table
Yufei Cheng <yfcheng@ittc.ku.edu>
parents:
9253
diff
changeset
|
154 |
Ptr<dsr::PassiveBuffer> GetPassiveBuffer () const; |
8752 | 155 |
|
156 |
///\functions used to direct to route cache |
|
157 |
//\{ |
|
158 |
bool IsLinkCache (); |
|
159 |
void UseExtends (RouteCacheEntry::IP_VECTOR rt); |
|
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); |
|
9293
854e085e1a01
bug 1608: DSR network ack and bug 1609: DSR route request table
Yufei Cheng <yfcheng@ittc.ku.edu>
parents:
9253
diff
changeset
|
165 |
bool FindSourceEntry (Ipv4Address src, Ipv4Address dst, uint16_t id); |
8752 | 166 |
//\} |
167 |
||
8751 | 168 |
/** |
9719 | 169 |
* \brief Connect the callback for the tracing event. |
170 |
* \return void |
|
171 |
*/ |
|
172 |
void ConnectCallbacks (); |
|
173 |
/** |
|
174 |
* \brief Get the netdevice from the context. |
|
175 |
* \return the netdevice we are looking for |
|
176 |
*/ |
|
177 |
Ptr<NetDevice> GetNetDeviceFromContext (std::string context); |
|
178 |
/** |
|
179 |
* \brief Get the elements from the tracing context. |
|
180 |
* \return the elements we are looking for |
|
181 |
*/ |
|
182 |
std::vector<std::string> GetElementsFromContext (std::string context); |
|
183 |
/** |
|
8751 | 184 |
* \brief Get the node id from ip address. |
185 |
* \return the node id |
|
186 |
*/ |
|
8752 | 187 |
uint16_t GetIDfromIP (Ipv4Address address); |
8751 | 188 |
/** |
189 |
* \brief Get the ip address from id. |
|
190 |
* \return the ip address for the id |
|
191 |
*/ |
|
8752 | 192 |
Ipv4Address GetIPfromID (uint16_t id); |
8751 | 193 |
/** |
194 |
* \brief Get the Ip address from mac address. |
|
195 |
* \return the ip address |
|
196 |
*/ |
|
197 |
Ipv4Address GetIPfromMAC (Mac48Address address); |
|
198 |
/** |
|
9719 | 199 |
* \brief Get the node with give ip address. |
200 |
* \return the node associated with the ip address |
|
201 |
*/ |
|
202 |
Ptr<Node> GetNodeWithAddress (Ipv4Address ipv4Address); |
|
203 |
/** |
|
8751 | 204 |
* \brief Print the route vector. |
205 |
*/ |
|
206 |
void PrintVector (std::vector<Ipv4Address>& vec); |
|
207 |
/** |
|
208 |
* \brief Get the next hop of the route. |
|
209 |
* \return the next hop address of the route |
|
210 |
*/ |
|
211 |
Ipv4Address SearchNextHop (Ipv4Address ipv4Address, std::vector<Ipv4Address>& vec); |
|
212 |
/** |
|
213 |
* \brief Get the dsr protocol number. |
|
214 |
* \return protocol number |
|
215 |
*/ |
|
216 |
int GetProtocolNumber (void) const; |
|
217 |
/** |
|
218 |
* \brief The send buffer timer expire. |
|
219 |
*/ |
|
220 |
void SendBuffTimerExpire (); |
|
221 |
/** |
|
222 |
* \brief Check the send buffer of packets with route when send buffer timer expire. |
|
223 |
*/ |
|
224 |
void CheckSendBuffer (); |
|
225 |
/** |
|
226 |
* \brief When route vector corrupted, originate a new packet, normally not happening. |
|
227 |
*/ |
|
228 |
void PacketNewRoute (Ptr<Packet> packet, |
|
229 |
Ipv4Address source, |
|
230 |
Ipv4Address destination, |
|
231 |
uint8_t protocol); |
|
9719 | 232 |
/** |
8751 | 233 |
* \brief Set the route to use for data packets |
234 |
* \return the route |
|
235 |
* \used by the option headers when sending data/control packets |
|
236 |
*/ |
|
237 |
Ptr<Ipv4Route> SetRoute (Ipv4Address nextHop, Ipv4Address srcAddress); |
|
9719 | 238 |
/** |
8752 | 239 |
* \brief Set the priority of the packet in network queue |
240 |
* \return the priority value |
|
241 |
*/ |
|
242 |
uint32_t GetPriority (DsrMessageType messageType); |
|
9719 | 243 |
/** |
8751 | 244 |
* \brief This function is responsible for sending error packets in case of break link to next hop |
245 |
*/ |
|
8752 | 246 |
void SendUnreachError (Ipv4Address errorHop, Ipv4Address destination, Ipv4Address originalDst, uint8_t salvage, uint8_t protocol); |
9719 | 247 |
/** |
8751 | 248 |
* \brief This function is responsible for forwarding error packets along the route |
249 |
*/ |
|
250 |
void ForwardErrPacket (DsrOptionRerrUnreachHeader &rerr, |
|
251 |
DsrOptionSRHeader &sourceRoute, |
|
252 |
Ipv4Address nextHop, |
|
253 |
uint8_t protocol, |
|
254 |
Ptr<Ipv4Route> route); |
|
9719 | 255 |
/** |
8751 | 256 |
* \brief This function is called by higher layer protocol when sending packets |
257 |
*/ |
|
258 |
void Send (Ptr<Packet> packet, Ipv4Address source, |
|
259 |
Ipv4Address destination, uint8_t protocol, Ptr<Ipv4Route> route); |
|
9719 | 260 |
/** |
8752 | 261 |
* \brief This function is called to add ack request header for network acknowledgement |
262 |
*/ |
|
263 |
uint16_t AddAckReqHeader (Ptr<Packet> &packet, Ipv4Address nextHop); |
|
9719 | 264 |
/** |
8752 | 265 |
* \brief This function is called by when really sending out the packet |
266 |
*/ |
|
267 |
void SendPacket (Ptr<Packet> packet, Ipv4Address source, Ipv4Address nextHop, uint8_t protocol); |
|
9719 | 268 |
/** |
8752 | 269 |
* \brief This function is called to schedule sending packets from the network queue |
270 |
*/ |
|
271 |
void Scheduler (uint32_t priority); |
|
9719 | 272 |
/** |
8752 | 273 |
* \brief This function is called to schedule sending packets from the network queue by priority |
274 |
*/ |
|
275 |
void PriorityScheduler (uint32_t priority, bool continueWithFirst); |
|
9719 | 276 |
/** |
8752 | 277 |
* \brief This function is called to increase the retransmission timer for data packet in the network queue |
278 |
*/ |
|
279 |
void IncreaseRetransTimer (); |
|
9719 | 280 |
/** |
8752 | 281 |
* \brief This function is called to send packets down stack |
282 |
*/ |
|
283 |
bool SendRealDown (DsrNetworkQueueEntry & newEntry); |
|
9719 | 284 |
/** |
285 |
* \brief This function is responsible for sending out data packets when have route, if no route found, it will |
|
8751 | 286 |
* cache the packet and send out route requests |
287 |
*/ |
|
8752 | 288 |
void SendPacketFromBuffer (DsrOptionSRHeader const &sourceRoute, |
289 |
Ipv4Address nextHop, |
|
290 |
uint8_t protocol); |
|
9293
854e085e1a01
bug 1608: DSR network ack and bug 1609: DSR route request table
Yufei Cheng <yfcheng@ittc.ku.edu>
parents:
9253
diff
changeset
|
291 |
/** |
854e085e1a01
bug 1608: DSR network ack and bug 1609: DSR route request table
Yufei Cheng <yfcheng@ittc.ku.edu>
parents:
9253
diff
changeset
|
292 |
* \brief Find the same passive entry |
854e085e1a01
bug 1608: DSR network ack and bug 1609: DSR route request table
Yufei Cheng <yfcheng@ittc.ku.edu>
parents:
9253
diff
changeset
|
293 |
*/ |
854e085e1a01
bug 1608: DSR network ack and bug 1609: DSR route request table
Yufei Cheng <yfcheng@ittc.ku.edu>
parents:
9253
diff
changeset
|
294 |
bool PassiveEntryCheck (Ptr<Packet> packet, Ipv4Address source, Ipv4Address destination, uint8_t segsLeft, |
9719 | 295 |
uint16_t fragmentOffset, uint16_t identification, bool saveEntry); |
9293
854e085e1a01
bug 1608: DSR network ack and bug 1609: DSR route request table
Yufei Cheng <yfcheng@ittc.ku.edu>
parents:
9253
diff
changeset
|
296 |
/** |
854e085e1a01
bug 1608: DSR network ack and bug 1609: DSR route request table
Yufei Cheng <yfcheng@ittc.ku.edu>
parents:
9253
diff
changeset
|
297 |
* \brief Cancel the passive timer |
854e085e1a01
bug 1608: DSR network ack and bug 1609: DSR route request table
Yufei Cheng <yfcheng@ittc.ku.edu>
parents:
9253
diff
changeset
|
298 |
*/ |
854e085e1a01
bug 1608: DSR network ack and bug 1609: DSR route request table
Yufei Cheng <yfcheng@ittc.ku.edu>
parents:
9253
diff
changeset
|
299 |
bool CancelPassiveTimer (Ptr<Packet> packet, Ipv4Address source, Ipv4Address destination, uint8_t segsLeft); |
9719 | 300 |
/** |
301 |
* \brief Call the cancel packet retransmission timer function |
|
8751 | 302 |
*/ |
303 |
void CallCancelPacketTimer (uint16_t ackId, Ipv4Header const& ipv4Header, Ipv4Address realSrc, Ipv4Address realDst); |
|
9719 | 304 |
/** |
305 |
* \brief Cancel the network packet retransmission timer for a specific maintenance entry |
|
8751 | 306 |
*/ |
307 |
void CancelNetworkPacketTimer (MaintainBuffEntry & mb); |
|
9719 | 308 |
/** |
309 |
* \brief Cancel the passive packet retransmission timer for a specific maintenance entry |
|
8751 | 310 |
*/ |
311 |
void CancelPassivePacketTimer (MaintainBuffEntry & mb); |
|
9719 | 312 |
/** |
313 |
* \brief Cancel the link packet retransmission timer for a specific maintenance entry |
|
314 |
*/ |
|
315 |
void CancelLinkPacketTimer (MaintainBuffEntry & mb); |
|
316 |
/** |
|
317 |
* \brief Cancel the packet retransmission timer for a all maintenance entries with nextHop address |
|
8751 | 318 |
*/ |
319 |
void CancelPacketTimerNextHop (Ipv4Address nextHop, uint8_t protocol); |
|
9719 | 320 |
/** |
321 |
* \brief Salvage the packet which has been transmitted for 3 times |
|
8751 | 322 |
*/ |
323 |
void SalvagePacket (Ptr<const Packet> packet, Ipv4Address source, Ipv4Address dst, uint8_t protocol); |
|
9719 | 324 |
/** |
325 |
* \brief Schedule the packet retransmission based on link-layer acknowledgment |
|
326 |
* \param mb maintainenace buffer entry |
|
327 |
* \param protocol the protocol number |
|
328 |
*/ |
|
329 |
void ScheduleLinkPacketRetry (MaintainBuffEntry & mb, |
|
330 |
uint8_t protocol); |
|
331 |
/** |
|
332 |
* \brief Schedule the packet retransmission based on passive acknowledgment |
|
333 |
* \param mb maintainenace buffer entry |
|
334 |
* \param protocol the protocol number |
|
8751 | 335 |
*/ |
8752 | 336 |
void SchedulePassivePacketRetry (MaintainBuffEntry & mb, |
337 |
uint8_t protocol); |
|
9719 | 338 |
/** |
339 |
* \brief Schedule the packet retransmission based on network layer acknowledgment |
|
340 |
* \param mb maintainenace buffer entry |
|
341 |
* \param isFirst see if this is the first packet retry or not |
|
342 |
* \param protocol the protocol number |
|
8751 | 343 |
*/ |
8752 | 344 |
void ScheduleNetworkPacketRetry (MaintainBuffEntry & mb, |
345 |
bool isFirst, |
|
346 |
uint8_t protocol); |
|
9719 | 347 |
/** |
348 |
* \brief This function deals with packet retransmission timer expire using link acknowledgment |
|
349 |
*/ |
|
350 |
void LinkScheduleTimerExpire (MaintainBuffEntry & mb, |
|
351 |
uint8_t protocol); |
|
352 |
/** |
|
353 |
* \brief This function deals with packet retransmission timer expire using network acknowledgment |
|
8751 | 354 |
*/ |
8752 | 355 |
void NetworkScheduleTimerExpire (MaintainBuffEntry & mb, |
356 |
uint8_t protocol); |
|
9719 | 357 |
/** |
358 |
* \brief This function deals with packet retransmission timer expire using passive acknowledgment |
|
8752 | 359 |
*/ |
360 |
void PassiveScheduleTimerExpire (MaintainBuffEntry & mb, |
|
361 |
uint8_t protocol); |
|
9719 | 362 |
/** |
363 |
* \brief Forward the packet using the route saved in the source route option header |
|
8751 | 364 |
*/ |
365 |
void ForwardPacket (Ptr<const Packet> packet, |
|
366 |
DsrOptionSRHeader &sourceRoute, |
|
367 |
Ipv4Header const& ipv4Header, |
|
368 |
Ipv4Address source, |
|
369 |
Ipv4Address destination, |
|
370 |
Ipv4Address targetAddress, |
|
371 |
uint8_t protocol, |
|
372 |
Ptr<Ipv4Route> route); |
|
9719 | 373 |
/** |
374 |
* \brief Broadcast the route request packet in subnet |
|
8751 | 375 |
*/ |
376 |
void SendInitialRequest (Ipv4Address source, |
|
377 |
Ipv4Address destination, |
|
378 |
uint8_t protocol); |
|
9719 | 379 |
/** |
8751 | 380 |
* \brief Send the error request packet |
381 |
* \param the route error header |
|
382 |
* \param the protocol number |
|
383 |
*/ |
|
384 |
void SendErrorRequest (DsrOptionRerrUnreachHeader &rerr, uint8_t protocol); |
|
9719 | 385 |
/** |
8751 | 386 |
* \brief Forward the route request if the node is not the destination |
387 |
* \param the original packet |
|
388 |
* \param source address |
|
389 |
*/ |
|
390 |
void SendRequest (Ptr<Packet> packet, |
|
391 |
Ipv4Address source); |
|
9719 | 392 |
/** |
8751 | 393 |
* \brief Schedule the intermediate route request |
394 |
* \param the original packet |
|
395 |
* \param source The source address |
|
396 |
* \param destination The destination address |
|
397 |
*/ |
|
398 |
void ScheduleInterRequest (Ptr<Packet> packet); |
|
9719 | 399 |
/** |
8751 | 400 |
* \brief Send the gratuitous reply |
401 |
* \param replyTo The destination address to send the reply to |
|
402 |
* \param replyFrom The source address sending the reply |
|
403 |
*/ |
|
404 |
void SendGratuitousReply (Ipv4Address replyTo, |
|
405 |
Ipv4Address replyFrom, |
|
406 |
std::vector<Ipv4Address> &nodeList, |
|
407 |
uint8_t protocol); |
|
9719 | 408 |
/** |
8751 | 409 |
* Send the route reply back to the request originator with the cumulated route |
410 |
*/ |
|
411 |
void SendReply (Ptr<Packet> packet, |
|
412 |
Ipv4Address source, |
|
413 |
Ipv4Address nextHop, |
|
414 |
Ptr<Ipv4Route> route); |
|
9719 | 415 |
/** |
8751 | 416 |
* this is a generating the initial route reply from the destination address, a random delay time |
417 |
* [0, m_broadcastJitter] is used before unicasting back the route reply packet |
|
418 |
*/ |
|
419 |
void ScheduleInitialReply (Ptr<Packet> packet, |
|
420 |
Ipv4Address source, |
|
421 |
Ipv4Address nextHop, |
|
422 |
Ptr<Ipv4Route> route); |
|
9719 | 423 |
/** |
8751 | 424 |
* Schedule the cached reply to a random start time to avoid possible route reply storm |
425 |
*/ |
|
426 |
void ScheduleCachedReply (Ptr<Packet> packet, |
|
427 |
Ipv4Address source, |
|
428 |
Ipv4Address destination, |
|
429 |
Ptr<Ipv4Route> route, |
|
8752 | 430 |
double hops); |
9719 | 431 |
/** |
8751 | 432 |
* Send network layer acknowledgment back to the earlier hop to notify the receipt of data packet |
433 |
*/ |
|
434 |
void SendAck (uint16_t ackId, |
|
435 |
Ipv4Address destination, |
|
436 |
Ipv4Address realSrc, |
|
437 |
Ipv4Address realDst, |
|
438 |
uint8_t protocol, |
|
439 |
Ptr<Ipv4Route> route); |
|
440 |
/** |
|
441 |
* \param p packet to forward up |
|
442 |
* \param header IPv4 Header information |
|
443 |
* \param incomingInterface the Ipv4Interface on which the packet arrived |
|
444 |
* |
|
445 |
* Called from lower-level layers to send the packet up |
|
446 |
* in the stack. |
|
447 |
*/ |
|
8753 | 448 |
virtual enum IpL4Protocol::RxStatus Receive (Ptr<Packet> p, |
8756
9a34e618f40b
check-style.py run on src/dsr
Tom Henderson <tomh@tomh.org>
parents:
8753
diff
changeset
|
449 |
Ipv4Header const &header, |
9a34e618f40b
check-style.py run on src/dsr
Tom Henderson <tomh@tomh.org>
parents:
8753
diff
changeset
|
450 |
Ptr<Ipv4Interface> incomingInterface); |
8751 | 451 |
|
8753 | 452 |
/** |
453 |
* \param p packet to forward up |
|
9145
5752b425cdf5
Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents:
8976
diff
changeset
|
454 |
* \param header IPv6 Header information |
8753 | 455 |
* \param incomingInterface the Ipv6Interface on which the packet arrived |
456 |
* |
|
457 |
* Called from lower-level layers to send the packet up |
|
458 |
* in the stack. Not implemented (IPv6). |
|
459 |
*/ |
|
460 |
virtual enum IpL4Protocol::RxStatus Receive (Ptr<Packet> p, |
|
9145
5752b425cdf5
Bug 1361 - Set TOS from Application level (sockets)
Daniel Lertpratchya <nikkipui@gmail.com>
parents:
8976
diff
changeset
|
461 |
Ipv6Header const &header, |
8753 | 462 |
Ptr<Ipv6Interface> incomingInterface); |
463 |
||
464 |
void SetDownTarget (IpL4Protocol::DownTargetCallback callback); |
|
465 |
void SetDownTarget6 (IpL4Protocol::DownTargetCallback6 callback); |
|
466 |
IpL4Protocol::DownTargetCallback GetDownTarget (void) const; |
|
467 |
IpL4Protocol::DownTargetCallback6 GetDownTarget6 (void) const; |
|
8751 | 468 |
/** |
469 |
* \brief Process method |
|
470 |
* Called from Ipv4L3Protocol::Receive. |
|
471 |
* |
|
472 |
* \param packet the packet |
|
473 |
* \param offset the offset of the extension to process |
|
474 |
* \param dst destination address of the packet received (i.e. us) |
|
475 |
* \param nextHeader the next header |
|
476 |
* \param isDropped if the packet must be dropped |
|
477 |
* \return the size processed |
|
478 |
*/ |
|
479 |
uint8_t Process (Ptr<Packet>& packet, Ipv4Header const& ipv4Header, Ipv4Address dst, uint8_t *nextHeader, uint8_t protocol, bool& isDropped); |
|
480 |
/** |
|
481 |
* \brief Insert a new Dsr Option. |
|
482 |
* \param option the option to insert |
|
483 |
*/ |
|
484 |
void Insert (Ptr<dsr::DsrOptions> option); |
|
485 |
/** |
|
486 |
* \brief Get the option corresponding to optionNumber. |
|
487 |
* \param optionNumber the option number of the option to retrieve |
|
488 |
* \return a matching Dsr option |
|
489 |
*/ |
|
490 |
Ptr<dsr::DsrOptions> GetOption (int optionNumber); |
|
491 |
/** |
|
492 |
* \brief Cancel the route request timer. |
|
493 |
* \param dst The dst address of the route request timer |
|
8752 | 494 |
* \param isRemove whether to remove the route request entry or not |
8751 | 495 |
*/ |
8752 | 496 |
void CancelRreqTimer (Ipv4Address dst, bool isRemove); |
8751 | 497 |
/** |
498 |
* \brief Schedule the route request retry. |
|
499 |
* \param dst The dst address of the route request |
|
500 |
*/ |
|
8752 | 501 |
void ScheduleRreqRetry (Ptr<Packet> packet, std::vector<Ipv4Address> address, bool nonProp, uint32_t requestId, uint8_t protocol); |
8751 | 502 |
// / Handle route discovery timer |
8752 | 503 |
void RouteRequestTimerExpire (Ptr<Packet> packet, std::vector<Ipv4Address> address, uint32_t requestId, uint8_t protocol); |
8751 | 504 |
|
8976
4df4e7cd077f
Replace src/dsr usage of RandomVariable with RandomVariableStream
Mitch Watrous
parents:
8756
diff
changeset
|
505 |
/** |
4df4e7cd077f
Replace src/dsr usage of RandomVariable with RandomVariableStream
Mitch Watrous
parents:
8756
diff
changeset
|
506 |
* Assign a fixed random variable stream number to the random variables |
4df4e7cd077f
Replace src/dsr usage of RandomVariable with RandomVariableStream
Mitch Watrous
parents:
8756
diff
changeset
|
507 |
* used by this model. Return the number of streams (possibly zero) that |
4df4e7cd077f
Replace src/dsr usage of RandomVariable with RandomVariableStream
Mitch Watrous
parents:
8756
diff
changeset
|
508 |
* have been assigned. |
4df4e7cd077f
Replace src/dsr usage of RandomVariable with RandomVariableStream
Mitch Watrous
parents:
8756
diff
changeset
|
509 |
* |
4df4e7cd077f
Replace src/dsr usage of RandomVariable with RandomVariableStream
Mitch Watrous
parents:
8756
diff
changeset
|
510 |
* \param stream first stream index to use |
4df4e7cd077f
Replace src/dsr usage of RandomVariable with RandomVariableStream
Mitch Watrous
parents:
8756
diff
changeset
|
511 |
* \return the number of stream indices assigned by this model |
4df4e7cd077f
Replace src/dsr usage of RandomVariable with RandomVariableStream
Mitch Watrous
parents:
8756
diff
changeset
|
512 |
*/ |
4df4e7cd077f
Replace src/dsr usage of RandomVariable with RandomVariableStream
Mitch Watrous
parents:
8756
diff
changeset
|
513 |
int64_t AssignStreams (int64_t stream); |
4df4e7cd077f
Replace src/dsr usage of RandomVariable with RandomVariableStream
Mitch Watrous
parents:
8756
diff
changeset
|
514 |
|
8751 | 515 |
protected: |
516 |
/* |
|
517 |
* * This function will notify other components connected to the node that a new stack member is now connected |
|
518 |
* * This will be used to notify Layer 3 protocol of layer 4 protocol stack to connect them together. |
|
519 |
* */ |
|
520 |
virtual void NotifyNewAggregate (); |
|
521 |
/** |
|
522 |
* \brief Drop trace callback. |
|
523 |
*/ |
|
524 |
virtual void DoDispose (void); |
|
9719 | 525 |
/** |
8751 | 526 |
* The trace for drop, receive and send data packets |
527 |
*/ |
|
528 |
TracedCallback<Ptr<const Packet> > m_dropTrace; |
|
529 |
TracedCallback <const DsrOptionSRHeader &> m_txPacketTrace; |
|
530 |
||
531 |
private: |
|
9719 | 532 |
|
8751 | 533 |
void Start (); |
534 |
/** |
|
9719 | 535 |
* \brief Notify the data receipt. |
536 |
* \return void |
|
537 |
*/ |
|
538 |
void NotifyDataReceipt (std::string context, Ptr<const Packet> p); |
|
539 |
/** |
|
8751 | 540 |
* \brief Send the route error message when the link breaks to the next hop. |
541 |
*/ |
|
542 |
void SendRerrWhenBreaksLinkToNextHop (Ipv4Address nextHop, uint8_t protocol); |
|
543 |
/** |
|
544 |
* \brief Promiscuous receive data packets destined to some other node. |
|
9719 | 545 |
* \param device The network device |
546 |
* \param packet Data packet we just received |
|
547 |
* \param protocol The protocol we receive, need to verify it is dsr protocol |
|
548 |
* \param from The from address we received the packet |
|
549 |
* \param to The address this packet is destined for |
|
550 |
* \param packetType The dsr packet type, 0 is for control packet, 1 for data packet |
|
8751 | 551 |
*/ |
552 |
bool PromiscReceive (Ptr<NetDevice> device, Ptr<const Packet> packet, uint16_t protocol, const Address &from, |
|
553 |
const Address &to, NetDevice::PacketType packetType); |
|
554 |
/** |
|
555 |
* \brief Define the list to hold DSR options. |
|
556 |
*/ |
|
557 |
typedef std::list<Ptr<DsrOptions> > DsrOptionList_t; |
|
558 |
/** |
|
559 |
* \brief List of DSR Options supported. |
|
560 |
*/ |
|
561 |
DsrOptionList_t m_options; |
|
562 |
||
9719 | 563 |
Ptr<Ipv4L3Protocol> m_ipv4; ///< Ipv4l3Protocol |
564 |
||
565 |
Ptr<Ipv4Route> m_ipv4Route; ///< Ipv4 Route |
|
8751 | 566 |
|
9719 | 567 |
Ptr<Ipv4> m_ip; ///< The ip ptr |
8751 | 568 |
|
9719 | 569 |
Ptr<Node> m_node; ///< The node ptr |
8751 | 570 |
|
9719 | 571 |
Ipv4Address m_mainAddress; ///< Our own Ip address |
8751 | 572 |
|
9719 | 573 |
uint8_t segsLeft; ///< The segment left value from SR header |
8751 | 574 |
|
9719 | 575 |
IpL4Protocol::DownTargetCallback m_downTarget; ///< The callback for down layer |
8751 | 576 |
|
9719 | 577 |
uint32_t m_maxNetworkSize; ///< Maximum network queue size |
8751 | 578 |
|
9719 | 579 |
Time m_maxNetworkDelay; ///< Maximum network delay |
8752 | 580 |
|
9719 | 581 |
uint32_t m_discoveryHopLimit; ///< Maximum hops to go for route request |
8752 | 582 |
|
9719 | 583 |
uint8_t m_maxSalvageCount; ///< Maximum # times to salvage a packet |
8751 | 584 |
|
9719 | 585 |
Time m_requestPeriod; ///< The base time interval between route requests |
8751 | 586 |
|
9719 | 587 |
Time m_nonpropRequestTimeout; ///< The non-propagation request timeout |
8751 | 588 |
|
9719 | 589 |
uint32_t m_sendRetries; ///< # of retries have been sent for network acknowledgment |
8751 | 590 |
|
9719 | 591 |
uint32_t m_passiveRetries; ///< # of retries have been sent for passive acknowledgment |
8752 | 592 |
|
9719 | 593 |
uint32_t m_linkRetries; ///< # of retries have been sent for link acknowledgment |
8751 | 594 |
|
9719 | 595 |
uint32_t m_rreqRetries; ///< Maximum number of retransmissions of RREQ with TTL = NetDiameter to discover a route |
8751 | 596 |
|
9719 | 597 |
uint32_t m_maxMaintRexmt; ///< Maximum number of retransmissions of data packets |
8751 | 598 |
|
9719 | 599 |
Time m_nodeTraversalTime; ///< Time estimated for packet to travel between two nodes |
8751 | 600 |
|
9719 | 601 |
uint32_t m_maxSendBuffLen; ///< The maximum number of packets that we allow a routing protocol to buffer. |
8751 | 602 |
|
9719 | 603 |
Time m_sendBufferTimeout; ///< The maximum period of time that a routing protocol is allowed to buffer a packet for. |
8751 | 604 |
|
9719 | 605 |
SendBuffer m_sendBuffer; ///< The send buffer |
8751 | 606 |
|
9719 | 607 |
ErrorBuffer m_errorBuffer; ///< The error buffer to save the error messages |
8752 | 608 |
|
9719 | 609 |
uint32_t m_maxMaintainLen; ///< Max # of entries for maintainance buffer |
8751 | 610 |
|
9719 | 611 |
Time m_maxMaintainTime; ///< Time out for maintainance buffer |
8751 | 612 |
|
9719 | 613 |
uint32_t m_maxCacheLen; ///< Max # of cache entries for route cache |
8751 | 614 |
|
9719 | 615 |
Time m_maxCacheTime; ///< Max time for caching the route cache entry |
8751 | 616 |
|
9719 | 617 |
Time m_maxRreqTime; ///< Max time for caching the route request entry |
8751 | 618 |
|
9719 | 619 |
uint32_t m_maxEntriesEachDst; ///< Max number of route entries to save for each destination |
8751 | 620 |
|
9719 | 621 |
MaintainBuffer m_maintainBuffer; ///< The declaration of maintain buffer |
8751 | 622 |
|
9719 | 623 |
uint32_t m_requestId; ///< The id assigned to each route request |
8751 | 624 |
|
9719 | 625 |
uint16_t m_ackId; ///< The ack id assigned to each acknowledge |
626 |
||
627 |
uint32_t m_requestTableSize; ///< The max size of the request table size |
|
8751 | 628 |
|
9719 | 629 |
uint32_t m_requestTableIds; ///< The request table identifiers |
630 |
||
631 |
uint32_t m_maxRreqId; ///< The max number of request ids for a single destination |
|
8751 | 632 |
|
9719 | 633 |
Time m_blacklistTimeout; ///< The black list time out |
8751 | 634 |
|
9719 | 635 |
Ipv4Address m_broadcast; ///< The broadcast IP address |
8751 | 636 |
|
9719 | 637 |
uint32_t m_broadcastJitter; ///< The max time to delay route request broadcast. |
8751 | 638 |
|
9719 | 639 |
Time m_passiveAckTimeout; ///< The timeout value for passive acknowledge |
8751 | 640 |
|
9719 | 641 |
uint32_t m_tryPassiveAcks; ///< Maximum number of packet transmission using passive acknowledgment |
8751 | 642 |
|
9719 | 643 |
Time m_linkAckTimeout; ///< The timeout value for link acknowledge |
8751 | 644 |
|
9719 | 645 |
uint32_t m_tryLinkAcks; ///< Maximum number of packet transmission using link acknowledgment |
8751 | 646 |
|
9719 | 647 |
Timer m_sendBuffTimer; ///< The send buffer timer |
8751 | 648 |
|
9719 | 649 |
Time m_sendBuffInterval; ///< how often to check send buffer |
8751 | 650 |
|
9719 | 651 |
Time m_gratReplyHoldoff; ///< The max gratuitous reply hold off time |
8751 | 652 |
|
9719 | 653 |
Time m_maxRequestPeriod; ///< The max request period |
8751 | 654 |
|
9719 | 655 |
uint32_t m_graReplyTableSize; ///< Set the gratuitous reply table size |
8751 | 656 |
|
9719 | 657 |
std::string m_cacheType; ///< The type of route cache |
8751 | 658 |
|
9719 | 659 |
std::string m_routeSortType; ///< The type of route sort methods |
660 |
||
661 |
uint32_t m_stabilityDecrFactor; ///< The initial decrease factor for link cache |
|
8751 | 662 |
|
9719 | 663 |
uint32_t m_stabilityIncrFactor; ///< The initial increase factor for link cache |
8752 | 664 |
|
9719 | 665 |
Time m_initStability; ///< The initial stability value for link cache |
8751 | 666 |
|
9719 | 667 |
Time m_minLifeTime; ///< The min life time |
8751 | 668 |
|
9719 | 669 |
Time m_useExtends; ///< The use extension of the life time for link cache |
8751 | 670 |
|
9719 | 671 |
bool m_subRoute; ///< Whether to save sub route or not |
8751 | 672 |
|
9719 | 673 |
Time m_retransIncr; ///< the increase time for retransmission timer when face network congestion |
8751 | 674 |
|
9719 | 675 |
std::vector<Ipv4Address> m_finalRoute; ///< The route cache |
8752 | 676 |
|
9719 | 677 |
std::map<Ipv4Address, Timer> m_addressReqTimer; ///< Map IP address + RREQ timer. |
8751 | 678 |
|
9719 | 679 |
std::map<Ipv4Address, Timer> m_nonPropReqTimer; ///< Map IP address + RREQ timer. |
8751 | 680 |
|
9719 | 681 |
std::map<NetworkKey, Timer> m_addressForwardTimer; ///< Map network key + forward timer. |
8751 | 682 |
|
9719 | 683 |
std::map<NetworkKey, uint32_t> m_addressForwardCnt; ///< Map network key + forward counts. |
8752 | 684 |
|
9719 | 685 |
std::map<PassiveKey, uint32_t> m_passiveCnt; ///< Map packet key + passive forward counts. |
8751 | 686 |
|
9719 | 687 |
std::map<PassiveKey, Timer> m_passiveAckTimer; ///< The timer for passive acknowledgment |
8751 | 688 |
|
9719 | 689 |
std::map<LinkKey, uint32_t> m_linkCnt; ///< Map packet key + link forward counts. |
8751 | 690 |
|
9719 | 691 |
std::map<LinkKey, Timer> m_linkAckTimer; ///< The timer for link acknowledgment |
8751 | 692 |
|
9719 | 693 |
Ptr<dsr::RouteCache> m_routeCache; ///< A "drop-front" queue used by the routing layer to cache routes found. |
694 |
||
695 |
Ptr<dsr::RreqTable> m_rreqTable; ///< A "drop-front" queue used by the routing layer to cache route request sent. |
|
8751 | 696 |
|
9293
854e085e1a01
bug 1608: DSR network ack and bug 1609: DSR route request table
Yufei Cheng <yfcheng@ittc.ku.edu>
parents:
9253
diff
changeset
|
697 |
Ptr<dsr::PassiveBuffer> m_passiveBuffer; ///< A "drop-front" queue used by the routing layer to cache route request sent. |
854e085e1a01
bug 1608: DSR network ack and bug 1609: DSR route request table
Yufei Cheng <yfcheng@ittc.ku.edu>
parents:
9253
diff
changeset
|
698 |
|
9719 | 699 |
uint32_t m_numPriorityQueues; ///< The number of priority queues used |
700 |
||
701 |
bool m_linkAck; ///< define if we use link acknowledgement or not |
|
8752 | 702 |
|
9719 | 703 |
std::map<uint32_t, Ptr<dsr::DsrNetworkQueue> > m_priorityQueue; ///< priority queues |
8752 | 704 |
|
9719 | 705 |
GraReply m_graReply; ///< The gratuitous route reply. |
8751 | 706 |
|
9719 | 707 |
std::vector<Ipv4Address> m_clearList; ///< The node that is clear to send packet to |
708 |
||
709 |
std::vector<Ipv4Address> m_addresses; ///< The bind ipv4 addresses with next hop, src, destination address in sequence |
|
8751 | 710 |
|
9719 | 711 |
std::map <std::string, uint32_t> m_macToNodeIdMap; ///< The map of mac address to node id |
8976
4df4e7cd077f
Replace src/dsr usage of RandomVariable with RandomVariableStream
Mitch Watrous
parents:
8756
diff
changeset
|
712 |
|
9719 | 713 |
Ptr<UniformRandomVariable> m_uniformRandomVariable; ///< Provides uniform random variables. |
8751 | 714 |
}; |
715 |
} /* namespace dsr */ |
|
716 |
} /* namespace ns3 */ |
|
8752 | 717 |
|
8751 | 718 |
#endif /* DSR_ROUTING_H */ |