satellite-uplink-info-tag.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: Bastien TAURAN <bastien.tauran@viveris.fr>
19  */
20 
22 
23 #include <ostream>
24 
25 namespace ns3
26 {
27 
28 NS_OBJECT_ENSURE_REGISTERED(SatUplinkInfoTag);
29 
31  : m_satelliteReceptionTime(Seconds(0)),
32  m_sinr(0.0),
33  m_additionalInterference(0.0),
34  m_sinrComputed(false),
35  m_satId(0),
36  m_beamId(0),
37  m_isControl(false)
38 {
39  // Nothing to do here
40 }
41 
42 SatUplinkInfoTag::SatUplinkInfoTag(Time satelliteReceptionTime,
43  double sinr,
44  double additionalInterference,
45  uint32_t satId,
46  uint32_t beamId,
47  bool isControl)
48  : m_satelliteReceptionTime(satelliteReceptionTime),
49  m_sinr(sinr),
50  m_additionalInterference(additionalInterference),
51  m_sinrComputed(true),
52  m_satId(satId),
53  m_beamId(beamId),
54  m_isControl(isControl)
55 {
56  // Nothing to do here
57 }
58 
59 TypeId
61 {
62  static TypeId tid =
63  TypeId("ns3::SatUplinkInfoTag").SetParent<Tag>().AddConstructor<SatUplinkInfoTag>();
64  return tid;
65 }
66 
67 TypeId
69 {
70  return GetTypeId();
71 }
72 
73 uint32_t
75 {
76  return sizeof(Time) + 2 * sizeof(double) + 2 * sizeof(bool) + 2 * sizeof(uint32_t);
77 }
78 
79 void
80 SatUplinkInfoTag::Serialize(TagBuffer i) const
81 {
82  int64_t satelliteReceptionTime = m_satelliteReceptionTime.GetNanoSeconds();
83  i.Write((const uint8_t*)&satelliteReceptionTime, sizeof(int64_t));
84 
85  i.WriteDouble(m_sinr);
86  i.WriteDouble(m_additionalInterference);
87  i.WriteU8(m_sinrComputed);
88  i.WriteU32(m_satId);
89  i.WriteU32(m_beamId);
90  i.WriteU8(m_isControl);
91 }
92 
93 void
95 {
96  int64_t satelliteReceptionTime;
97  i.Read((uint8_t*)&satelliteReceptionTime, 8);
98  m_satelliteReceptionTime = NanoSeconds(satelliteReceptionTime);
99 
100  m_sinr = i.ReadDouble();
101  m_additionalInterference = i.ReadDouble();
102  m_sinrComputed = i.ReadU8();
103  m_satId = i.ReadU32();
104  m_beamId = i.ReadU32();
105  m_isControl = i.ReadU8();
106 }
107 
108 void
109 SatUplinkInfoTag::Print(std::ostream& os) const
110 {
111  os << m_satelliteReceptionTime << " " << m_sinr << " " << m_satId << " " << m_beamId << " "
112  << m_isControl;
113 }
114 
115 Time
117 {
119 }
120 
121 void
123 {
124  m_satelliteReceptionTime = satelliteReceptionTime;
125 }
126 
127 double
129 {
130  return m_sinr;
131 }
132 
133 void
134 SatUplinkInfoTag::SetSinr(double sinr, double additionalInterference)
135 {
136  m_sinr = sinr;
137  m_additionalInterference = additionalInterference;
138 }
139 
140 double
142 {
144 }
145 
146 bool
148 {
149  return m_sinrComputed;
150 }
151 
152 uint32_t
154 {
155  return m_satId;
156 }
157 
158 void
160 {
161  m_satId = satId;
162 }
163 
164 uint32_t
166 {
167  return m_beamId;
168 }
169 
170 void
172 {
173  m_beamId = beamId;
174 }
175 
176 bool
178 {
179  return m_isControl;
180 }
181 
182 void
184 {
185  m_isControl = isControl;
186 }
187 
188 } // namespace ns3
SatArqSequenceNumber is handling the sequence numbers for the ARQ process.