EMANE  1.2.1
receivemanager.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2015,2017-2018 - Adjacent Link LLC, Bridgewater,
3  * New Jersey
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 Adjacent Link 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 #ifndef EMANEMODELSTDMARECEIVEMANAGER_HEADER_
35 #define EMANEMODELSTDMARECEIVEMANAGER_HEADER_
36 
37 #include "emane/types.h"
38 #include "emane/upstreampacket.h"
42 #include "emane/frequencysegment.h"
46 
47 #include "pormanager.h"
48 #include "basemodelmessage.h"
50 
51 #include <tuple>
52 
53 namespace EMANE
54 {
55  namespace Models
56  {
57  namespace TDMA
58  {
70  {
71  public:
73  DownstreamTransport * pDownstreamTransport,
74  LogServiceProvider * pLogService,
75  RadioServiceProvider * pRadioService,
76  Scheduler * pScheduler,
77  PacketStatusPublisher * pPacketStatusPublisher,
78  NeighborMetricManager *pNeighborMetricManager);
79 
80  void setFragmentCheckThreshold(const std::chrono::seconds & threshold);
81 
82  void setFragmentTimeoutThreshold(const std::chrono::seconds & threshold);
83 
84  void setPromiscuousMode(bool bEnable);
85 
86  void loadCurves(const std::string & sPCRFileName);
87 
88  bool enqueue(BaseModelMessage && baseModelMessage,
89  const PacketInfo & pktInfo,
90  size_t length,
91  const TimePoint & startOfReception,
92  const FrequencySegments & frequencySegments,
93  const Microseconds & span,
94  const TimePoint & beginTime,
95  std::uint64_t u64PacketSequence);
96 
97  void process(std::uint64_t u64AbsoluteSlotIndex);
98 
99  private:
100  NEMId id_;
101  DownstreamTransport * pDownstreamTransport_;
102  LogServiceProvider * pLogService_;
103  RadioServiceProvider * pRadioService_;
104  Scheduler * pScheduler_;
105  PacketStatusPublisher * pPacketStatusPublisher_;
106  NeighborMetricManager * pNeighborMetricManager_;
107 
108  using PendingInfo = std::tuple<BaseModelMessage,
109  PacketInfo,
110  size_t,
111  TimePoint, //sor
113  Microseconds, // span
114  TimePoint,
115  std::uint64_t>; // sequence number
116  PendingInfo pendingInfo_;
117  std::uint64_t u64PendingAbsoluteSlotIndex_;
118  PORManager porManager_;
119  Utils::RandomNumberDistribution<std::mt19937,
120  std::uniform_real_distribution<float>> distribution_;
121 
122  bool bPromiscuousMode_;
123  std::chrono::seconds fragmentCheckThreshold_;
124  std::chrono::seconds fragmentTimeoutThreshold_;
125 
126  using FragmentKey = std::tuple<NEMId,Priority,std::uint64_t>;
127  using FragmentParts = std::map<size_t,std::vector<std::uint8_t>>;
128  using FragmentInfo = std::tuple<std::set<size_t>,
129  FragmentParts,
130  TimePoint, // last fragment time
131  NEMId, // destination
132  Priority,
133  size_t>; // total number of fragments
134  using FragmentStore = std::map<FragmentKey,FragmentInfo>;
135 
136  FragmentStore fragmentStore_;
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.