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