EMANE  1.0.1
receivemanager.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2015 - Adjacent Link LLC, Bridgewater, New Jersey
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  *
9  * * Redistributions of source code must retain the above copyright
10  * notice, this list of conditions and the following disclaimer.
11  * * Redistributions in binary form must reproduce the above copyright
12  * notice, this list of conditions and the following disclaimer in
13  * the documentation and/or other materials provided with the
14  * distribution.
15  * * Neither the name of Adjacent Link LLC nor the names of its
16  * contributors may be used to endorse or promote products derived
17  * from this software without specific prior written permission.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
22  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
23  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
24  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
25  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
26  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
27  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
29  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30  * POSSIBILITY OF SUCH DAMAGE.
31  */
32 
33 #ifndef EMANEMODELSTDMARECEIVEMANAGER_HEADER_
34 #define EMANEMODELSTDMARECEIVEMANAGER_HEADER_
35 
36 #include "emane/types.h"
37 #include "emane/upstreampacket.h"
41 #include "emane/frequencysegment.h"
45 
46 #include "pormanager.h"
47 #include "basemodelmessage.h"
49 
50 #include <tuple>
51 
52 namespace EMANE
53 {
54  namespace Models
55  {
56  namespace TDMA
57  {
69  {
70  public:
72  DownstreamTransport * pDownstreamTransport,
73  LogServiceProvider * pLogService,
74  RadioServiceProvider * pRadioService,
75  Scheduler * pScheduler,
76  PacketStatusPublisher * pPacketStatusPublisher,
77  NeighborMetricManager *pNeighborMetricManager);
78 
79  void setFragmentCheckThreshold(const std::chrono::seconds & threshold);
80 
81  void setFragmentTimeoutThreshold(const std::chrono::seconds & threshold);
82 
83  void setPromiscuousMode(bool bEnable);
84 
85  void loadCurves(const std::string & sPCRFileName);
86 
87  bool enqueue(BaseModelMessage && baseModelMessage,
88  const PacketInfo & pktInfo,
89  size_t length,
90  const TimePoint & startOfReception,
91  const FrequencySegments & frequencySegments,
92  const Microseconds & span,
93  const TimePoint & beginTime,
94  std::uint64_t u64PacketSequence);
95 
96  void process(std::uint64_t u64AbsoluteSlotIndex);
97 
98  private:
99  NEMId id_;
100  DownstreamTransport * pDownstreamTransport_;
101  LogServiceProvider * pLogService_;
102  RadioServiceProvider * pRadioService_;
103  Scheduler * pScheduler_;
104  PacketStatusPublisher * pPacketStatusPublisher_;
105  NeighborMetricManager * pNeighborMetricManager_;
106 
107  using PendingInfo = std::tuple<BaseModelMessage,
108  PacketInfo,
109  size_t,
110  TimePoint, //sor
112  Microseconds, // span
113  TimePoint,
114  std::uint64_t>; // sequence number
115  PendingInfo pendingInfo_;
116  std::uint64_t u64PendingAbsoluteSlotIndex_;
117  PORManager porManager_;
118  Utils::RandomNumberDistribution<std::mt19937,
119  std::uniform_real_distribution<float>> distribution_;
120 
121  bool bPromiscuousMode_;
122  std::chrono::seconds fragmentCheckThreshold_;
123  std::chrono::seconds fragmentTimeoutThreshold_;
124 
125  using FragmentKey = std::tuple<NEMId,Priority,std::uint64_t>;
126  using FragmentParts = std::map<size_t,std::vector<std::uint8_t>>;
127  using FragmentInfo = std::tuple<std::set<size_t>,
128  FragmentParts,
129  TimePoint, // last fragment time
130  NEMId, // destination
131  Priority>;
132  using FragmentStore = std::map<FragmentKey,FragmentInfo>;
133  using FragmentTimeStore = std::map<TimePoint,FragmentKey>;
134 
135  FragmentStore fragmentStore_;
136  FragmentTimeStore fragmentTimeStore_;
137  TimePoint lastFragmentCheckTime_;
138 
139  ReceiveManager(const ReceiveManager &) = delete;
140 
141  ReceiveManager & operator=(const ReceiveManager &) = delete;
142  };
143  }
144  }
145 }
146 
147 #endif // EMANEMODELSTDMARECEIVEMANAGER_HEADER_
void process(std::uint64_t u64AbsoluteSlotIndex)
Message class used to serialize and deserialize TDMA radio model messages.
POR Manager responsible for loading PCR curves from file and determining POR.
Definition: pormanager.h:56
std::uint8_t Priority
Definition: types.h:64
Store source, destination, creation time and priority information for a packet.
Definition: packetinfo.h:50
Log service provider interface.
void setFragmentTimeoutThreshold(const std::chrono::seconds &threshold)
ReceiveManager(NEMId id, DownstreamTransport *pDownstreamTransport, LogServiceProvider *pLogService, RadioServiceProvider *pRadioService, Scheduler *pScheduler, PacketStatusPublisher *pPacketStatusPublisher, NeighborMetricManager *pNeighborMetricManager)
std::chrono::microseconds Microseconds
Definition: types.h:45
void loadCurves(const std::string &sPCRFileName)
std::uint16_t NEMId
Definition: types.h:52
The RadioServiceProvider interface provides access to radio (RF) model specific services.
Scheduler interface used by BaseModel to communicate with a scheduler module.
Definition: scheduler.h:56
void setFragmentCheckThreshold(const std::chrono::seconds &threshold)
std::list< FrequencySegment > FrequencySegments
Manages all receive side message processing.
Packet status interface used to publish statistics and tables showing accepted and rejected byte coun...
Clock::time_point TimePoint
Definition: types.h:50
DownstreamTransport allows for processing downstream data and control messages.
Definition: agent.h:43
bool enqueue(BaseModelMessage &&baseModelMessage, const PacketInfo &pktInfo, size_t length, const TimePoint &startOfReception, const FrequencySegments &frequencySegments, const Microseconds &span, const TimePoint &beginTime, std::uint64_t u64PacketSequence)
A utility wrapper around a generator and a distribution.
Manages neighbor metrics and sends neighbor metric control message upstream.