author | Borovkova Elena <borovkovaes@iitp.ru> |
Thu, 16 Jul 2009 18:25:49 +0400 | |
changeset 5597 | 8e4c7f2aaead |
parent 5591 | e0448da5da14 |
child 5601 | 82c874729b6c |
permissions | -rw-r--r-- |
5539 | 1 |
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
2 |
/* |
|
5591
e0448da5da14
AODV copyright changed to IITP
Pavel Boyko <boyko@iitp.ru>
parents:
5561
diff
changeset
|
3 |
* Copyright (c) 2009 IITP RAS |
5539 | 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 |
* |
|
5591
e0448da5da14
AODV copyright changed to IITP
Pavel Boyko <boyko@iitp.ru>
parents:
5561
diff
changeset
|
18 |
* Based on |
e0448da5da14
AODV copyright changed to IITP
Pavel Boyko <boyko@iitp.ru>
parents:
5561
diff
changeset
|
19 |
* NS-2 AODV model developed by the CMU/MONARCH group and optimized and |
e0448da5da14
AODV copyright changed to IITP
Pavel Boyko <boyko@iitp.ru>
parents:
5561
diff
changeset
|
20 |
* tuned by Samir Das and Mahesh Marina, University of Cincinnati; |
e0448da5da14
AODV copyright changed to IITP
Pavel Boyko <boyko@iitp.ru>
parents:
5561
diff
changeset
|
21 |
* |
e0448da5da14
AODV copyright changed to IITP
Pavel Boyko <boyko@iitp.ru>
parents:
5561
diff
changeset
|
22 |
* AODV-UU implementation by Erik Nordström of Uppsala University |
e0448da5da14
AODV copyright changed to IITP
Pavel Boyko <boyko@iitp.ru>
parents:
5561
diff
changeset
|
23 |
* http://core.it.uu.se/core/index.php/AODV-UU |
5539 | 24 |
* |
5591
e0448da5da14
AODV copyright changed to IITP
Pavel Boyko <boyko@iitp.ru>
parents:
5561
diff
changeset
|
25 |
* Authors: Elena Borovkova <borovkovaes@iitp.ru> |
e0448da5da14
AODV copyright changed to IITP
Pavel Boyko <boyko@iitp.ru>
parents:
5561
diff
changeset
|
26 |
* Pavel Boyko <boyko@iitp.ru> |
5539 | 27 |
*/ |
28 |
#ifndef __aodv_rqueue_h__ |
|
5561
f74c7723afd3
AODV protocol copy-paste in progress
Pavel Boyko <boyko@iitp.ru>
parents:
5543
diff
changeset
|
29 |
#define __aodv_rqueue_h__ |
5539 | 30 |
|
31 |
#include "ns3/ipv4-header.h" |
|
32 |
#include "ns3/nstime.h" |
|
33 |
#include "ns3/packet.h" |
|
34 |
#include <vector> |
|
35 |
||
36 |
namespace ns3 { |
|
37 |
namespace aodv { |
|
38 |
||
5540 | 39 |
/// The maximum number of packets that we allow a routing protocol to buffer. |
5541 | 40 |
#define AODV_RTQ_MAX_LEN 64 |
5540 | 41 |
/// The maximum period of time that a routing protocol is allowed to buffer a packet for, seconds. |
5541 | 42 |
#define AODV_RTQ_TIMEOUT 30 |
5542
1b504e63a1b1
aodv_rtable unit test added
Borovkova Elena <borovkovaes@iitp.ru>
parents:
5541
diff
changeset
|
43 |
/** |
1b504e63a1b1
aodv_rtable unit test added
Borovkova Elena <borovkovaes@iitp.ru>
parents:
5541
diff
changeset
|
44 |
* \ingroup aodv |
1b504e63a1b1
aodv_rtable unit test added
Borovkova Elena <borovkovaes@iitp.ru>
parents:
5541
diff
changeset
|
45 |
* \brief AODV Queue Entry |
1b504e63a1b1
aodv_rtable unit test added
Borovkova Elena <borovkovaes@iitp.ru>
parents:
5541
diff
changeset
|
46 |
*/ |
5539 | 47 |
struct QueueEntry |
48 |
{ |
|
5597
8e4c7f2aaead
mothods, classes and members renamed
Borovkova Elena <borovkovaes@iitp.ru>
parents:
5591
diff
changeset
|
49 |
Ptr<Packet> m_packet; |
8e4c7f2aaead
mothods, classes and members renamed
Borovkova Elena <borovkovaes@iitp.ru>
parents:
5591
diff
changeset
|
50 |
Ipv4Header m_header; |
5543 | 51 |
/// Expire time for queue entry |
5597
8e4c7f2aaead
mothods, classes and members renamed
Borovkova Elena <borovkovaes@iitp.ru>
parents:
5591
diff
changeset
|
52 |
Time m_expire; |
5543 | 53 |
/// c-tor |
5597
8e4c7f2aaead
mothods, classes and members renamed
Borovkova Elena <borovkovaes@iitp.ru>
parents:
5591
diff
changeset
|
54 |
QueueEntry(Ptr<Packet> pa, Ipv4Header const & h, Time exp = Seconds(0)) : m_packet(pa), m_header(h), m_expire(exp) {} |
5543 | 55 |
/** |
56 |
* Compare queue entries |
|
57 |
* \return true if equal |
|
58 |
*/ |
|
5541 | 59 |
bool operator==(QueueEntry const & o) const |
60 |
{ |
|
5597
8e4c7f2aaead
mothods, classes and members renamed
Borovkova Elena <borovkovaes@iitp.ru>
parents:
5591
diff
changeset
|
61 |
return ((m_packet == o.m_packet)/*&& header == o.header*/ && (m_expire == o.m_expire)); |
5541 | 62 |
} |
5539 | 63 |
}; |
5542
1b504e63a1b1
aodv_rtable unit test added
Borovkova Elena <borovkovaes@iitp.ru>
parents:
5541
diff
changeset
|
64 |
/** |
1b504e63a1b1
aodv_rtable unit test added
Borovkova Elena <borovkovaes@iitp.ru>
parents:
5541
diff
changeset
|
65 |
* \ingroup aodv |
1b504e63a1b1
aodv_rtable unit test added
Borovkova Elena <borovkovaes@iitp.ru>
parents:
5541
diff
changeset
|
66 |
* \brief AODV Queue |
1b504e63a1b1
aodv_rtable unit test added
Borovkova Elena <borovkovaes@iitp.ru>
parents:
5541
diff
changeset
|
67 |
*/ |
5597
8e4c7f2aaead
mothods, classes and members renamed
Borovkova Elena <borovkovaes@iitp.ru>
parents:
5591
diff
changeset
|
68 |
class AodvQueue |
5540 | 69 |
{ |
5539 | 70 |
public: |
5543 | 71 |
/// Default c-tor |
5597
8e4c7f2aaead
mothods, classes and members renamed
Borovkova Elena <borovkovaes@iitp.ru>
parents:
5591
diff
changeset
|
72 |
AodvQueue (); |
5543 | 73 |
/// Push entry in queue. |
5597
8e4c7f2aaead
mothods, classes and members renamed
Borovkova Elena <borovkovaes@iitp.ru>
parents:
5591
diff
changeset
|
74 |
void Enqueue (QueueEntry & entry); |
5543 | 75 |
/// Returns a entry from the head of the queue. |
5597
8e4c7f2aaead
mothods, classes and members renamed
Borovkova Elena <borovkovaes@iitp.ru>
parents:
5591
diff
changeset
|
76 |
QueueEntry Dequeue (); |
5543 | 77 |
/// Return first found (the earliest) entry for given destination |
5597
8e4c7f2aaead
mothods, classes and members renamed
Borovkova Elena <borovkovaes@iitp.ru>
parents:
5591
diff
changeset
|
78 |
bool Dequeue (Ipv4Address dst, QueueEntry & entry); |
5539 | 79 |
/// Finds whether a packet with destination dst exists in the queue |
5597
8e4c7f2aaead
mothods, classes and members renamed
Borovkova Elena <borovkovaes@iitp.ru>
parents:
5591
diff
changeset
|
80 |
bool Find (Ipv4Address dst); |
5541 | 81 |
/// Number of entries |
5597
8e4c7f2aaead
mothods, classes and members renamed
Borovkova Elena <borovkovaes@iitp.ru>
parents:
5591
diff
changeset
|
82 |
uint32_t GetSize (); |
5539 | 83 |
|
84 |
private: |
|
5597
8e4c7f2aaead
mothods, classes and members renamed
Borovkova Elena <borovkovaes@iitp.ru>
parents:
5591
diff
changeset
|
85 |
std::vector<QueueEntry> m_queue; |
5540 | 86 |
/// Remove and return first entry from queue |
5597
8e4c7f2aaead
mothods, classes and members renamed
Borovkova Elena <borovkovaes@iitp.ru>
parents:
5591
diff
changeset
|
87 |
QueueEntry RemoveHead(); |
5541 | 88 |
/// Remove all expired entries |
5597
8e4c7f2aaead
mothods, classes and members renamed
Borovkova Elena <borovkovaes@iitp.ru>
parents:
5591
diff
changeset
|
89 |
void Purge(); |
5540 | 90 |
/// Notify that packet is dropped from queue by timeout |
5597
8e4c7f2aaead
mothods, classes and members renamed
Borovkova Elena <borovkovaes@iitp.ru>
parents:
5591
diff
changeset
|
91 |
void Drop (QueueEntry e); |
5543 | 92 |
/// Maximum number of entries in queue |
5597
8e4c7f2aaead
mothods, classes and members renamed
Borovkova Elena <borovkovaes@iitp.ru>
parents:
5591
diff
changeset
|
93 |
uint32_t m_maxSize; |
5543 | 94 |
/// Life time of queue entry in queue |
5597
8e4c7f2aaead
mothods, classes and members renamed
Borovkova Elena <borovkovaes@iitp.ru>
parents:
5591
diff
changeset
|
95 |
Time m_timeout; |
5539 | 96 |
}; |
97 |
}} |
|
98 |
||
99 |
#endif /* __aodv_rqueue_h__ */ |