Left: | ||
Right: |
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) 2013 Universita' di Firenze, Italy | 3 * Copyright (c) 2013 Universita' di Firenze, Italy |
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 |
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 * GNU General Public License for more details. | 12 * GNU General Public License for more details. |
13 * | 13 * |
14 * You should have received a copy of the GNU General Public License | 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 | 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 | 16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
17 * | 17 * |
18 * Author: Tommaso Pecorella <tommaso.pecorella@unifi.it> | 18 * Author: Tommaso Pecorella <tommaso.pecorella@unifi.it> |
19 * Michele Muccio <michelemuccio@virgilio.it> | |
19 */ | 20 */ |
20 | 21 |
21 #ifndef SIXLOWPAN_NET_DEVICE_H | 22 #ifndef SIXLOWPAN_NET_DEVICE_H |
22 #define SIXLOWPAN_NET_DEVICE_H | 23 #define SIXLOWPAN_NET_DEVICE_H |
23 | 24 |
24 #include <stdint.h> | 25 #include <stdint.h> |
25 #include <string> | 26 #include <string> |
26 #include <map> | 27 #include <map> |
27 #include "ns3/traced-callback.h" | 28 #include "ns3/traced-callback.h" |
28 #include "ns3/event-id.h" | 29 #include "ns3/event-id.h" |
29 #include "ns3/nstime.h" | 30 #include "ns3/nstime.h" |
30 #include "ns3/net-device.h" | 31 #include "ns3/net-device.h" |
31 #include "ns3/packet.h" | 32 #include "ns3/packet.h" |
32 #include "sixlowpan-header.h" | 33 #include "sixlowpan-header.h" |
33 | 34 #include "ns3/random-variable-stream.h" |
34 | 35 |
35 namespace ns3 { | 36 namespace ns3 { |
36 | 37 |
37 class Node; | 38 class Node; |
38 | |
39 namespace sixlowpan { | |
40 | 39 |
41 /** | 40 /** |
42 * \defgroup sixlowpan 6LoWPAN | 41 * \defgroup sixlowpan 6LoWPAN |
43 * \brief Performs 6LoWPAN compression of IPv6 packets as specified by RFC 4944 and RFC 6262 | 42 * \brief Performs 6LoWPAN compression of IPv6 packets as specified by RFC 4944 and RFC 6262 |
44 * | 43 * |
45 * This module acts as a middleware between IPv6 and a generic NetDevice. | 44 * This module acts as a shim between IPv6 and a generic NetDevice. |
46 * | 45 * |
47 * The module implements RFCs 4944 and 6262, with the following exceptions: | 46 * The module implements RFCs 4944 and 6262, with the following exceptions: |
48 * <ul> | 47 * <ul> |
49 * <li> MESH and LOWPAN_BC0 dispatch types are not supported </li> | 48 * <li> MESH and LOWPAN_BC0 dispatch types are not supported </li> |
50 * <li> HC2 encoding is not supported </li> | 49 * <li> HC2 encoding is not supported </li> |
51 * <li> IPHC's SAC and DAC are not supported </li> | 50 * <li> IPHC's SAC and DAC are not supported </li> |
52 *</ul> | 51 *</ul> |
53 */ | 52 */ |
54 | 53 |
55 /** | 54 /** |
56 * \ingroup sixlowpan | 55 * \ingroup sixlowpan |
57 * | 56 * |
58 * \brief Middleware performing 6LoWPAN compression, decompression and fragmenta tion. | 57 * \brief Shim performing 6LoWPAN compression, decompression and fragmentation. |
59 * | 58 * |
60 * This class implements the middleware between IPv6 and a generic NetDevice, | 59 * This class implements the shim between IPv6 and a generic NetDevice, |
61 * performing packet compression, decompression and fragmentation in a transpare nt way. | 60 * performing packet compression, decompression and fragmentation in a transpare nt way. |
62 * To this end, the class pretend to be a normal NetDevice, masquerading some fu nctinos | 61 * To this end, the class pretend to be a normal NetDevice, masquerading some fu nctions |
63 * of the underlying NetDevice. | 62 * of the underlying NetDevice. |
64 */ | 63 */ |
65 class SixLowPanNetDevice : public NetDevice | 64 class SixLowPanNetDevice : public NetDevice |
Mathieu Lacage
2013/11/25 07:59:14
If you use a sixlowpan namespace, there is zero po
Tommaso Pecorella
2013/11/25 11:08:26
The sixlowpan namespace doesn't affect NetDevice,
| |
66 { | 65 { |
67 public: | 66 public: |
68 /** | 67 /** |
69 * Enumeration of the dropping reasons in SixLoWPAN. | 68 * Enumeration of the dropping reasons in SixLoWPAN. |
70 */ | 69 */ |
71 enum DropReason | 70 enum DropReason |
72 { | 71 { |
73 DROP_FRAGMENT_TIMEOUT = 1, /**< Fragment timeout exceeded */ | 72 DROP_FRAGMENT_TIMEOUT = 1, /**< Fragment timeout exceeded */ |
74 DROP_FRAGMENT_BUFFERFULL, /**< Fragment buffer size exceeded */ | 73 DROP_FRAGMENT_BUFFER_FULL, /**< Fragment buffer size exceeded */ |
75 DROP_UNKNOWN_EXTENSION /**< Undupported compression kind */ | 74 DROP_UNKNOWN_EXTENSION /**< Unsupported compression kind */ |
76 }; | 75 }; |
77 | 76 |
78 /** | 77 /** |
79 * \brief Get the type ID. | 78 * \brief Get the type ID. |
80 * \return the object TypeId | 79 * \return the object TypeId |
81 */ | 80 */ |
82 static TypeId GetTypeId (void); | 81 static TypeId GetTypeId (void); |
83 | 82 |
84 /** | 83 /** |
85 * Constructor for the SixLowPanNetDevice. | 84 * Constructor for the SixLowPanNetDevice. |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
129 | 128 |
130 /** | 129 /** |
131 * \brief Setup SixLowPan to be a proxy for the specified NetDevice. | 130 * \brief Setup SixLowPan to be a proxy for the specified NetDevice. |
132 * All the packets incoming and outgoing from the NetDevice will be | 131 * All the packets incoming and outgoing from the NetDevice will be |
133 * processed by SixLowPanNetDevice. | 132 * processed by SixLowPanNetDevice. |
134 * | 133 * |
135 * \param device a smart pointer to the NetDevice to be proxied. | 134 * \param device a smart pointer to the NetDevice to be proxied. |
136 */ | 135 */ |
137 void SetNetDevice (Ptr<NetDevice> device); | 136 void SetNetDevice (Ptr<NetDevice> device); |
138 | 137 |
138 /** | |
139 * Assign a fixed random variable stream number to the random variables | |
140 * used by this model. Return the number of streams (possibly zero) that | |
141 * have been assigned. | |
142 * | |
143 * \param stream first stream index to use | |
144 * \return the number of stream indices assigned by this model | |
145 */ | |
146 int64_t AssignStreams (int64_t stream); | |
147 | |
139 protected: | 148 protected: |
140 virtual void DoDispose (void); | 149 virtual void DoDispose (void); |
141 | 150 |
142 private: | 151 private: |
143 /** | 152 /** |
144 * \brief receives all the packets from a NetDevice for further processing. | 153 * \brief receives all the packets from a NetDevice for further processing. |
145 * \param device the NetDevice the packet ws received from | 154 * \param device the NetDevice the packet ws received from |
146 * \param packet the received packet | 155 * \param packet the received packet |
147 * \param protocol the protocol (if known) | 156 * \param protocol the protocol (if known) |
148 * \param source the source address | 157 * \param source the source address |
149 * \param destination the destination address | 158 * \param destination the destination address |
150 * \param packetType the packet kind (e.g., HOST, BROADCAST, etc.) | 159 * \param packetType the packet kind (e.g., HOST, BROADCAST, etc.) |
151 * \return the IPv6 link-local address | 160 * \return the IPv6 link-local address |
152 */ | 161 */ |
153 void ReceiveFromDevice (Ptr<NetDevice> device, Ptr<const Packet> packet, uint1 6_t protocol, | 162 void ReceiveFromDevice (Ptr<NetDevice> device, Ptr<const Packet> packet, uint1 6_t protocol, |
154 Address const &source, Address const &destination, Pac ketType packetType); | 163 Address const &source, Address const &destination, Pac ketType packetType); |
155 | 164 |
156 /** | 165 /** |
157 * The callback used to notify higher layers that a packet has been received. | 166 * The callback used to notify higher layers that a packet has been received. |
158 */ | 167 */ |
159 NetDevice::ReceiveCallback m_rxCallback; | 168 NetDevice::ReceiveCallback m_rxCallback; |
160 | 169 |
161 /** | 170 /** |
162 * The callback used to notify higher layers that a packet has been received i n promiscuous mode. | 171 * The callback used to notify higher layers that a packet has been received i n promiscuous mode. |
163 */ | 172 */ |
164 NetDevice::PromiscReceiveCallback m_promiscRxCallback; | 173 NetDevice::PromiscReceiveCallback m_promiscRxCallback; |
165 | 174 |
166 /** | 175 /** |
167 * \brief Callback to trace TX (transmission) packets. | 176 * \brief Callback to trace TX (transmission) packets. |
177 * | |
178 * Data passed: | |
179 * \li Packet received (including 6LoWPAN header) | |
180 * \li Ptr to SixLowPanNetDevice | |
181 * \li interface index | |
168 */ | 182 */ |
169 TracedCallback<Ptr<const Packet>, Ptr<SixLowPanNetDevice>, uint32_t> m_txTrace ; | 183 TracedCallback<Ptr<const Packet>, Ptr<SixLowPanNetDevice>, uint32_t> m_txTrace ; |
170 | 184 |
171 /** | 185 /** |
172 * \brief Callback to trace RX (reception) packets. | 186 * \brief Callback to trace RX (reception) packets. |
187 * | |
188 * Data passed: | |
189 * \li Packet received (including 6LoWPAN header) | |
190 * \li Ptr to SixLowPanNetDevice | |
191 * \li interface index | |
173 */ | 192 */ |
174 TracedCallback<Ptr<const Packet>, Ptr<SixLowPanNetDevice>, uint32_t> m_rxTrace ; | 193 TracedCallback<Ptr<const Packet>, Ptr<SixLowPanNetDevice>, uint32_t> m_rxTrace ; |
175 | 194 |
176 /** | 195 /** |
177 * \brief Callback to trace drop packets. | 196 * \brief Callback to trace drop packets. |
178 */ | 197 * |
179 TracedCallback<DropReason, Ptr<SixLowPanNetDevice>, uint32_t> m_dropTrace; | 198 * Data passed: |
199 * \li DropReason | |
200 * \li Packet dropped (including 6LoWPAN header) | |
201 * \li Ptr to SixLowPanNetDevice | |
202 * \li interface index | |
203 */ | |
204 TracedCallback<DropReason, Ptr<const Packet>, Ptr<SixLowPanNetDevice>, uint32_ t> m_dropTrace; | |
180 | 205 |
181 /** | 206 /** |
182 * \brief make a link-local address from a MAC address. | 207 * \brief make a link-local address from a MAC address. |
183 * \param addr the MAC address | 208 * \param addr the MAC address |
184 * \return the IPv6 link-local address | 209 * \return the IPv6 link-local address |
185 */ | 210 */ |
186 Ipv6Address MakeLinkLocalAddressFromMac (Address const &addr); | 211 Ipv6Address MakeLinkLocalAddressFromMac (Address const &addr); |
187 | 212 |
188 /** | 213 /** |
189 * \brief make a global address from a MAC address. | 214 * \brief make a global address from a MAC address. |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
251 * \param dst the MAC destination address | 276 * \param dst the MAC destination address |
252 * \param srcAddress the IPv6 source address | 277 * \param srcAddress the IPv6 source address |
253 * \param dstAddress the IPv6 destination address | 278 * \param dstAddress the IPv6 destination address |
254 * \return the decompressed header type | 279 * \return the decompressed header type |
255 */ | 280 */ |
256 uint8_t DecompressLowPanNhc (Ptr<Packet> packet, Address const &src, Address c onst &dst, Ipv6Address srcAddress, Ipv6Address dstAddress); | 281 uint8_t DecompressLowPanNhc (Ptr<Packet> packet, Address const &src, Address c onst &dst, Ipv6Address srcAddress, Ipv6Address dstAddress); |
257 | 282 |
258 /** | 283 /** |
259 * \brief Compress the headers according to NHC compression. | 284 * \brief Compress the headers according to NHC compression. |
260 * \param packet the packet to be compressed | 285 * \param packet the packet to be compressed |
261 * \param elideChecksum elide UDP checksum (if true) | 286 * \param omitChecksum omit UDP checksum (if true) |
262 * \return the size of the removed headers | 287 * \return the size of the removed headers |
263 */ | 288 */ |
264 uint32_t CompressLowPanUdpNhc (Ptr<Packet> packet, bool elideChecksum); | 289 uint32_t CompressLowPanUdpNhc (Ptr<Packet> packet, bool omitChecksum); |
265 | 290 |
266 /** | 291 /** |
267 * \brief Decompress the headers according to NHC compression. | 292 * \brief Decompress the headers according to NHC compression. |
268 * \param packet the packet to be compressed | 293 * \param packet the packet to be compressed |
269 * \param saddr the IPv6 source address | 294 * \param saddr the IPv6 source address |
270 * \param daddr the IPv6 destination address | 295 * \param daddr the IPv6 destination address |
271 */ | 296 */ |
272 void DecompressLowPanUdpNhc (Ptr<Packet> packet, Ipv6Address saddr, Ipv6Addres s daddr); | 297 void DecompressLowPanUdpNhc (Ptr<Packet> packet, Ipv6Address saddr, Ipv6Addres s daddr); |
273 | 298 |
274 /** | 299 /** |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
317 * \brief Get the entire packet. | 342 * \brief Get the entire packet. |
318 * \return the entire packet | 343 * \return the entire packet |
319 */ | 344 */ |
320 Ptr<Packet> GetPacket () const; | 345 Ptr<Packet> GetPacket () const; |
321 | 346 |
322 /** | 347 /** |
323 * \brief Set the packet-to-be-defragmented size. | 348 * \brief Set the packet-to-be-defragmented size. |
324 * \param packetSize the packet size (bytes) | 349 * \param packetSize the packet size (bytes) |
325 */ | 350 */ |
326 void SetPacketSize (uint32_t packetSize); | 351 void SetPacketSize (uint32_t packetSize); |
352 | |
353 /** | |
354 * \brief Get a list of the current stored fragments. | |
355 */ | |
356 std::list< Ptr<Packet> > GetFraments () const; | |
327 | 357 |
328 private: | 358 private: |
329 /** | 359 /** |
330 * \brief The size of the reconstructed packet (bytes). | 360 * \brief The size of the reconstructed packet (bytes). |
331 */ | 361 */ |
332 uint32_t m_packetSize; | 362 uint32_t m_packetSize; |
333 | 363 |
334 /** | 364 /** |
335 * \brief The current fragments. | 365 * \brief The current fragments. |
336 */ | 366 */ |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
409 uint32_t m_ifIndex; /**< Interface index */ | 439 uint32_t m_ifIndex; /**< Interface index */ |
410 | 440 |
411 /** | 441 /** |
412 * \brief Force the EtherType number. | 442 * \brief Force the EtherType number. |
413 * Also implying that the underlying NetDevice is using 48-bit Addresses, e.g. , Ethernet, WiFi, etc. | 443 * Also implying that the underlying NetDevice is using 48-bit Addresses, e.g. , Ethernet, WiFi, etc. |
414 */ | 444 */ |
415 bool m_forceEtherType; | 445 bool m_forceEtherType; |
416 | 446 |
417 uint16_t m_etherType; /**< EtherType number (used only if m_forceEtherType is true) */ | 447 uint16_t m_etherType; /**< EtherType number (used only if m_forceEtherType is true) */ |
418 bool m_omitUdpChecksum; /**< Omit UDP checksum in NC1 encoding */ | 448 bool m_omitUdpChecksum; /**< Omit UDP checksum in NC1 encoding */ |
449 | |
450 Ptr<UniformRandomVariable> m_rng; //!< Rng for the fragments tag. | |
419 }; | 451 }; |
420 | 452 |
421 } // namespace ns3 | 453 } // namespace ns3 |
422 } | |
423 | 454 |
424 #endif /* SIXLOWPAN_NET_DEVICE_H */ | 455 #endif /* SIXLOWPAN_NET_DEVICE_H */ |
LEFT | RIGHT |