MeshProtocolSimulator  1.0.0
Emulator_helpers.h
Go to the documentation of this file.
1 
18 #pragma once
19 
20 #include "meshNetGateway.h"
21 #include "Simulation_interface.h"
22 #include <deque>
23 #include <vector>
24 #include <thread>
25 #include <mutex>
26 #include <condition_variable>
27 #include <list>
28 
33 typedef enum {
34  TT_RTable = 0,
35  TT_IDTable,
36  TT_OIDTable,
37  TT_FIDTable,
38  TT_DHCPTable,
39  TT_WaitingFIFO,
40  TT_OutFIFO
41 } TableType;
42 
48  NodeConnections() = default;
49 
50  NodeConnections(MeshMAC node1, MeshMAC node2) {
51  Node1 = node1;
52  Node2 = node2;
53  }
54 
55  NodeConnections(MeshMAC node1, MeshMAC node2, float rssi, float rssi_tolerance, float quality) {
56  Node1 = node1;
57  Node2 = node2;
58  RSSI = rssi;
59  RSSI_tolerance = rssi_tolerance;
60  Quality = quality;
61  }
62 
66  MeshMAC Node1 = 0;
67 
71  MeshMAC Node2 = 0;
72 
76  float RSSI = 0.00f;
77 
83  float RSSI_tolerance = 0.00f;
84 
88  float getRSSI() const;
89 
94  float Quality = 1.00f;
95 
99  bool canReceive() const;
100 };
101 
102 struct NeighborNode {
103 
104  NeighborNode(NodeSimulator* neighbor, const NodeConnections* link) {
105  Neighbor = neighbor;
106  Link = link;
107  }
108 
113 
118 };
119 
124 struct NodeSettings {
125  /*
126  * @brief MAC address of node.
127  */
128  MeshMAC MACAddress = 0;
129 
130  /*
131  * @brief True when node is gateway
132  */
133  bool isGateway = false;
134 
135  /*
136  * @brief Network SSID. This can be set only when node is marked as gateway
137  */
138  std::string SSID = "";
139 
143  std::chrono::nanoseconds simulationOffset = std::chrono::nanoseconds::zero();
144 
148  uint32_t MCUFrequency = 16000000UL;
149 
153  uint32_t preSendCyclesDelay = 50;
154 
158  std::chrono::nanoseconds preSendDelay = std::chrono::nanoseconds(13000);
159 
163  uint32_t sendingSpeed = 1000000UL;
164 
168  uint32_t extraBitsSentCount = 6 * 8; //Preamble 1 byte, dummy address 3 bytes, CRC 2 bytes
169 
173  uint32_t postSendCyclesDelay = 50;
174 
178  std::chrono::nanoseconds postSendDelay = std::chrono::nanoseconds(13000);
179 
183  uint32_t preReceiveCyclesDelay = 10;
184 
188  std::chrono::nanoseconds preReceiveDelay = std::chrono::nanoseconds(5000);
189 
193  uint32_t postReceiveCyclesDelay = 10;
194 
198  std::chrono::nanoseconds postReceiveDelay = std::chrono::nanoseconds(5000);
199 
203  uint32_t availableCyclesDelay = 10;
204 
208  std::chrono::nanoseconds availableDelay = std::chrono::nanoseconds(5000);
209 
214 
218  std::chrono::nanoseconds interferenceCheckDelay = std::chrono::nanoseconds(5000);
219 
223  uint8_t maxFrameSize = 32;
224 
228  int InputFiFoSize = 3;
229 
233  void clear() {
234  isGateway = false;
235  SSID = "";
236  simulationOffset = std::chrono::nanoseconds::zero();
237  MCUFrequency = 16000000UL;
238  preSendCyclesDelay = 50;
239  preSendDelay = std::chrono::nanoseconds(13000);
240  sendingSpeed = 1000000UL;
241  extraBitsSentCount = 6 * 8;
242  postSendCyclesDelay = 50;
243  postSendDelay = std::chrono::nanoseconds(13000);
245  preReceiveDelay = std::chrono::nanoseconds(5000);
247  postReceiveDelay = std::chrono::nanoseconds(5000);
249  std::chrono::nanoseconds(5000);
251  interferenceCheckDelay = std::chrono::nanoseconds(5000);
252  maxFrameSize = 32;
253  InputFiFoSize = 3;
254  MACAddress = 0;
255  }
256 };
257 
262 struct RawMessage {
263 public:
264 
265  RawMessage() = default;
266 
267  RawMessage(uint8_t* message, uint8_t messageLength, std::chrono::nanoseconds _sentTime, std::chrono::nanoseconds _sendingDoneTime);
268 
276  void Set(uint8_t* message, uint8_t messageLength, std::chrono::nanoseconds _sentTime, std::chrono::nanoseconds _sendingDoneTime);
277 
283  void Get(uint8_t* message, uint8_t& messageLength) const;
284 
288  void Clear();
289 
294  inline std::chrono::nanoseconds SentTime() const{
295  return sentTime;
296  }
297 
302  inline std::chrono::nanoseconds ReceiveTime() const {
303  return receiveTime;
304  }
305 
310  inline uint32_t Length() const {
311  return length;
312  }
313 
318  inline uint64_t GetUniqueIdentifier() const {
319  return uniqueIdentifier;
320  }
321 
327  inline bool IsTransacting(std::chrono::nanoseconds currentSimulationTime) const {
328  return currentSimulationTime < ReceiveTime() && sentTime >= currentSimulationTime && !(sentTime == std::chrono::nanoseconds::zero() || receiveTime == std::chrono::nanoseconds::zero());
329  }
330 
336  bool IsInterfering(RawMessage& anotherMessage) const;
337 
341  bool IsInterfered = false;
342 
346  MeshMAC SenderNodeMACAddress = 0;
347 
348  static void printFrameCompressed(uint64_t uniqueID, MeshFrame& msg);
349 
360  std::string ConvertToBase64();
361 
362 protected:
363  uint8_t payload[MESH_FRAME_SIZE_LIMIT];
364  uint8_t length = 0;
365  std::chrono::nanoseconds sentTime = std::chrono::nanoseconds::zero();
366  std::chrono::nanoseconds receiveTime = std::chrono::nanoseconds::zero();
367 
368  uint64_t uniqueIdentifier = 0;
369  static uint64_t globalUniqueIdentifier;
370 };
371 
381 
382  RawMessageDescriptor() = default;
383 
384  RawMessageDescriptor(std::shared_ptr<RawMessage>& msg_ptr) {
385  Message = msg_ptr;
386  }
387 
391  bool IsInterfered = false;
392 
396  float RSSI = 0.00;
397 
401  bool BadQuality = false;
402 
411  std::shared_ptr<RawMessage> Message;
412 };
413 
414 class Emulator;
415 
421 public:
422 
427 
434  NodeSimulator(Emulator* emulator, int index, MeshMAC nodeMACAddress);
435 
441  NodeSimulator(Emulator* emulator, int index);
442 
443  NodeSimulator(const NodeSimulator&) = default;
444 
448  ~NodeSimulator();
449 
450  NodeSimulator& operator=(const NodeSimulator&) = default;
451 
452  std::thread Thread;
453  std::mutex Mutex;
454 
458  std::function<void(void)> Interrupt = NULL;
459 
463  inline MeshNet* Node() {
464  return currentNode;
465  }
466 
470  inline Emulator* getParentPtr() {
471  return em;
472  }
473 
477  inline int getIndex() {
478  return index;
479  }
480 
484  inline uint64_t getCyclesCount() {
485  return numberOfCycles;
486  }
487 
491  void ExecuteCycle();
492 
500  inline bool BeginSimulation(NodeSettings settings_, std::chrono::nanoseconds simulationTimeOffset = std::chrono::nanoseconds::zero()) {
501  settings = settings_;
502  return BeginSimulation(simulationTimeOffset);
503  }
504 
512  bool BeginSimulation(std::chrono::nanoseconds simulationTimeOffset = std::chrono::nanoseconds::zero());
513 
517  void EndSimulation();
518 
523  void SleepFor(std::chrono::nanoseconds sleepDelay);
524 
529  inline bool IsSimulationRunning() {
530  return IsSimulationEnabled() && !CycleLock;
531  }
532 
537  inline bool IsSimulationEnabled() {
538  return simulationStarted;
539  }
540 
545  std::chrono::nanoseconds getSimulationTime();
546 
551  inline std::chrono::nanoseconds getNodeWorkTime() {
553  }
554 
559  inline std::chrono::nanoseconds getLastSentTime() {
560  return lastSentTime;
561  }
562 
566  inline const std::vector<NeighborNode>& GetNeighborNodes() {
567  return neighborNodes;
568  }
569 
574  return settings;
575  }
576 
577 protected:
578 
579  //Methods called by Emulator --- BEGIN
580 
587  bool IsFree(std::chrono::nanoseconds time);
588 
595  bool IsFreeEx(std::chrono::nanoseconds time);
596 
603  uint8_t Available();
604 
608  inline uint16_t GetLastAvailableBytes() {
609  return lastAvailableBytes;
610  }
611 
620  bool Receive(uint8_t* message, uint8_t& messageLength, float& RSSI);
621 
629  void Send(uint8_t* message, uint8_t messageLength);
630 
636  void OnScanResponse(const MeshNetScanResult& result);
637 
638  //TODO
639  void CreateRandomInterference(std::chrono::microseconds interferingDuration);
640 
644  void PauseSimulationTimer();
645 
649  void ResumeSimulationTimer();
650 
651  //Methods called by Emulator -- END
652 
653 
658 
662  Emulator* em = NULL;
663 
667  int index = 0;
668 
672  uint64_t numberOfCycles = 0;
673 
677  std::vector<NeighborNode> neighborNodes;
678 
679  std::chrono::nanoseconds FreeFromTime = std::chrono::nanoseconds::zero();
680  std::chrono::nanoseconds FreeSenderFromTime = std::chrono::nanoseconds::zero();
681 
685  std::deque<RawMessageDescriptor> inputFIFO;
686 
690  std::list<RawMessageDescriptor> receivedMessagesList;
691 
695  uint64_t lastCycles = 0;
696 
700  std::chrono::nanoseconds simulationTime = std::chrono::nanoseconds::zero();
701 
705  std::chrono::nanoseconds lastSentTime = std::chrono::nanoseconds::zero();
706 
710  std::chrono::nanoseconds simulationOffset = std::chrono::nanoseconds::zero();
711 
715  std::atomic<bool> CycleLock{ true };
716 
720  std::condition_variable_any CycleLockCV;
721 
725  bool simulationStarted = false;
726 
731 
737 
741  MeshNet* currentNode = NULL;
742 
746  Simulation_RFI* currentRFI = NULL;
747 
752  int CheckForSentMessages();
753 
769 
783 
789  void ReportMessageLost(RawMessageDescriptor& msg, MeshMAC receiverNode);
790 
794  static void OnNodeConnectedStatic(MeshNet* mesh);
795 
800  void OnNodeConnected();
801 
805  static void OnNodeDisconnectedStatic(MeshNet* mesh, MeshDisconnectReason reason, MeshMAC oldBSSID, uint8_t oldAddress);
806 
814  void OnNodeDisconnected(MeshDisconnectReason reason, MeshMAC oldBSSID, uint8_t oldAddress);
815 
819  static void OnReceiveStatic(MeshNet* mesh, MeshPacket& packet);
820 
825  void OnReceive(MeshPacket& packet);
826 
830  static void OnPingRespStatic(MeshNet* mesh, uint8_t pingID, uint8_t pingAddr, MeshPacketError pingStat, uint8_t hops, uint32_t duration, const uint8_t* testData, int16_t testDataLength);
831 
842  void OnPingResp(uint8_t pingID, uint8_t pingAddr, MeshPacketError pingStat, uint8_t hops, uint32_t duration, const uint8_t* testData, int16_t testDataLength);
843 
844 
845  friend Emulator; //Friend class
846  friend Simulation_RFI; //Friend class
847 };
848 
849 
862 std::string ConvertToBase64(const MeshNetScanResult& result);
NodeSimulator::currentRFI
Simulation_RFI * currentRFI
Pointer to speficied RF interface.
Definition: Emulator_helpers.h:746
RawMessage::ReceiveTime
std::chrono::nanoseconds ReceiveTime() const
Gets time, when message will be available to receive.
Definition: Emulator_helpers.h:302
NodeSettings
Settings for each node in simulation. Those settings can be get from scenario file.
Definition: Emulator_helpers.h:124
NodeSimulator::simulationOffset
std::chrono::nanoseconds simulationOffset
Simulation start offset.
Definition: Emulator_helpers.h:710
NodeConnections::Node2
MeshMAC Node2
Second node.
Definition: Emulator_helpers.h:71
NodeSettings::MCUFrequency
uint32_t MCUFrequency
Simulation MCU frequency in Hz. Defaultly set to 16 MHz.
Definition: Emulator_helpers.h:148
NeighborNode::Link
const NodeConnections * Link
Pointer to nodes link connection.
Definition: Emulator_helpers.h:117
RawMessage::IsInterfering
bool IsInterfering(RawMessage &anotherMessage) const
Checks if two messages are interfering each other.
Definition: Emulator_helpers.cpp:338
NodeSettings::preReceiveDelay
std::chrono::nanoseconds preReceiveDelay
Delay before message is received in nanoseconds. Defaultly set to 5µs.
Definition: Emulator_helpers.h:188
NeighborNode
Definition: Emulator_helpers.h:102
NodeSimulator::CycleLockCV
std::condition_variable_any CycleLockCV
Conditional variable for cycle lock.
Definition: Emulator_helpers.h:720
RawMessageDescriptor
Class, that holds description of shared pointer to RawMessage instance. This is most effective way,...
Definition: Emulator_helpers.h:380
NodeSettings::availableDelay
std::chrono::nanoseconds availableDelay
Delay when checking message avaiability in nanoseconds. Defaultly set to 5µs.
Definition: Emulator_helpers.h:208
NodeSimulator::getSimulationTime
std::chrono::nanoseconds getSimulationTime()
Gets current node simulation time.
Definition: Emulator_helpers.cpp:913
NodeSimulator::OnNodeConnectedStatic
static void OnNodeConnectedStatic(MeshNet *mesh)
Static function, which can be used as callback. In this function correct OnNodeConnected() method is ...
Definition: Emulator_helpers.cpp:975
RawMessage::Get
void Get(uint8_t *message, uint8_t &messageLength) const
Gets bytes from message.
Definition: Emulator_helpers.cpp:322
NodeSimulator::PauseSimulationTimer
void PauseSimulationTimer()
Call this if cycle is going to be paused. It stops counting instructions done on current thread.
Definition: Emulator_helpers.cpp:953
NodeSimulator::IsSimulationRunning
bool IsSimulationRunning()
Checks if simulation is running for current node.
Definition: Emulator_helpers.h:529
NodeSettings::sendingSpeed
uint32_t sendingSpeed
Speed of send in bits per second. Defaultly set to 1 Mbps.
Definition: Emulator_helpers.h:163
NodeSettings::clear
void clear()
Clears settings.
Definition: Emulator_helpers.h:233
TableType
TableType
This enum represents type of table of buffer used in MeshNet.
Definition: Emulator_helpers.h:33
NodeSimulator
Structure, that runs simulation for one node in network and contains some info about that node.
Definition: Emulator_helpers.h:420
RawMessage::GetUniqueIdentifier
uint64_t GetUniqueIdentifier() const
Gets unique identifier of current message.
Definition: Emulator_helpers.h:318
RawMessage::IsInterfered
bool IsInterfered
True when message was interfered.
Definition: Emulator_helpers.h:341
NodeSettings::preSendCyclesDelay
uint32_t preSendCyclesDelay
Delay before message sending in cycles. Defaultly set to 50.
Definition: Emulator_helpers.h:153
NeighborNode::Neighbor
NodeSimulator * Neighbor
Pointer to neighbor node simulator.
Definition: Emulator_helpers.h:112
NodeSimulator::inputFIFO
std::deque< RawMessageDescriptor > inputFIFO
FIFO, that acts as FIFO on receiver module.
Definition: Emulator_helpers.h:685
NodeSettings::InputFiFoSize
int InputFiFoSize
Size of input FiFo on specified radio. Defaultly set to 3.
Definition: Emulator_helpers.h:228
NodeSimulator::BeginSimulation
bool BeginSimulation(NodeSettings settings_, std::chrono::nanoseconds simulationTimeOffset=std::chrono::nanoseconds::zero())
Turns on simulation for current node.
Definition: Emulator_helpers.h:500
NodeConnections::canReceive
bool canReceive() const
Returns true if sent frame has to be received and false if not. Decision is made by Quality value.
Definition: Emulator_helpers.cpp:33
RawMessageDescriptor::RSSI
float RSSI
RSSI value of received message.
Definition: Emulator_helpers.h:396
NodeSettings::postReceiveCyclesDelay
uint32_t postReceiveCyclesDelay
Delay after message is received in cycles. Defaultly set to 10.
Definition: Emulator_helpers.h:193
NodeSimulator::lastAvailableBytes
int lastAvailableBytes
Count of bytes, that was returned last time by Available() method.
Definition: Emulator_helpers.h:730
NodeSettings::postSendCyclesDelay
uint32_t postSendCyclesDelay
Delay after message sending in cycles. Defaultly set to 50.
Definition: Emulator_helpers.h:173
NodeSimulator::~NodeSimulator
~NodeSimulator()
Destructor.
Definition: Emulator_helpers.cpp:360
NodeSettings::availableCyclesDelay
uint32_t availableCyclesDelay
Delay when checking message avaiability in cycles. Defaultly set to 10.
Definition: Emulator_helpers.h:203
NodeSimulator::settings
NodeSettings settings
Node settings.
Definition: Emulator_helpers.h:657
NodeSimulator::IsSimulationEnabled
bool IsSimulationEnabled()
Checks if simulation has been started, but it does not mean it is currently running.
Definition: Emulator_helpers.h:537
NodeSimulator::ReportCollision
void ReportCollision(RawMessageDescriptor &msg, RawMessage &msg2)
Reports half-duplex collision of message, which was received during sending.
Definition: Emulator_helpers.cpp:843
NodeSimulator::lastCycles
uint64_t lastCycles
Last count of processor cycles, which are used to calculate properly timing of simulation.
Definition: Emulator_helpers.h:695
NodeSimulator::getNodeWorkTime
std::chrono::nanoseconds getNodeWorkTime()
Gets work time of current node.
Definition: Emulator_helpers.h:551
NodeSimulator::Available
uint8_t Available()
Checks how many bytes are available to receive.
Definition: Emulator_helpers.cpp:548
ConvertToBase64
std::string ConvertToBase64(const MeshNetScanResult &result)
Converts MeshNetScanResult to Base64. Structure of data is:
Definition: Emulator_helpers.cpp:1075
NodeConnections::getRSSI
float getRSSI() const
Gets RSSI from specified range, see RSSI and RSSI_tolerance.
Definition: Emulator_helpers.cpp:7
NodeConnections::RSSI
float RSSI
RSSI of current link connection in dBm. This value has to be negative and in range from 0dBm to -120d...
Definition: Emulator_helpers.h:76
NodeSettings::preReceiveCyclesDelay
uint32_t preReceiveCyclesDelay
Delay before message is received in cycles. Defaultly set to 10.
Definition: Emulator_helpers.h:183
NodeSimulator::OnReceiveStatic
static void OnReceiveStatic(MeshNet *mesh, MeshPacket &packet)
Static function, which can be used as callback. In this function correct OnReceive() method is called...
Definition: Emulator_helpers.cpp:1001
NodeSimulator::ExecuteCycle
void ExecuteCycle()
Executes current node's one cycle.
Definition: Emulator_helpers.cpp:485
RawMessage::SentTime
std::chrono::nanoseconds SentTime() const
Gets time, when message was sent.
Definition: Emulator_helpers.h:294
NodeSimulator::simulationTimerPaused
bool simulationTimerPaused
True if current simulation timer is running (ResumeSimulationTimer() was called) and false if simulat...
Definition: Emulator_helpers.h:736
NodeConnections::RSSI_tolerance
float RSSI_tolerance
Absolute value, that can be added or subtracted from RSSI during simulation. When set to 0,...
Definition: Emulator_helpers.h:83
NodeSimulator::OnReceive
void OnReceive(MeshPacket &packet)
This method is called when node has received data packet.
Definition: Emulator_helpers.cpp:1006
NodeSimulator::GetSettings
NodeSettings GetSettings()
Gets node settings.
Definition: Emulator_helpers.h:573
RawMessage::ConvertToBase64
std::string ConvertToBase64()
Converts raw message to Base64. Structure of data is:
Definition: Emulator_helpers.cpp:249
NodeSettings::postReceiveDelay
std::chrono::nanoseconds postReceiveDelay
Delay after message is received in nanoseconds. Defaultly set to 5µs.
Definition: Emulator_helpers.h:198
NodeSimulator::lastSentTime
std::chrono::nanoseconds lastSentTime
Simulation time, when last message was sent.
Definition: Emulator_helpers.h:705
RawMessage::SenderNodeMACAddress
MeshMAC SenderNodeMACAddress
MAC address of current message sender.
Definition: Emulator_helpers.h:346
RawMessage
This structure represents raw message, that was sent between two virtual radios. It has no header and...
Definition: Emulator_helpers.h:262
RawMessageDescriptor::IsInterfered
bool IsInterfered
True if message was interfered yet.
Definition: Emulator_helpers.h:391
Emulator
This class emulates virtual wireless environment for MeshNet nodes (MNodes) with virtual radios....
Definition: Emulator.h:26
NodeSimulator::Node
MeshNet * Node()
Gets pointer to node, which is simulated by current NodeSimulator.
Definition: Emulator_helpers.h:463
NodeSimulator::getParentPtr
Emulator * getParentPtr()
Gets pointer to emulator, which owns this instance.
Definition: Emulator_helpers.h:470
NodeSimulator::EndSimulation
void EndSimulation()
Turns off simulation for current node.
Definition: Emulator_helpers.cpp:457
NodeSimulator::CheckForSentMessages
int CheckForSentMessages()
Checks received messages, puts them in FIFO and clears FIFO from interference and overflow messages.
Definition: Emulator_helpers.cpp:504
NodeSimulator::ResumeSimulationTimer
void ResumeSimulationTimer()
Call this if cycle is going to be resumed. It restarts counting instructions done on current thread.
Definition: Emulator_helpers.cpp:965
NodeSimulator::OnNodeDisconnected
void OnNodeDisconnected(MeshDisconnectReason reason, MeshMAC oldBSSID, uint8_t oldAddress)
This method is called when node is disconnected from any network.
Definition: Emulator_helpers.cpp:992
NodeSimulator::getLastSentTime
std::chrono::nanoseconds getLastSentTime()
Gets simulation time, when last sent occoured.
Definition: Emulator_helpers.h:559
NodeSimulator::getIndex
int getIndex()
Gets index of node in emulator array of nodes.
Definition: Emulator_helpers.h:477
NodeSimulator::Send
void Send(uint8_t *message, uint8_t messageLength)
Sends data to the environment.
Definition: Emulator_helpers.cpp:618
NodeSimulator::OnScanResponse
void OnScanResponse(const MeshNetScanResult &result)
This method is called on every scan response by node.
Definition: Emulator_helpers.cpp:779
NodeSettings::simulationOffset
std::chrono::nanoseconds simulationOffset
Simulation start offset.
Definition: Emulator_helpers.h:143
NodeSimulator::getCyclesCount
uint64_t getCyclesCount()
Gets count of cycles, that were done in infinity loop, where is MeshNet code executed.
Definition: Emulator_helpers.h:484
NodeSimulator::Interrupt
std::function< void(void)> Interrupt
Function done at interrupt.
Definition: Emulator_helpers.h:458
NodeSimulator::index
int index
Index of node in emulator array of nodes.
Definition: Emulator_helpers.h:667
RawMessage::Clear
void Clear()
Clears data stored in message.
Definition: Emulator_helpers.cpp:329
NodeSimulator::NodeSimulator
NodeSimulator()
Constructor.
Definition: Emulator_helpers.h:426
NodeSimulator::simulationTime
std::chrono::nanoseconds simulationTime
Simulation time elapsed in nanoseconds.
Definition: Emulator_helpers.h:700
NodeSimulator::CycleLock
std::atomic< bool > CycleLock
True when current cycle is locked. Cycle can be executed only when it is unlocked.
Definition: Emulator_helpers.h:715
RawMessage::Set
void Set(uint8_t *message, uint8_t messageLength, std::chrono::nanoseconds _sentTime, std::chrono::nanoseconds _sendingDoneTime)
Sets message bytes.
Definition: Emulator_helpers.cpp:308
NodeSettings::maxFrameSize
uint8_t maxFrameSize
Maximum size of frame, that can be sent. Value can be from 24 to 255.
Definition: Emulator_helpers.h:223
NodeConnections::Node1
MeshMAC Node1
First node.
Definition: Emulator_helpers.h:66
NodeSettings::interferenceCheckCyclesDelay
uint32_t interferenceCheckCyclesDelay
Delay when checking interference in cycles. Defaultly set to 10.
Definition: Emulator_helpers.h:213
NodeSimulator::OnNodeDisconnectedStatic
static void OnNodeDisconnectedStatic(MeshNet *mesh, MeshDisconnectReason reason, MeshMAC oldBSSID, uint8_t oldAddress)
Static function, which can be used as callback. In this function correct OnNodeDisconnected() method ...
Definition: Emulator_helpers.cpp:988
NodeSimulator::Receive
bool Receive(uint8_t *message, uint8_t &messageLength, float &RSSI)
Receives message when available.
Definition: Emulator_helpers.cpp:573
NodeSimulator::SleepFor
void SleepFor(std::chrono::nanoseconds sleepDelay)
Makes current node sleep for specified delay.
Definition: Emulator_helpers.cpp:901
NodeSimulator::GetLastAvailableBytes
uint16_t GetLastAvailableBytes()
Gets last available bytes in one frame from Available() method.
Definition: Emulator_helpers.h:608
NodeSimulator::OnNodeConnected
void OnNodeConnected()
This method is called when node is connected to new network.
Definition: Emulator_helpers.cpp:979
NodeSimulator::numberOfCycles
uint64_t numberOfCycles
Number of cycles done from start of the simulation.
Definition: Emulator_helpers.h:672
NodeSimulator::currentNode
MeshNet * currentNode
Pointer to speficied node.
Definition: Emulator_helpers.h:741
NodeSimulator::GetNeighborNodes
const std::vector< NeighborNode > & GetNeighborNodes()
Gets reference to vector, which has pointers to all neighbor nodes. This return valid value only when...
Definition: Emulator_helpers.h:566
NodeSimulator::OnPingRespStatic
static void OnPingRespStatic(MeshNet *mesh, uint8_t pingID, uint8_t pingAddr, MeshPacketError pingStat, uint8_t hops, uint32_t duration, const uint8_t *testData, int16_t testDataLength)
Static function, which can be used as callback. In this function correct OnPingResp() method is calle...
Definition: Emulator_helpers.cpp:1028
NodeConnections
This structure represents link connection between two nodes. Nodes are indentified by it's MeshMAC ad...
Definition: Emulator_helpers.h:47
NodeSettings::preSendDelay
std::chrono::nanoseconds preSendDelay
Delay before message sending in nanoseconds. Defaultly set to 13µs.
Definition: Emulator_helpers.h:158
RawMessage::Length
uint32_t Length() const
Gets length of stored message in bytes.
Definition: Emulator_helpers.h:310
NodeConnections::Quality
float Quality
Link quality, represented as probability, that sent packet through this link will be received....
Definition: Emulator_helpers.h:94
NodeSimulator::em
Emulator * em
Pointer to emulator, which owns this instance.
Definition: Emulator_helpers.h:662
NodeSettings::postSendDelay
std::chrono::nanoseconds postSendDelay
Delay after message sending in nanoseconds. Defaultly set to 13µs.
Definition: Emulator_helpers.h:178
NodeSimulator::simulationStarted
bool simulationStarted
True if BeginSimulation() was called.
Definition: Emulator_helpers.h:725
NodeSimulator::IsFreeEx
bool IsFreeEx(std::chrono::nanoseconds time)
Check if node is not receiving at current simulation time. Use this from outside of simulation.
Definition: Emulator_helpers.cpp:936
NodeSettings::interferenceCheckDelay
std::chrono::nanoseconds interferenceCheckDelay
Delay when checking interference in nanoseconds. Defaultly set to 5µs.
Definition: Emulator_helpers.h:218
NodeSimulator::neighborNodes
std::vector< NeighborNode > neighborNodes
Vector with pointers to all neighbor nodes.
Definition: Emulator_helpers.h:677
NodeSimulator::ReportMessageLost
void ReportMessageLost(RawMessageDescriptor &msg, MeshMAC receiverNode)
Reports, that sent message was lost due to bad link quality.
Definition: Emulator_helpers.cpp:871
NodeSimulator::IsFree
bool IsFree(std::chrono::nanoseconds time)
Check if node is not receiving at current simulation time. Use this from inside in simulation.
Definition: Emulator_helpers.cpp:930
RawMessageDescriptor::Message
std::shared_ptr< RawMessage > Message
Shared pointer to sent message. This acts as pointer to sent message. It is used to prevent copying s...
Definition: Emulator_helpers.h:411
NodeSimulator::OnPingResp
void OnPingResp(uint8_t pingID, uint8_t pingAddr, MeshPacketError pingStat, uint8_t hops, uint32_t duration, const uint8_t *testData, int16_t testDataLength)
This method is called when ping response is received.
Definition: Emulator_helpers.cpp:1032
NodeSimulator::receivedMessagesList
std::list< RawMessageDescriptor > receivedMessagesList
List of received messages, that was not processed yet.
Definition: Emulator_helpers.h:690
RawMessageDescriptor::BadQuality
bool BadQuality
True if message cannot be read due to bad quality.
Definition: Emulator_helpers.h:401
RawMessage::IsTransacting
bool IsTransacting(std::chrono::nanoseconds currentSimulationTime) const
Checks if message is transacting right now.
Definition: Emulator_helpers.h:327
NodeSimulator::ReportInterference
void ReportInterference(RawMessageDescriptor &msg1, RawMessageDescriptor &msg2, MeshMAC currentNode)
Reports Hidden terminal interference of two messages.
Definition: Emulator_helpers.cpp:810
NodeSettings::extraBitsSentCount
uint32_t extraBitsSentCount
Count of extra bits sent with message (preamble, CRC, ...)
Definition: Emulator_helpers.h:168