EMANE  1.2.1
models/phy/bypass/phylayer.cc
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2013-2014 - Adjacent Link LLC, Bridgewater, New Jersey
3  * Copyright (c) 2008-2009 - DRS CenGen, LLC, Columbia, Maryland
4  * All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions
8  * are met:
9  *
10  * * Redistributions of source code must retain the above copyright
11  * notice, this list of conditions and the following disclaimer.
12  * * Redistributions in binary form must reproduce the above copyright
13  * notice, this list of conditions and the following disclaimer in
14  * the documentation and/or other materials provided with the
15  * distribution.
16  * * Neither the name of DRS CenGen, LLC nor the names of its
17  * contributors may be used to endorse or promote products derived
18  * from this software without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
23  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
24  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
25  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
26  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
27  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
28  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
30  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31  * POSSIBILITY OF SUCH DAMAGE.
32  */
33 
34 #include "phylayer.h"
35 #include "emane/commonphyheader.h"
37 
39  PlatformServiceProvider* pPlatformService):
40  PHYLayerImplementor(id, pPlatformService),
41  commonLayerStatistics_{{}}
42 {}
43 
45 {}
46 
48 {
51  "PHYI %03hu Models::Bypass::PHYLayer::%s",
52  id_,
53  __func__);
54 }
55 
57  const ControlMessages &)
58 {
59  TimePoint beginTime{Clock::now()};
60 
61  commonLayerStatistics_.processInbound(pkt);
62 
65  "PHYI %03hu Models::Bypass::PHYLayer::%s",
66  id_,
67  __func__);
68 
69  CommonPHYHeader hdr{type_, // phy registration id
70  0, // subid
71  0, // tx power dBm
72  0, // bandwidth Hz
73  Clock::now(), // time stamp
74  FrequencySegments{{0,Microseconds::zero()}},
75  Transmitters{{id_,0}},
76  {0,false}}; // antenna gain dBi
77 
78  commonLayerStatistics_.processOutbound(pkt,
79  std::chrono::duration_cast<Microseconds>(Clock::now() - beginTime));
80 
81  sendDownstreamPacket(hdr,pkt);
82 }
83 
85  UpstreamPacket & pkt,
86  const ControlMessages &)
87 {
88  TimePoint beginTime{Clock::now()};
89 
90  commonLayerStatistics_.processInbound(pkt);
91 
94  "PHYI %03hu Models::Bypass::PHYLayer::%s",
95  id_,
96  __func__);
97 
98  commonLayerStatistics_.processOutbound(pkt,
99  std::chrono::duration_cast<Microseconds>(Clock::now() - beginTime));
100 
101  sendUpstreamPacket(pkt);
102 }
103 
105 {
107  DEBUG_LEVEL,
108  "PHYI %03hu Models::Bypass::PHYLayer::%s",
109  id_,
110  __func__);
111 
112  commonLayerStatistics_.registerStatistics(registrar.statisticRegistrar());;
113 }
114 
116 {
118  DEBUG_LEVEL,
119  "PHYI %03hu Models::Bypass::PHYLayer::%s",
120  id_,
121  __func__);
122 
123  if(!update.empty())
124  {
125  throw ConfigureException("Models::Bypass::PHYLayer: Unexpected configuration items.");
126  }
127 }
128 
130 {
132  DEBUG_LEVEL,
133  "PHYI %03hu Models::Bypass::PHYLayer::%s",
134  id_,
135  __func__);
136 }
137 
139 {
141  DEBUG_LEVEL,
142  "PHYI %03hu Models::Bypass::PHYLayer::%s",
143  id_,
144  __func__);
145 }
146 
148 {
150  DEBUG_LEVEL,
151  "PHYI %03hu Models::Bypass::PHYLayer::%s",
152  id_,
153  __func__);
154 
155 }
156 
158  const Serialization & )
159 {
161  DEBUG_LEVEL,
162  "PHYI %03hu Models::Bypass::PHYLayer::%s",
163  id_,
164  __func__);
165 }
166 
168  const TimePoint &,
169  const TimePoint &,
170  const TimePoint &,
171  const void *)
172 {
174  DEBUG_LEVEL,
175  "PHYI %03hu Models::Bypass::PHYLayer::%s",
176  id_,
177  __func__);
178 }
179 
std::string Serialization
Definition: serializable.h:42
A Packet class that allows upstream processing to strip layer headers as the packet travels up the st...
void processUpstreamPacket(const CommonPHYHeader &hdr, UpstreamPacket &pkt, const ControlMessages &msgs) override
The Registrar interface provides access to all of the emulator registrars.
Definition: registrar.h:50
void processDownstreamPacket(DownstreamPacket &pkt, const ControlMessages &msgs) override
#define LOGGER_VERBOSE_LOGGING(logger, level, fmt, args...)
virtual StatisticRegistrar & statisticRegistrar()=0
void processOutbound(const UpstreamPacket &pkt, Microseconds delay, size_t dropCode={})
Interface used to create a PHY layer plugin implementation.
Definition: phylayerimpl.h:53
void processEvent(const EventId &id, const Serialization &serialization) override
std::list< const ControlMessage * > ControlMessages
DECLARE_PHY_LAYER(EMANE::Models::Bypass::PHYLayer)
void sendDownstreamPacket(const CommonPHYHeader &hdr, DownstreamPacket &pkt, const ControlMessages &msgs=DownstreamTransport::empty)
Exception thrown when failures in configuration occur.
std::uint16_t EventId
Definition: types.h:53
The PlatformServiceProvider interface provides access to emulator services.
void registerStatistics(StatisticRegistrar &statisticRegistrar)
void processDownstreamControl(const ControlMessages &msgs) override
The common physical layer header used to facilitate heterogeneous radio model experimentation.
PHYLayer(NEMId id, PlatformServiceProvider *pPlatformService)
constructor
Specialized packet the allows downstream processing to add layer specific headers as the packet trave...
void initialize(Registrar &registrar) override
void configure(const ConfigurationUpdate &update) override
std::uint16_t NEMId
Definition: types.h:52
void processTimedEvent(TimerEventId eventId, const TimePoint &expireTime, const TimePoint &scheduleTime, const TimePoint &fireTime, const void *arg) override
PlatformServiceProvider * pPlatformService_
virtual LogServiceProvider & logService()=0
std::list< FrequencySegment > FrequencySegments
std::vector< ConfigurationNameAnyValues > ConfigurationUpdate
std::size_t TimerEventId
Definition: types.h:54
Clock::time_point TimePoint
Definition: types.h:50
std::list< Transmitter > Transmitters
Definition: transmitter.h:85
void sendUpstreamPacket(UpstreamPacket &pkt, const ControlMessages &msgs=empty)
#define LOGGER_STANDARD_LOGGING(logger, level, fmt, args...)
Implementation of the bypass PHY layer.
void processInbound(const UpstreamPacket &pkt)