LEFT | RIGHT |
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) 2007,2008 INRIA | 3 * Copyright (c) 2007,2008 INRIA |
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 15 matching lines...) Expand all Loading... |
26 #include "wimax-mac-header.h" | 26 #include "wimax-mac-header.h" |
27 #include "ns3/packet.h" | 27 #include "ns3/packet.h" |
28 #include "ns3/object.h" | 28 #include "ns3/object.h" |
29 #include "ns3/traced-callback.h" | 29 #include "ns3/traced-callback.h" |
30 #include "ns3/nstime.h" | 30 #include "ns3/nstime.h" |
31 | 31 |
32 namespace ns3 { | 32 namespace ns3 { |
33 | 33 |
34 /** | 34 /** |
35 * \ingroup wimax | 35 * \ingroup wimax |
| 36 * Class implementing the device packet queue |
36 */ | 37 */ |
37 class WimaxMacQueue : public Object | 38 class WimaxMacQueue : public Object |
38 { | 39 { |
39 public: | 40 public: |
40 /** | 41 /** |
41 * \brief Get the type ID. | 42 * \brief Get the type ID. |
42 * \return the object TypeId | 43 * \return the object TypeId |
43 */ | 44 */ |
44 static TypeId GetTypeId (void); | 45 static TypeId GetTypeId (void); |
45 WimaxMacQueue (void); | 46 WimaxMacQueue (void); |
46 /** | 47 /** |
47 * Constructor | 48 * Constructor |
48 * | 49 * |
49 * \param maxSize | 50 * \param maxSize maximum size of queue |
50 */ | 51 */ |
51 WimaxMacQueue (uint32_t maxSize); | 52 WimaxMacQueue (uint32_t maxSize); |
52 ~WimaxMacQueue (void); | 53 ~WimaxMacQueue (void); |
53 /** | 54 /** |
54 * \brief set the maximum queue size | 55 * \brief set the maximum queue size |
55 * \param maxSize the max queue size | 56 * \param maxSize the max queue size |
56 */ | 57 */ |
57 void SetMaxSize (uint32_t maxSize); | 58 void SetMaxSize (uint32_t maxSize); |
58 /** | 59 /** |
59 * \return the maximum queue size | 60 * \return the maximum queue size |
60 */ | 61 */ |
61 uint32_t GetMaxSize (void) const; | 62 uint32_t GetMaxSize (void) const; |
62 /** | 63 /** |
63 * \brief Enqueue a packet | 64 * \brief Enqueue a packet |
64 * \param packet the packet to enqueue | 65 * \param packet the packet to enqueue |
65 * \param hdrType the mac header type of the packet | 66 * \param hdrType the mac header type of the packet |
66 * \param hdr the header of the packet | 67 * \param hdr the header of the packet |
67 * \return true if successful | 68 * \return true if successful |
68 */ | 69 */ |
69 bool Enqueue (Ptr<Packet> packet, const MacHeaderType &hdrType, | 70 bool Enqueue (Ptr<Packet> packet, const MacHeaderType &hdrType, |
70 const GenericMacHeader &hdr); | 71 const GenericMacHeader &hdr); |
71 /** | 72 /** |
72 * \brief Dequeue a packet of type packetType from the queue | 73 * \brief Dequeue a packet of type packetType from the queue |
73 * \param packetType the type of the packet | 74 * \param packetType the type of the packet |
74 * \return the first packet in the queue | 75 * \return the first packet in the queue |
75 */ | 76 */ |
76 Ptr<Packet> Dequeue (MacHeaderType::HeaderType packetType); | 77 Ptr<Packet> Dequeue (MacHeaderType::HeaderType packetType); |
77 /** | 78 /** |
78 * \brief Dequeue a fragment of size availableByte from the queue | 79 * \brief Dequeue a fragment of size availableByte from the queue |
79 * \param packetType the type of the packet | 80 * \param packetType the type of the packet |
80 * \param availableByte the size of the fragment | 81 * \param availableByte the size of the fragment |
81 * \return the first packet in the queue if its size is lower than availableBy
te, the first availableByte of the | 82 * \return the first packet in the queue if its size is lower than availableBy
te, the first availableByte of the first packet otherwise |
82 * first packet otherwise | |
83 */ | 83 */ |
84 Ptr<Packet> Dequeue (MacHeaderType::HeaderType packetType, | 84 Ptr<Packet> Dequeue (MacHeaderType::HeaderType packetType, |
85 uint32_t availableByte); | 85 uint32_t availableByte); |
86 | 86 |
87 /** | 87 /** |
88 * \brief Exclusive for BS. | 88 * \brief Exclusively for BS. |
89 * Two versions of Peek function (with Generic MAC Header as parameter) only | 89 * Two versions of Peek function (with Generic MAC Header as parameter) only |
90 * for BS, as BS's scheduler needs to know the CID in Generic MAC Header. | 90 * for BS, as BS's scheduler needs to know the CID in Generic MAC Header. |
91 * \param hdr the header of the packet | 91 * \param hdr the header of the packet |
92 * \return the first packet in the queue | 92 * \return the first packet in the queue |
93 */ | 93 */ |
94 Ptr<Packet> Peek (GenericMacHeader &hdr) const; | 94 Ptr<Packet> Peek (GenericMacHeader &hdr) const; |
95 /** | 95 /** |
96 * \brief Exclusive for BS. | 96 * \brief Exclusively for BS. |
97 * Two versions of Peek function (with Generic MAC Header as parameter) only | 97 * Two versions of Peek function (with Generic MAC Header as parameter) only |
98 * for BS, as BS's scheduler needs to know the CID in Generic MAC Header. | 98 * for BS, as BS's scheduler needs to know the CID in Generic MAC Header. |
99 * \param hdr the header of the packet | 99 * \param hdr the header of the packet |
100 * \param timeStamp the timestamp of the packet | 100 * \param timeStamp the timestamp of the packet |
101 * \return the first packet in the queue | 101 * \return the first packet in the queue |
102 */ | 102 */ |
103 Ptr<Packet> Peek (GenericMacHeader &hdr, Time &timeStamp) const; | 103 Ptr<Packet> Peek (GenericMacHeader &hdr, Time &timeStamp) const; |
104 | 104 |
105 /** | 105 /** |
106 * \brief Two versions for SS without Generic MAC Header parameter, as SS's | 106 * \brief Two versions for SS without Generic MAC Header parameter, as SS's |
107 * scheduler does not require to know the CID in Generic MAC Header. | 107 * scheduler does not require to know the CID in Generic MAC Header. |
108 * \param packetType the type of the packet | 108 * \param packetType the type of the packet |
109 * \return the first packet in the queue | 109 * \return the first packet in the queue |
110 */ | 110 */ |
111 Ptr<Packet> Peek (MacHeaderType::HeaderType packetType) const; | 111 Ptr<Packet> Peek (MacHeaderType::HeaderType packetType) const; |
112 /** | 112 /** |
113 * \brief Two versions for SS without Generic MAC Header parameter, as SS's | 113 * \brief Two versions for SS without Generic MAC Header parameter, as SS's |
114 * scheduler does not require to know the CID in Generic MAC Header. | 114 * scheduler does not require to know the CID in Generic MAC Header. |
115 * \param packetType the type of the packet | 115 * \param packetType the type of the packet |
116 * \param timeStamp the timestamp of the packet | 116 * \param timeStamp the timestamp of the packet |
117 * \return the first packet in the queue | 117 * \return the first packet in the queue |
118 */ | 118 */ |
119 Ptr<Packet> Peek (MacHeaderType::HeaderType packetType, Time &timeStamp) const
; | 119 Ptr<Packet> Peek (MacHeaderType::HeaderType packetType, Time &timeStamp) const
; |
120 | 120 |
121 | 121 /** |
122 /// Is empty function | 122 * Check if queue is empty |
| 123 * \returns true if empty |
| 124 */ |
123 bool IsEmpty (void) const; | 125 bool IsEmpty (void) const; |
124 | 126 |
125 /** | 127 /** |
126 * Exclusive for SS. | 128 * Exclusively for SS. |
| 129 * \return true if queue is empty of type packetType |
| 130 * \param packetType packet type to check |
127 */ | 131 */ |
128 bool IsEmpty (MacHeaderType::HeaderType packetType) const; | 132 bool IsEmpty (MacHeaderType::HeaderType packetType) const; |
129 | 133 |
130 /** | 134 /** |
131 * Get size function | 135 * Get size of queue |
132 * \returns the size | 136 * \returns the size |
133 */ | 137 */ |
134 uint32_t GetSize (void) const; | 138 uint32_t GetSize (void) const; |
135 /** | 139 /** |
136 * Get number of bytes function | 140 * Get number of bytes in queue |
137 * \returns the number of bytes | 141 * \returns the number of bytes |
138 */ | 142 */ |
139 uint32_t GetNBytes (void) const; | 143 uint32_t GetNBytes (void) const; |
140 | 144 |
141 /** | 145 /** |
142 * Check for fragmentation function | 146 * Check for fragmentation of the first packet of the specified type |
143 * \param packetType the packet type | 147 * \param packetType the packet type |
144 * \returns true if fragmented | 148 * \returns true if fragmented |
145 */ | 149 */ |
146 bool CheckForFragmentation (MacHeaderType::HeaderType packetType); | 150 bool CheckForFragmentation (MacHeaderType::HeaderType packetType); |
147 /** | 151 /** |
148 * Get first packet header size function | 152 * Get first packet header size of the specified type |
149 * \param packetType the packet type | 153 * \param packetType the packet type |
150 * \returns the first packet header size | 154 * \returns the first packet header size |
151 */ | 155 */ |
152 uint32_t GetFirstPacketHdrSize (MacHeaderType::HeaderType packetType); | 156 uint32_t GetFirstPacketHdrSize (MacHeaderType::HeaderType packetType); |
153 /** | 157 /** |
154 * Get first packet payload size function | 158 * Get first packet payload size of the specified type |
155 * \param packetType the packet type | 159 * \param packetType the packet type |
156 * \returns the first packet payload size | 160 * \returns the first packet payload size |
157 */ | 161 */ |
158 uint32_t GetFirstPacketPayloadSize (MacHeaderType::HeaderType packetType); | 162 uint32_t GetFirstPacketPayloadSize (MacHeaderType::HeaderType packetType); |
159 /// Get first packet required byte | 163 /** |
| 164 * Get required number of bytes to hold first packet of packetType |
| 165 * \param packetType the packet type |
| 166 * \returns the sum of the first packet header and payload (of specified type) |
| 167 */ |
160 uint32_t GetFirstPacketRequiredByte (MacHeaderType::HeaderType packetType); | 168 uint32_t GetFirstPacketRequiredByte (MacHeaderType::HeaderType packetType); |
161 | 169 /** |
162 /// Get queue ength with MAC overhead function | 170 * Get queue length considering also the MAC overhead |
| 171 * \return queue length |
| 172 */ |
163 uint32_t GetQueueLengthWithMACOverhead (void); | 173 uint32_t GetQueueLengthWithMACOverhead (void); |
164 | |
165 /// Set fragmentation function | 174 /// Set fragmentation function |
| 175 /** |
| 176 * Set fragmentation state for first packet of type packetType |
| 177 * \param packetType packetType to check |
| 178 */ |
166 void SetFragmentation (MacHeaderType::HeaderType packetType); | 179 void SetFragmentation (MacHeaderType::HeaderType packetType); |
167 /// Set fragmentation number | 180 /** |
| 181 * Set fragment number for first packet of type packetType |
| 182 * \param packetType packetType to check |
| 183 */ |
168 void SetFragmentNumber (MacHeaderType::HeaderType packetType); | 184 void SetFragmentNumber (MacHeaderType::HeaderType packetType); |
169 /// Set fragmeentation offset | 185 /** |
| 186 * Set fragment offset for first packet of type packetType |
| 187 * \param packetType packetType to check |
| 188 * \param offset offset value to set |
| 189 */ |
170 void SetFragmentOffset (MacHeaderType::HeaderType packetType, uint32_t offset)
; | 190 void SetFragmentOffset (MacHeaderType::HeaderType packetType, uint32_t offset)
; |
171 | 191 |
172 /// QueueElement structure | 192 /// QueueElement structure |
173 struct QueueElement | 193 struct QueueElement |
174 { | 194 { |
175 QueueElement (void); | 195 QueueElement (void); |
176 /** | 196 /** |
177 * Constructor | 197 * Constructor |
178 * | 198 * |
179 * \param packet the packet | 199 * \param packet the packet |
(...skipping 10 matching lines...) Expand all Loading... |
190 * \returns the size | 210 * \returns the size |
191 */ | 211 */ |
192 uint32_t GetSize (void) const; | 212 uint32_t GetSize (void) const; |
193 Ptr<Packet> m_packet; ///< packet | 213 Ptr<Packet> m_packet; ///< packet |
194 MacHeaderType m_hdrType; ///< header type | 214 MacHeaderType m_hdrType; ///< header type |
195 GenericMacHeader m_hdr; ///< header | 215 GenericMacHeader m_hdr; ///< header |
196 Time m_timeStamp; ///< timestamp | 216 Time m_timeStamp; ///< timestamp |
197 | 217 |
198 /** | 218 /** |
199 To manage fragmentation feature, each QueueElement have 3 new fields: | 219 To manage fragmentation feature, each QueueElement have 3 new fields: |
200 m_fragmentation that became true when the fragmentation starts; | 220 m_fragmentation that becomes true when the fragmentation starts; |
201 m_fragmentNumber that are incremented when a new fragment is sent | 221 m_fragmentNumber that is incremented when a new fragment is sent |
202 m_fragmentOffset that describe the start of the next fragment into the pack
et | 222 m_fragmentOffset that tracks the start of the next fragment into the packet |
203 */ | 223 */ |
204 bool m_fragmentation; ///< becomes true when the fragmentation starts | 224 bool m_fragmentation; ///< becomes true when the fragmentation starts |
205 uint32_t m_fragmentNumber; ///< incremented when a new fragment is sent | 225 uint32_t m_fragmentNumber; ///< incremented when a new fragment is sent |
206 uint32_t m_fragmentOffset; ///< describes the start of the next fragment int
o the packet | 226 uint32_t m_fragmentOffset; ///< tracks the start of the next fragment into t
he packet |
207 | 227 |
208 /// Set fragmentation | 228 /// Set fragmentation |
209 void SetFragmentation (void); | 229 void SetFragmentation (void); |
210 /// Set fragment number | 230 /// Set fragment number |
211 void SetFragmentNumber (void); | 231 void SetFragmentNumber (void); |
212 /** | 232 /** |
213 * Set fragment offset | 233 * Set fragment offset |
214 * \param offset the offset | 234 * \param offset the offset |
215 */ | 235 */ |
216 void SetFragmentOffset (uint32_t offset); | 236 void SetFragmentOffset (uint32_t offset); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
249 /** | 269 /** |
250 * Get packet queue function | 270 * Get packet queue function |
251 * \returns the packet queue | 271 * \returns the packet queue |
252 */ | 272 */ |
253 const WimaxMacQueue::PacketQueue & GetPacketQueue (void) const; | 273 const WimaxMacQueue::PacketQueue & GetPacketQueue (void) const; |
254 }; | 274 }; |
255 | 275 |
256 } // namespace ns3 | 276 } // namespace ns3 |
257 | 277 |
258 #endif /* WIMAX_MAC_QUEUE_H */ | 278 #endif /* WIMAX_MAC_QUEUE_H */ |
LEFT | RIGHT |