From 736fbc07e67efc7e59b50c4b4c525f610902bd35 Mon Sep 17 00:00:00 2001 From: Borovkova Elena Date: Mon, 6 Jul 2009 22:57:10 +0400 Subject: [PATCH] RREP_ACK header --- src/routing/aodv/aodv-packet.cc | 57 +++++++++++++++++++++++++++++++++ src/routing/aodv/aodv-packet.h | 30 +++++++++++++++++ 2 files changed, 87 insertions(+) diff --git a/src/routing/aodv/aodv-packet.cc b/src/routing/aodv/aodv-packet.cc index 60d209161..f4143e333 100644 --- a/src/routing/aodv/aodv-packet.cc +++ b/src/routing/aodv/aodv-packet.cc @@ -322,5 +322,62 @@ bool RrepHeaderTest::RunTests () } #endif +//----------------------------------------------------------------------------- +// RREP-ACK +//----------------------------------------------------------------------------- + +RrepAckHader::RrepAckHader () : reserved(0) +{ +} + +TypeId +RrepAckHader::GetInstanceTypeId() const +{ + return TypeId(); +} + +uint32_t +RrepAckHader::GetSerializedSize () const +{ + return 2; +} + +void +RrepAckHader::Serialize (Buffer::Iterator i) const +{ + i.WriteU8(type()); + i.WriteU8(reserved); +} + +uint32_t +RrepAckHader::Deserialize (Buffer::Iterator start) +{ + Buffer::Iterator i = start; + uint8_t t = i.ReadU8 (); + NS_ASSERT (t == type()); + reserved = i.ReadU8 (); + uint32_t dist = i.GetDistanceFrom (start); + NS_ASSERT (dist == GetSerializedSize ()); + return dist; +} + +void +RrepAckHader::Print (std::ostream &os) const +{ + // TODO +} + +bool +RrepAckHader::operator==(RrepAckHader const & o) const +{ + return reserved == o.reserved; +} + +std::ostream & operator<<(std::ostream & os, RrepAckHader const & h) +{ + h.Print(os); + return os; +} + }} diff --git a/src/routing/aodv/aodv-packet.h b/src/routing/aodv/aodv-packet.h index ff787016d..e66995f81 100644 --- a/src/routing/aodv/aodv-packet.h +++ b/src/routing/aodv/aodv-packet.h @@ -188,6 +188,36 @@ private: std::ostream & operator<<(std::ostream & os, RrepHeader const &); +/** + * \ingroup aodv + * \brief Route Reply Acknowledgment (RREP-ACK) Message Format + * 0 1 + 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + | Type | Reserved | + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + */ +class RrepAckHader : public Header +{ +public: + RrepAckHader (); + + ///\name Header serialization/deserialization + //\{ + TypeId GetInstanceTypeId() const; + uint32_t GetSerializedSize () const; + void Serialize (Buffer::Iterator start) const; + uint32_t Deserialize (Buffer::Iterator start); + void Print (std::ostream &os) const; + //\} + bool operator==(RrepAckHader const & o) const; +private: + static MessageType type() { return AODVTYPE_RREP_ACK; } + uint8_t reserved; +}; +std::ostream & operator<<(std::ostream & os, RrepAckHader const &); + + } }