Loading...
Searching...
No Matches
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
22
23#include "ns3/log.h"
24
25#include <ostream>
26
27NS_LOG_COMPONENT_DEFINE("SatArqHeader");
28
29namespace ns3
30{
31
32NS_OBJECT_ENSURE_REGISTERED(SatArqHeader);
33
38
42
43TypeId
45{
46 static TypeId tid =
47 TypeId("ns3::SatArqHeader").SetParent<Header>().AddConstructor<SatArqHeader>();
48 return tid;
49}
50
51uint32_t
53{
54 NS_LOG_FUNCTION(this);
55 return 1;
56}
57
58void
59SatArqHeader::Serialize(Buffer::Iterator start) const
60{
61 NS_LOG_FUNCTION(this);
62 Buffer::Iterator i = start;
63 i.WriteU8(m_seqNo);
64}
65
66uint32_t
67SatArqHeader::Deserialize(Buffer::Iterator start)
68{
69 NS_LOG_FUNCTION(this);
70 Buffer::Iterator i = start;
71
72 m_seqNo = i.ReadU8();
73 return GetSerializedSize();
74}
75
76void
77SatArqHeader::Print(std::ostream& os) const
78{
79 os << m_seqNo;
80}
81
82TypeId
84{
85 return GetTypeId();
86}
87
88uint8_t
90{
91 NS_LOG_FUNCTION(this);
92 return m_seqNo;
93}
94
95void
97{
98 NS_LOG_FUNCTION(this << (uint32_t)seqNo);
99 m_seqNo = seqNo;
100}
101
102} // namespace ns3
ARQ header implementation contains the sequence number related to the packet in question.
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.
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.