src/routing/dsdv/model/dsdv-packet.h
changeset 6717 e041eb593928
equal deleted inserted replaced
6716:e2c0e6a51e58 6717:e041eb593928
       
     1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
       
     2 /*
       
     3  * Copyright (c) 2010 Hemanth Narra
       
     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: Hemanth Narra <hemanth@ittc.ku.com>
       
    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 Experimentation on GENI),
       
    29  * US Department of Defense (DoD), and ITTC at The University of Kansas.
       
    30  */
       
    31 #ifndef DSDVPACKET_H_
       
    32 #define DSDVPACKET_H_
       
    33 
       
    34 #include <iostream>
       
    35 #include "ns3/header.h"
       
    36 #include "ns3/ipv4-address.h"
       
    37 #include "ns3/nstime.h"
       
    38 
       
    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
       
    57 {
       
    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)
       
    70   {
       
    71     m_dst = destination;
       
    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 private:
       
    99   Ipv4Address m_dst;     // /< Destination IP Address
       
   100   uint32_t m_hopCount;     // /< Number of Hops
       
   101   uint32_t m_dstSeqNo;     // /< Destination Sequence Number
       
   102 };
       
   103 static inline std::ostream & operator<< (std::ostream& os, const DsdvHeader & packet)
       
   104 {
       
   105   packet.Print (os);
       
   106   return os;
       
   107 }
       
   108 }
       
   109 }
       
   110 #endif /* DSDVPACKET_H_ */