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) 2010 Hemanth Narra, KU | 3 * Copyright (c) 2010 Hemanth Narra |
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 * Authors: Hemanth Narra <hemanth@ittc.ku.com> | 18 * Author: Hemanth Narra <hemanth@ittc.ku.com> |
19 * | 19 * |
20 * Thanks to the students and our professor Dr.James P.G. Sterbenz in the Resili
Nets group | 20 * James P.G. Sterbenz <jpgs@ittc.ku.edu>, director |
21 * at The University of Kansas, https://wiki.ittc.ku.edu/resilinets/Main_Page | 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 Experimenta
tion on GENI), |
| 29 * US Department of Defense (DoD), and ITTC at The University of Kansas. |
22 */ | 30 */ |
23 #ifndef DSDVPACKET_H_ | 31 #ifndef DSDVPACKET_H_ |
24 #define DSDVPACKET_H_ | 32 #define DSDVPACKET_H_ |
25 | 33 |
26 #include <iostream> | 34 #include <iostream> |
27 #include "ns3/header.h" | 35 #include "ns3/header.h" |
28 #include "ns3/ipv4-address.h" | 36 #include "ns3/ipv4-address.h" |
29 #include "ns3/nstime.h" | 37 #include "ns3/nstime.h" |
30 | 38 |
31 namespace ns3 | 39 namespace ns3 { |
| 40 namespace dsdv { |
| 41 /** |
| 42 * \ingroup dsdv |
| 43 * \brief DSDV Update Packet Format |
| 44 * \verbatim |
| 45 | 0 | 1 | 2 | 3 | |
| 46 0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7 |
| 47 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
| 48 | Destination Address | |
| 49 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
| 50 | HopCount | |
| 51 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
| 52 | Sequence Number | |
| 53 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
| 54 */ |
| 55 |
| 56 class DsdvHeader : public Header |
32 { | 57 { |
33 namespace dsdv | 58 public: |
| 59 DsdvHeader (Ipv4Address dst = Ipv4Address (), uint32_t hopcount = 0, uint32_t
dstSeqNo = 0); |
| 60 virtual ~DsdvHeader (); |
| 61 static TypeId GetTypeId (void); |
| 62 virtual TypeId GetInstanceTypeId (void) const; |
| 63 virtual uint32_t GetSerializedSize () const; |
| 64 virtual void Serialize (Buffer::Iterator start) const; |
| 65 virtual uint32_t Deserialize (Buffer::Iterator start); |
| 66 virtual void Print (std::ostream &os) const; |
| 67 |
| 68 void |
| 69 SetDst (Ipv4Address destination) |
34 { | 70 { |
35 /** | 71 m_dst = destination; |
36 * \ingroup dsdv | |
37 * \brief DSDV Update Packet Format | |
38 * \verbatim | |
39 | » 0 | 1 | 2 | 3 | | |
40 0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7 | |
41 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | |
42 | Destination Address | | |
43 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | |
44 | HopCount | | |
45 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | |
46 | Sequence Number | | |
47 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | |
48 */ | |
49 | |
50 class DsdvHeader : public Header | |
51 { | |
52 public: | |
53 DsdvHeader (Ipv4Address dst = Ipv4Address(), uint32_t hopcount = 0, uint32
_t dstSeqNo = 0); | |
54 TypeId | |
55 GetInstanceTypeId () const; | |
56 uint32_t | |
57 GetSerializedSize () const; | |
58 void | |
59 Serialize (Buffer::Iterator start) const; | |
60 uint32_t | |
61 Deserialize (Buffer::Iterator start); | |
62 void | |
63 Print (std::ostream &os) const; | |
64 void | |
65 SetDst (Ipv4Address destination) | |
66 { | |
67 m_dst = destination; | |
68 } | |
69 Ipv4Address | |
70 GetDst () const | |
71 { | |
72 return m_dst; | |
73 } | |
74 void | |
75 SetHopCount (uint32_t hopCount) | |
76 { | |
77 m_hopCount = hopCount; | |
78 } | |
79 uint32_t | |
80 GetHopCount () const | |
81 { | |
82 return m_hopCount; | |
83 } | |
84 void | |
85 SetDstSeqno (uint32_t sequenceNumber) | |
86 { | |
87 m_dstSeqNo = sequenceNumber; | |
88 } | |
89 uint32_t | |
90 GetDstSeqno () const | |
91 { | |
92 return m_dstSeqNo; | |
93 } | |
94 bool | |
95 operator== (DsdvHeader const & o) const; | |
96 private: | |
97 Ipv4Address m_dst; ///< Destination IP Address | |
98 uint32_t m_hopCount; ///< Number of Hops | |
99 uint32_t m_dstSeqNo; ///< Destination Sequence Number | |
100 }; | |
101 | |
102 std::ostream & | |
103 operator<< (std::ostream & os, DsdvHeader const &); | |
104 } | 72 } |
| 73 Ipv4Address |
| 74 GetDst () const |
| 75 { |
| 76 return m_dst; |
| 77 } |
| 78 void |
| 79 SetHopCount (uint32_t hopCount) |
| 80 { |
| 81 m_hopCount = hopCount; |
| 82 } |
| 83 uint32_t |
| 84 GetHopCount () const |
| 85 { |
| 86 return m_hopCount; |
| 87 } |
| 88 void |
| 89 SetDstSeqno (uint32_t sequenceNumber) |
| 90 { |
| 91 m_dstSeqNo = sequenceNumber; |
| 92 } |
| 93 uint32_t |
| 94 GetDstSeqno () const |
| 95 { |
| 96 return m_dstSeqNo; |
| 97 } |
| 98 bool |
| 99 operator== (DsdvHeader const & o) const; |
| 100 private: |
| 101 Ipv4Address m_dst; // /< Destination IP Address |
| 102 uint32_t m_hopCount; // /< Number of Hops |
| 103 uint32_t m_dstSeqNo; // /< Destination Sequence Number |
| 104 }; |
| 105 static inline std::ostream & operator<< (std::ostream& os, const DsdvHeader & pa
cket) |
| 106 { |
| 107 packet.Print (os); |
| 108 return os; |
| 109 } |
| 110 } |
105 } | 111 } |
106 #endif /* DSDVPACKET_H_ */ | 112 #endif /* DSDVPACKET_H_ */ |
LEFT | RIGHT |