OLD | NEW |
(Empty) | |
| 1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
| 2 /* |
| 3 * Copyright (c) 2015 Amir Modarresi |
| 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 * |
| 18 * Author: Amir Modarresi <amodarresi@ittc.ku.edu> |
| 19 * |
| 20 * James P.G. Sterbenz <jpgs@ittc.ku.edu>, director |
| 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. |
| 30 */ |
| 31 |
| 32 #ifndef SIFT_HEADER_H |
| 33 #define SIFT_HEADER_H |
| 34 #define UDP_PROTOCOL 17 |
| 35 #define GRE_PROTOCOL 47 |
| 36 |
| 37 #include <vector> |
| 38 #include <list> |
| 39 #include <ostream> |
| 40 |
| 41 #include "ns3/header.h" |
| 42 #include "ns3/ipv4-address.h" |
| 43 |
| 44 namespace ns3 { |
| 45 namespace sift { |
| 46 /** |
| 47 * \class SiftHeader |
| 48 * \brief Header for Sift Routing. |
| 49 */ |
| 50 |
| 51 /** |
| 52 * \ingroup sift |
| 53 * \brief Sift header Format |
| 54 0 | 1 | 2 | 3 |
| 55 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 |
| 56 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
| 57 | Next Header | Option Length | Message Type | Segment Left | |
| 58 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
| 59 | Source X Coordinate | |
| 60 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
| 61 | Source Y Coordinate | |
| 62 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
| 63 | Last Source X Coordinate | |
| 64 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
| 65 | Last Source Y Coordinate | |
| 66 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
| 67 | Destination X Coordinate | |
| 68 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
| 69 | Destination Y Coordinate | |
| 70 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
| 71 | Source IP Address | |
| 72 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
| 73 | Destination IP Address | |
| 74 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
| 75 | Seq No | TTL | Pad | |
| 76 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
| 77 */ |
| 78 class SiftHeader : public Header |
| 79 { |
| 80 public: |
| 81 /** |
| 82 * \brief Get the type identificator. |
| 83 * \return type identificator |
| 84 */ |
| 85 static TypeId GetTypeId (); |
| 86 /** |
| 87 * \brief Get the instance type ID. |
| 88 * \return instance type ID |
| 89 */ |
| 90 virtual TypeId GetInstanceTypeId () const; |
| 91 /** |
| 92 * \brief Constructor. |
| 93 */ |
| 94 SiftHeader (); |
| 95 /** |
| 96 * \brief Destructor. |
| 97 */ |
| 98 virtual ~SiftHeader (); |
| 99 /** |
| 100 * \brief Set the "Next header" field. |
| 101 * \param nextHeader the next header number |
| 102 */ |
| 103 void SetNextHeader (uint8_t protocol); |
| 104 /** |
| 105 * \brief Get the next header. |
| 106 * \return the next header number |
| 107 */ |
| 108 uint8_t GetNextHeader () const; |
| 109 /** |
| 110 * brief Set the message type of the header. |
| 111 * \param message type the message type of the header |
| 112 */ |
| 113 void SetOptionLength (uint8_t optionLength); |
| 114 /** |
| 115 * brief Get the message type of the header. |
| 116 * \return message type the message type of the header |
| 117 */ |
| 118 uint8_t GetOptionLength () const; |
| 119 /** |
| 120 * brief Set the source id of the header. |
| 121 * \param source id the source id of the header |
| 122 */ |
| 123 |
| 124 |
| 125 void SetSourceAddress (Ipv4Address address); |
| 126 /** |
| 127 * brief Get the source id of the header. |
| 128 * \return source id the source id of the header |
| 129 */ |
| 130 Ipv4Address GetSourceAddress () const; |
| 131 |
| 132 void SetDestAddress (Ipv4Address address); |
| 133 /** |
| 134 * brief Get the dest id of the header. |
| 135 * \return dest id the dest id of the header |
| 136 */ |
| 137 Ipv4Address GetDestAddress () const; |
| 138 /** |
| 139 * brief Set the segments left of the header. |
| 140 * \param segmentsLeft segment left field of the header |
| 141 */ |
| 142 void SetSegmentsLeft (uint8_t segmentsLeft); |
| 143 /** |
| 144 * brief Get the segments left field of the header. |
| 145 * \return segments left field of the header |
| 146 */ |
| 147 uint8_t GetSegmentsLeft () const; |
| 148 /** |
| 149 * brief Set the message type of the header. |
| 150 * \param message type the message type of the header |
| 151 */ |
| 152 void SetMessageType (uint8_t messageType); |
| 153 /** |
| 154 * brief Get the message type of the header. |
| 155 * \return message type the message type of the header |
| 156 */ |
| 157 uint8_t GetMessageType () const; |
| 158 /** |
| 159 * \brief Set the number of ipv4 address. |
| 160 * \param n the number of ipv4 address |
| 161 */ |
| 162 void SetSourceXLoc (int32_t x); |
| 163 int32_t GetSourceXLoc () const; |
| 164 void SetSourceYLoc (int32_t y); |
| 165 int32_t GetSourceYLoc () const; |
| 166 void SetLastSourceXLoc (int32_t x); |
| 167 int32_t GetLastSourceXLoc () const; |
| 168 void SetLastSourceYLoc (int32_t y); |
| 169 int32_t GetLastSourceYLoc () const; |
| 170 void SetDestXLoc (int32_t x); |
| 171 int32_t GetDestXLoc () const; |
| 172 void SetDestYLoc (int32_t y); |
| 173 int32_t GetDestYLoc () const; |
| 174 void SetHeaderSeqNo (uint16_t seqNo); |
| 175 uint16_t GetHeaderSeqNo () const; |
| 176 void SetHeaderTTL (uint8_t ttl); |
| 177 uint8_t GetHeaderTTL () const; |
| 178 void UpdateHeaderTTL (); |
| 179 |
| 180 |
| 181 void SetNumberAddress (uint8_t n); |
| 182 /** |
| 183 * \brief Set the vector of ipv4 address |
| 184 * \param ipv4Address the vector of ipv4 address |
| 185 */ |
| 186 void SetNodesAddress (std::vector<Ipv4Address> ipv4Address); |
| 187 /** |
| 188 * \brief Get the vector of ipv4 address |
| 189 * \return the vector of ipv4 address |
| 190 */ |
| 191 std::vector<Ipv4Address> GetNodesAddresses () const; |
| 192 /** |
| 193 * \brief Set a Node IPv4 Address. |
| 194 * \param index the index of the IPv4 Address |
| 195 * \param addr the new IPv4 Address |
| 196 */ |
| 197 void SetNodeAddress (uint8_t index, Ipv4Address addr); |
| 198 /** |
| 199 * \brief Get a Node IPv4 Address. |
| 200 * \param index the index of the IPv4 Address |
| 201 * \return the router IPv4 Address |
| 202 */ |
| 203 Ipv4Address GetNodeAddress (uint8_t index) const; |
| 204 /* |
| 205 * \brief Get the node list size which is the number of ip address of the route |
| 206 * \return the node list size |
| 207 */ |
| 208 uint8_t GetNodeListSize () const; |
| 209 /** |
| 210 * \brief Print some informations about the packet. |
| 211 * \param os output stream |
| 212 * \return info about this packet |
| 213 */ |
| 214 virtual void Print (std::ostream &os) const; |
| 215 /** |
| 216 * \brief Get the serialized size of the packet. |
| 217 * \return size |
| 218 */ |
| 219 virtual void Print (); |
| 220 /* |
| 221 * Prints header |
| 222 */ |
| 223 virtual uint32_t GetSerializedSize () const; |
| 224 /** |
| 225 * \brief Serialize the packet. |
| 226 * \param start Buffer iterator |
| 227 */ |
| 228 virtual void Serialize (Buffer::Iterator start) const; |
| 229 /** |
| 230 * \brief Deserialize the packet. |
| 231 * \param start Buffer iterator |
| 232 * \return size of the packet |
| 233 */ |
| 234 virtual uint32_t Deserialize (Buffer::Iterator start); |
| 235 |
| 236 private: |
| 237 /** |
| 238 * \brief The "next header" field. |
| 239 */ |
| 240 uint8_t m_nextHeader; |
| 241 /** |
| 242 * \brief The type of the message. |
| 243 */ |
| 244 uint8_t m_optionLength; |
| 245 /** |
| 246 * \brief The type of the message. |
| 247 */ |
| 248 uint8_t m_messageType; |
| 249 /** |
| 250 * \brief The segments left to keep track of how many hops to go. |
| 251 */ |
| 252 uint8_t m_segmentsLeft; |
| 253 /** |
| 254 * \brief The data of the extension. |
| 255 */ |
| 256 //Buffer m_data; |
| 257 /** |
| 258 * \brief The source node id |
| 259 */ |
| 260 uint32_t m_sourceId; |
| 261 /** |
| 262 * \brief The destination node id |
| 263 */ |
| 264 int32_t m_sourceXLoc; |
| 265 /** |
| 266 * \ brief source x location. it doesn't change until reaches to final destina
tion |
| 267 */ |
| 268 int32_t m_sourceYLoc; |
| 269 /**· |
| 270 * brief source Y location. It doesn't change until reaches to final destinati
on |
| 271 */ |
| 272 int32_t m_lastsourceXLoc; |
| 273 /** |
| 274 * brief last source X location. it changes in each hup |
| 275 */ |
| 276 int32_t m_lastsourceYLoc; |
| 277 /** |
| 278 * brief last source Y location. it changes in each hop |
| 279 */ |
| 280 int32_t m_destId; |
| 281 /** |
| 282 * \brief The source node id |
| 283 */ |
| 284 int32_t m_destXLoc; |
| 285 /** |
| 286 * destination X location |
| 287 */ |
| 288 int32_t m_destYLoc; |
| 289 /** |
| 290 * destination Y location |
| 291 */ |
| 292 uint16_t m_headerSeqNo; // SIFT Seq number |
| 293 uint8_t m_headerTTL; // SIFT TTL |
| 294 uint8_t m_pad; // 1 Byte pad to fit the header to multiple of 4 |
| 295 Ipv4Address m_sourceAddress; |
| 296 /** |
| 297 * \brief The destination node id |
| 298 */ |
| 299 Ipv4Address m_destAddress; |
| 300 /** |
| 301 * \brief A vector of IPv4 Address. |
| 302 */ |
| 303 |
| 304 typedef std::vector<Ipv4Address> VectorIpv4Address_t; |
| 305 /** |
| 306 * \brief The vector of Nodes' IPv4 Address. |
| 307 */ |
| 308 VectorIpv4Address_t m_ipv4Address; |
| 309 }; |
| 310 |
| 311 } // namespace sift |
| 312 } // namespace ns3 |
| 313 |
| 314 #endif /* SIFT_HEADER_H */ |
| 315 |
OLD | NEW |