OLD | NEW |
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ | 1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
2 /* | 2 /* |
3 * Copyright (c) 2009 IITP RAS | 3 * Copyright (c) 2009 IITP RAS |
4 * | 4 * |
5 * This program is free software; you can redistribute it and/or modify | 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 | 6 * it under the terms of the GNU General Public License version 2 as |
7 * published by the Free Software Foundation; | 7 * published by the Free Software Foundation; |
8 * | 8 * |
9 * This program is distributed in the hope that it will be useful, | 9 * This program is distributed in the hope that it will be useful, |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
(...skipping 29 matching lines...) Expand all Loading... |
40 * \ingroup aodv | 40 * \ingroup aodv |
41 * \brief AODV Queue Entry | 41 * \brief AODV Queue Entry |
42 */ | 42 */ |
43 class QueueEntry | 43 class QueueEntry |
44 { | 44 { |
45 public: | 45 public: |
46 /// IPv4 routing unicast forward callback typedef | 46 /// IPv4 routing unicast forward callback typedef |
47 typedef Ipv4RoutingProtocol::UnicastForwardCallback UnicastForwardCallback; | 47 typedef Ipv4RoutingProtocol::UnicastForwardCallback UnicastForwardCallback; |
48 /// IPv4 routing error callback typedef | 48 /// IPv4 routing error callback typedef |
49 typedef Ipv4RoutingProtocol::ErrorCallback ErrorCallback; | 49 typedef Ipv4RoutingProtocol::ErrorCallback ErrorCallback; |
50 /// c-tor | 50 /** |
| 51 * c-tor |
| 52 * |
| 53 * \param pa the packet to add to the queue |
| 54 * \param h the Ipv4Header |
| 55 * \param ucb the UnicastForwardCallback function |
| 56 * \param ecb the ErrorCallback function |
| 57 * \param exp the expiration time |
| 58 */ |
51 QueueEntry (Ptr<const Packet> pa = 0, Ipv4Header const & h = Ipv4Header (), | 59 QueueEntry (Ptr<const Packet> pa = 0, Ipv4Header const & h = Ipv4Header (), |
52 UnicastForwardCallback ucb = UnicastForwardCallback (), | 60 UnicastForwardCallback ucb = UnicastForwardCallback (), |
53 ErrorCallback ecb = ErrorCallback (), Time exp = Simulator::Now ()
) | 61 ErrorCallback ecb = ErrorCallback (), Time exp = Simulator::Now ()
) |
54 : m_packet (pa), | 62 : m_packet (pa), |
55 m_header (h), | 63 m_header (h), |
56 m_ucb (ucb), | 64 m_ucb (ucb), |
57 m_ecb (ecb), | 65 m_ecb (ecb), |
58 m_expire (exp + Simulator::Now ()) | 66 m_expire (exp + Simulator::Now ()) |
59 { | 67 { |
60 } | 68 } |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
165 }; | 173 }; |
166 /** | 174 /** |
167 * \ingroup aodv | 175 * \ingroup aodv |
168 * \brief AODV route request queue | 176 * \brief AODV route request queue |
169 * | 177 * |
170 * Since AODV is an on demand routing we queue requests while looking for route. | 178 * Since AODV is an on demand routing we queue requests while looking for route. |
171 */ | 179 */ |
172 class RequestQueue | 180 class RequestQueue |
173 { | 181 { |
174 public: | 182 public: |
175 /// Default c-tor | 183 /** |
| 184 * Default c-tor |
| 185 * |
| 186 * \param maxLen the maximum length |
| 187 * \param routeToQueueTimeout the route to queue timeout |
| 188 */ |
176 RequestQueue (uint32_t maxLen, Time routeToQueueTimeout) | 189 RequestQueue (uint32_t maxLen, Time routeToQueueTimeout) |
177 : m_maxLen (maxLen), | 190 : m_maxLen (maxLen), |
178 m_queueTimeout (routeToQueueTimeout) | 191 m_queueTimeout (routeToQueueTimeout) |
179 { | 192 { |
180 } | 193 } |
181 /// Push entry in queue, if there is no entry with the same packet and destina
tion address in queue. | 194 /** |
| 195 * Push entry in queue, if there is no entry with the same packet and destinat
ion address in queue. |
| 196 * \param entry the queue entry |
| 197 * \returns true if the entry is queued |
| 198 */ |
182 bool Enqueue (QueueEntry & entry); | 199 bool Enqueue (QueueEntry & entry); |
183 /// Return first found (the earliest) entry for given destination | 200 /** |
| 201 * Return first found (the earliest) entry for given destination |
| 202 *· |
| 203 * \param dst the destination IP address |
| 204 * \param entry the queue entry |
| 205 * \returns true if the entry is dequeued |
| 206 */ |
184 bool Dequeue (Ipv4Address dst, QueueEntry & entry); | 207 bool Dequeue (Ipv4Address dst, QueueEntry & entry); |
185 /// Remove all packets with destination IP address dst | 208 /** |
| 209 * Remove all packets with destination IP address dst |
| 210 * \param dst the destination IP address |
| 211 */ |
186 void DropPacketWithDst (Ipv4Address dst); | 212 void DropPacketWithDst (Ipv4Address dst); |
187 /// Finds whether a packet with destination dst exists in the queue | 213 /** |
| 214 * Finds whether a packet with destination dst exists in the queue |
| 215 *· |
| 216 * \param dst the destination IP address |
| 217 * \returns true if an entry with the IP address is found |
| 218 */ |
188 bool Find (Ipv4Address dst); | 219 bool Find (Ipv4Address dst); |
189 /// Number of entries | 220 /** |
| 221 * \returns the number of entries |
| 222 */ |
190 uint32_t GetSize (); | 223 uint32_t GetSize (); |
191 | 224 |
192 // Fields | 225 // Fields |
193 /** | 226 /** |
194 * Get maximum queue length | 227 * Get maximum queue length |
195 * \returns the maximum queue length | 228 * \returns the maximum queue length |
196 */ | 229 */ |
197 uint32_t GetMaxQueueLen () const | 230 uint32_t GetMaxQueueLen () const |
198 { | 231 { |
199 return m_maxLen; | 232 return m_maxLen; |
(...skipping 21 matching lines...) Expand all Loading... |
221 void SetQueueTimeout (Time t) | 254 void SetQueueTimeout (Time t) |
222 { | 255 { |
223 m_queueTimeout = t; | 256 m_queueTimeout = t; |
224 } | 257 } |
225 | 258 |
226 private: | 259 private: |
227 /// The queue | 260 /// The queue |
228 std::vector<QueueEntry> m_queue; | 261 std::vector<QueueEntry> m_queue; |
229 /// Remove all expired entries | 262 /// Remove all expired entries |
230 void Purge (); | 263 void Purge (); |
231 /// Notify that packet is dropped from queue by timeout | 264 /** |
| 265 * Notify that packet is dropped from queue by timeout |
| 266 * \param en the queue entry to drop |
| 267 * \param reason the reason to drop the entry |
| 268 */ |
232 void Drop (QueueEntry en, std::string reason); | 269 void Drop (QueueEntry en, std::string reason); |
233 /// The maximum number of packets that we allow a routing protocol to buffer. | 270 /// The maximum number of packets that we allow a routing protocol to buffer. |
234 uint32_t m_maxLen; | 271 uint32_t m_maxLen; |
235 /// The maximum period of time that a routing protocol is allowed to buffer a
packet for, seconds. | 272 /// The maximum period of time that a routing protocol is allowed to buffer a
packet for, seconds. |
236 Time m_queueTimeout; | 273 Time m_queueTimeout; |
237 /** | 274 /** |
238 * Determine if queue matches a destination address | 275 * Determine if queue matches a destination address |
239 * \param en The queue entry | 276 * \param en The queue entry |
240 * \param dst The destination IPv4 address | 277 * \param dst The destination IPv4 address |
241 * \returns true if the queue entry matches the desination address | 278 * \returns true if the queue entry matches the desination address |
242 */ | 279 */ |
243 static bool IsEqual (QueueEntry en, const Ipv4Address dst) | 280 static bool IsEqual (QueueEntry en, const Ipv4Address dst) |
244 { | 281 { |
245 return (en.GetIpv4Header ().GetDestination () == dst); | 282 return (en.GetIpv4Header ().GetDestination () == dst); |
246 } | 283 } |
247 }; | 284 }; |
248 | 285 |
249 | 286 |
250 } // namespace aodv | 287 } // namespace aodv |
251 } // namespace ns3 | 288 } // namespace ns3 |
252 | 289 |
253 #endif /* AODV_RQUEUE_H */ | 290 #endif /* AODV_RQUEUE_H */ |
OLD | NEW |