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 #include <ostream>
26 #include <vector>
27 
28 NS_LOG_COMPONENT_DEFINE("SatCrdsaReplicaTag");
29 
30 namespace ns3
31 {
32 
33 NS_OBJECT_ENSURE_REGISTERED(SatCrdsaReplicaTag);
34 
36  : m_numOfIds(0)
37 {
38  NS_LOG_FUNCTION(this);
39 }
40 
42 {
43  NS_LOG_FUNCTION(this);
44 
45  m_slotIds.clear();
46 }
47 
48 TypeId
50 {
51  static TypeId tid =
52  TypeId("ns3::SatCrdsaReplicaTag").SetParent<Tag>().AddConstructor<SatCrdsaReplicaTag>();
53  return tid;
54 }
55 
56 TypeId
58 {
59  NS_LOG_FUNCTION(this);
60 
61  return GetTypeId();
62 }
63 
64 void
66 {
67  NS_LOG_FUNCTION(this);
68  m_slotIds.push_back(slotId);
69  m_numOfIds = m_slotIds.size();
70 }
71 
72 std::vector<uint16_t>
74 {
75  NS_LOG_FUNCTION(this);
76  return m_slotIds;
77 }
78 
79 uint32_t
81 {
82  NS_LOG_FUNCTION(this);
83 
84  return (sizeof(uint8_t) + m_slotIds.size() * sizeof(uint16_t));
85 }
86 
87 void
88 SatCrdsaReplicaTag::Serialize(TagBuffer buffer) const
89 {
90  NS_LOG_FUNCTION(this << &buffer);
91 
92  buffer.WriteU8(m_numOfIds);
93 
94  for (uint8_t i = 0; i < m_numOfIds; i++)
95  {
96  buffer.WriteU16(m_slotIds[i]);
97  }
98 }
99 
100 void
102 {
103  NS_LOG_FUNCTION(this << &buffer);
104 
105  m_numOfIds = buffer.ReadU8();
106 
107  for (uint8_t i = 0; i < m_numOfIds; i++)
108  {
109  m_slotIds.push_back(buffer.ReadU16());
110  }
111 }
112 
113 void
114 SatCrdsaReplicaTag::Print(std::ostream& os) const
115 {
116  NS_LOG_FUNCTION(this << &os);
117 
118  os << "id=";
119 
120  for (uint8_t i = 0; i < m_numOfIds; i++)
121  {
122  os << m_slotIds[i] << " ";
123  }
124 }
125 
126 } // 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.