34 #include "commonphyheader.pb.h" 36 class EMANE::CommonPHYHeader::Implementation
40 std::uint16_t u16SubId,
41 std::uint16_t u16SequenceNumber,
42 std::uint64_t u64BandwidthHz,
46 const std::pair<double,bool> & optionalFixedAntennaGaindBi):
47 registrationId_{registrationId},
49 u16SequenceNumber_{u16SequenceNumber},
50 u64BandwidthHz_{u64BandwidthHz},
52 frequencySegments_{frequencySegments},
53 transmitters_{transmitters},
54 optionalFixedAntennaGaindBi_{optionalFixedAntennaGaindBi}{}
58 return registrationId_;
68 return optionalFixedAntennaGaindBi_;
78 return u64BandwidthHz_;
83 return u16SequenceNumber_;
88 return frequencySegments_;
98 std::uint16_t u16SubId_;
99 std::uint16_t u16SequenceNumber_;
100 std::uint64_t u64BandwidthHz_;
104 std::pair<double,bool> optionalFixedAntennaGaindBi_;
113 if(pkt.
length() >= u16HeaderLength)
117 if(!msg.ParseFromArray(pkt.
get(),u16HeaderLength))
124 for(
const auto & transmitter : msg.transmitters())
126 transmitters.push_back({
static_cast<NEMId>(transmitter.nemid()),
127 transmitter.powerdbm()});
132 for(
const auto & segment : msg.frequencysegments())
134 if(segment.has_powerdbm())
136 frequencySegments.push_back({segment.frequencyhz(),
143 frequencySegments.push_back({segment.frequencyhz(),
150 std::uint16_t u16SubId{
static_cast<std::uint16_t
>(msg.subid())};
151 std::uint16_t u16SequenceNumber{
static_cast<std::uint16_t
>(msg.sequencenumber())};
152 std::uint64_t u64BandwidthHz{msg.bandwidthhz()};
154 std::pair<double,bool> optionalFixedAntennaGaindBi{0,msg.has_fixedantennagain()};
156 if(optionalFixedAntennaGaindBi.second)
158 optionalFixedAntennaGaindBi.first = msg.fixedantennagain();
161 pImpl_.reset(
new Implementation{registrationId,
168 optionalFixedAntennaGaindBi});
177 pkt.
strip(u16HeaderLength);
187 std::uint16_t u16SubId,
188 std::uint16_t u16SequenceNumber,
189 std::uint64_t u64BandwidthHz,
193 const std::pair<double,bool> & optionalFixedAntennaGaindBi):
194 pImpl_{
new Implementation{registrationId,
201 optionalFixedAntennaGaindBi}}
206 pImpl_(
std::move(rvalue.pImpl_))
213 return pImpl_->getRegistrationId();
218 return pImpl_->getSubId();
223 return pImpl_->getOptionalFixedAntennaGaindBi();
229 return pImpl_->getTxTime();
238 for(
const auto & segment: pImpl_->getFrequencySegments())
241 const auto & offset = segment.getOffset();
242 const auto & duration = segment.getDuration();
245 const auto relative = offset + duration;
267 return pImpl_->getBandwidthHz();
273 return pImpl_->getSequenceNumber();
279 return pImpl_->getFrequencySegments();
285 return pImpl_->getTransmitters();
291 msg.set_registrationid(pImpl_->getRegistrationId());
292 msg.set_subid(pImpl_->getSubId());
293 msg.set_sequencenumber(pImpl_->getSequenceNumber());
294 msg.set_bandwidthhz(pImpl_->getBandwidthHz());
295 msg.set_txtimemicroseconds(std::chrono::duration_cast<Microseconds>(pImpl_->getTxTime().time_since_epoch()).count());
297 const auto & optionalFixedAntennaGaindBi = pImpl_->getOptionalFixedAntennaGaindBi();
299 if(optionalFixedAntennaGaindBi.second)
301 msg.set_fixedantennagain(optionalFixedAntennaGaindBi.first);
304 for(
const auto & transmitter : pImpl_->getTransmitters())
306 auto pTransmitter = msg.add_transmitters();
307 pTransmitter->set_nemid(transmitter.getNEMId());
308 pTransmitter->set_powerdbm(transmitter.getPowerdBm());
311 for(
const auto & segment : pImpl_->getFrequencySegments())
313 auto pSegment = msg.add_frequencysegments();
314 pSegment->set_frequencyhz(segment.getFrequencyHz());
315 pSegment->set_offsetmicroseconds(segment.getOffset().count());
316 pSegment->set_durationmicroseconds(segment.getDuration().count());
318 if(segment.getPowerdBm().second)
320 pSegment->set_powerdbm(segment.getPowerdBm().first);
324 std::string sSerialization;
326 if(!msg.SerializeToString(&sSerialization))
332 pkt.
prepend(sSerialization.c_str(),sSerialization.size());
339 const auto & optionalFixedAntennaGaindBi =
340 pImpl_->getOptionalFixedAntennaGaindBi();
342 Strings sFormat{{
"regid: " + std::to_string( pImpl_->getRegistrationId())},
343 {
"seq: " + std::to_string(pImpl_->getSequenceNumber())},
344 {
"bandwidth: " + std::to_string(pImpl_->getBandwidthHz())},
345 {
"fixed antenna gain: " + std::string(optionalFixedAntennaGaindBi.second ?
"on" :
"off")},
346 {
"fixed antenna gain: " + std::to_string(optionalFixedAntennaGaindBi.first)},
347 {
"tx time: " + std::to_string(std::chrono::duration_cast<DoubleSeconds>(pImpl_->getTxTime().time_since_epoch()).count())}};
349 for(
const auto & segment : pImpl_->getFrequencySegments())
351 sFormat.push_back(
"freq: " + std::to_string(segment.getFrequencyHz()));
352 sFormat.push_back(
"duration: " + std::to_string(segment.getDuration().count()));
353 sFormat.push_back(
"offset: " + std::to_string(segment.getOffset().count()));
354 if(segment.getPowerdBm().second)
356 sFormat.push_back(
"segment power: " + std::to_string(segment.getPowerdBm().first));
360 for(
const auto & transmitter : pImpl_->getTransmitters())
362 sFormat.push_back(
"src: " + std::to_string(transmitter.getNEMId()));
363 sFormat.push_back(
"transmitter power: " + std::to_string(transmitter.getPowerdBm()));
A Packet class that allows upstream processing to strip layer headers as the packet travels up the st...
SerializationException is thrown when an exception occurs during serialization or deserialization of ...
std::uint16_t stripLengthPrefixFraming()
size_t strip(size_t size)
void prepend(const void *buf, size_t size)
Specialized packet the allows downstream processing to add layer specific headers as the packet trave...
std::uint16_t RegistrationId
std::chrono::microseconds Microseconds
std::list< std::string > Strings
std::list< FrequencySegment > FrequencySegments
Clock::time_point TimePoint
std::list< Transmitter > Transmitters
void prependLengthPrefixFraming(std::uint16_t u16Length)