satellite-crdsa-replica-tag.cc
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2014 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: Frans Laakso <frans.laakso@magister.fi>
19  */
20 
22 
23 #include <ns3/log.h>
24 
25 NS_LOG_COMPONENT_DEFINE("SatCrdsaReplicaTag");
26 
27 namespace ns3
28 {
29 
30 NS_OBJECT_ENSURE_REGISTERED(SatCrdsaReplicaTag);
31 
33  : m_numOfIds(0)
34 {
35  NS_LOG_FUNCTION(this);
36 }
37 
39 {
40  NS_LOG_FUNCTION(this);
41 
42  m_slotIds.clear();
43 }
44 
45 TypeId
47 {
48  static TypeId tid =
49  TypeId("ns3::SatCrdsaReplicaTag").SetParent<Tag>().AddConstructor<SatCrdsaReplicaTag>();
50  return tid;
51 }
52 
53 TypeId
55 {
56  NS_LOG_FUNCTION(this);
57 
58  return GetTypeId();
59 }
60 
61 void
63 {
64  NS_LOG_FUNCTION(this);
65  m_slotIds.push_back(slotId);
66  m_numOfIds = m_slotIds.size();
67 }
68 
69 std::vector<uint16_t>
71 {
72  NS_LOG_FUNCTION(this);
73  return m_slotIds;
74 }
75 
76 uint32_t
78 {
79  NS_LOG_FUNCTION(this);
80 
81  return (sizeof(uint8_t) + m_slotIds.size() * sizeof(uint16_t));
82 }
83 
84 void
85 SatCrdsaReplicaTag::Serialize(TagBuffer buffer) const
86 {
87  NS_LOG_FUNCTION(this << &buffer);
88 
89  buffer.WriteU8(m_numOfIds);
90 
91  for (uint8_t i = 0; i < m_numOfIds; i++)
92  {
93  buffer.WriteU16(m_slotIds[i]);
94  }
95 }
96 
97 void
99 {
100  NS_LOG_FUNCTION(this << &buffer);
101 
102  m_numOfIds = buffer.ReadU8();
103 
104  for (uint8_t i = 0; i < m_numOfIds; i++)
105  {
106  m_slotIds.push_back(buffer.ReadU16());
107  }
108 }
109 
110 void
111 SatCrdsaReplicaTag::Print(std::ostream& os) const
112 {
113  NS_LOG_FUNCTION(this << &os);
114 
115  os << "id=";
116 
117  for (uint8_t i = 0; i < m_numOfIds; i++)
118  {
119  os << m_slotIds[i] << " ";
120  }
121 }
122 
123 } // namespace ns3
virtual void Deserialize(TagBuffer buffer)
Deserializes information from buffer to this instance of SatCrdsaReplicaTag.
std::vector< uint16_t > m_slotIds
virtual uint32_t GetSerializedSize(void) const
Get serialized size of SatCrdsaReplicaTag.
virtual TypeId GetInstanceTypeId(void) const
Get the type ID of instance.
static TypeId GetTypeId(void)
Get the type ID.
~SatCrdsaReplicaTag()
Destructor for SatCrdsaReplicaTag.
virtual void Serialize(TagBuffer buffer) const
Serializes information to buffer from this instance of SatCrdsaReplicaTag.
virtual void Print(std::ostream &os) const
Print time stamp of this instance of SatCrdsaReplicaTag.
SatCrdsaReplicaTag()
Default constructor.
std::vector< uint16_t > GetSlotIds(void)
SatArqSequenceNumber is handling the sequence numbers for the ARQ process.