satellite-arq-header.cc
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2013 Magister Solutions Ltd.
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: Jani Puttonen <jani.puttonen@magister.fi>
19  */
20 
21 #include "satellite-arq-header.h"
22 
23 #include <ns3/log.h>
24 
25 NS_LOG_COMPONENT_DEFINE("SatArqHeader");
26 
27 namespace ns3
28 {
29 
30 NS_OBJECT_ENSURE_REGISTERED(SatArqHeader);
31 
33  : m_seqNo(0)
34 {
35 }
36 
38 {
39 }
40 
41 TypeId
43 {
44  static TypeId tid =
45  TypeId("ns3::SatArqHeader").SetParent<Header>().AddConstructor<SatArqHeader>();
46  return tid;
47 }
48 
49 uint32_t
51 {
52  NS_LOG_FUNCTION(this);
53  return 1;
54 }
55 
56 void
57 SatArqHeader::Serialize(Buffer::Iterator start) const
58 {
59  NS_LOG_FUNCTION(this);
60  Buffer::Iterator i = start;
61  i.WriteU8(m_seqNo);
62 }
63 
64 uint32_t
65 SatArqHeader::Deserialize(Buffer::Iterator start)
66 {
67  NS_LOG_FUNCTION(this);
68  Buffer::Iterator i = start;
69 
70  m_seqNo = i.ReadU8();
71  return GetSerializedSize();
72 }
73 
74 void
75 SatArqHeader::Print(std::ostream& os) const
76 {
77  os << m_seqNo;
78 }
79 
80 TypeId
82 {
83  return GetTypeId();
84 }
85 
86 uint8_t
88 {
89  NS_LOG_FUNCTION(this);
90  return m_seqNo;
91 }
92 
93 void
94 SatArqHeader::SetSeqNo(uint8_t seqNo)
95 {
96  NS_LOG_FUNCTION(this << (uint32_t)seqNo);
97  m_seqNo = seqNo;
98 }
99 
100 } // namespace ns3
virtual uint32_t GetSerializedSize(void) const
Get serialized size of SatArqHeader.
static TypeId GetTypeId(void)
Get the type ID.
~SatArqHeader()
Destructor for SatArqHeader.
virtual void Serialize(Buffer::Iterator start) const
Serializes information to buffer from this instance of SatArqHeader.
virtual TypeId GetInstanceTypeId(void) const
Get the type ID of instance.
uint8_t GetSeqNo() const
Get sequence number.
virtual uint32_t Deserialize(Buffer::Iterator start)
Deserializes information from buffer to this instance of SatArqHeader.
SatArqHeader()
Constructor.
void SetSeqNo(uint8_t seqNo)
Set sequence number.
virtual void Print(std::ostream &os) const
Print time stamp of this instance of SatArqHeader.
uint8_t m_seqNo
Sequence number represented by one Byte.
SatArqSequenceNumber is handling the sequence numbers for the ARQ process.