MeshProtocolSimulator
1.0.0
|
MeshProtocolSimulator is console application programmed in C++ which can emulate virtual wireless environment for MeshNet protocol. The simulation can detect interference between nodes and interfered frame won't be received by nodes. Environmental noise or link quality cannot be simulated right now, but we want to implement it. The simulation can be controlled by commands or by scenario file. Simulation process can be recorded to log file, which can be later analyzed.
Emulator
class controlls whole simulation. This class allows interventions in the simulation or can invoke functions like: send, receive, connect, disconnect, ping, network scan, etc. Network topology is also specified in this class thanks to array of NodeConnections
structures, which defines link between two nodes. Network topology can be default or can be specified in scenario file. Default topology looks like this: MeshMAC
addresses and node 1 is gateway. This class also controlls timing of the simulation for each node. Although each NodeSimulator instance has its own thread, only the code of one node can be processed at a time. This is because code for all nodes in virtual network has to be done simultaneously for proper timing, but CPUs has only limited count of cores, which can also process threads of another applications. We solved this by executing the code of only one node that is far behind in the simulation. Code execution is paused when a node sends or receives a frame or tries to determine the number of received frames by calling available()
function or one cycle from infinity loop on a node was done.NodeSimulator
class handles simulation of one Node. It also describes the node behavior with structure NodeSettings
. This class also handles frames sending and receiving. Those frames are sent as RawMessage
. It also checks if interference happened. There are two types of interferences which may occur:RawMessage
structure represents raw message, that was sent between two virtual radios. It has no header and data are not structured.Simulation_RFI
class is interface, which behaves as real radio, which is described by NodeSettings
.Simulation contol can be dividen into 4 phases:
-a
or --autopause
- If set, auto pause is enabled. Simulation will be auto paused after one second of inactivity. Simulation is also paused at the beginning of simulation.-o
or --logonly
- Can be used only if log file path is specified. Simulation logs are not showed to screen but are written only to specified log file.-r
or --raw
- Output showed on screen will be in raw form. This is recommended to use, when output is redirected to some application, which controls simulation.-s
- After this switch scenario file path must be specified.-l
- After this switch log file path must be specified.-h
or --help
shows help.-v
or --version
shows version.auto pause <enabled/disabled:enable>
which enables or disables auto pause after one second of inactivity. For example: "`auto pause enabled`".begin
runs simulation, see third phase.end
exits simulation.help
shows help.resume
- Resumes simulation.resume for <ulong:time>
- Resumes simulation for specified simulation time in nanoseconds.pause
- Pauses simulation.auto pause <enabled/disabled:enable>
which enables or disables auto pause after one second of inactivity.ping <uint:source> <uint:destination> <uint:timeout[1000, 127500]> <uint:load[0, 500]>
- Pings specified node with "destination" MAC address from module with "source" MAC address.send <uint:from> <uint:to> <message>
- Invokes message send from node with "from" MAC address to module with MAC "to" address.net scan <uint:node> <uint:timeout[500,10000]>
- Invokes network scan on node with "node" MAC address with "timeout" in ms.connect <uint:from> <uint:to>
- Invokes connection of node with MAC address "from" to node with MAC address "to".disconnect <uint:from>
- Invokes node disconnection with MAC address "from".disconnect request <uint:gateway> <uint:node>
- Invokes disconnection of "node" by "gateway" node.network drop <uint:gateway> <-f:forced drop>
- Invokes network drop by "gateway" node.print table <uint:node> <rt/idt/fidt/oidt/dhcpt/wf/of:table_type>
- Prints out table or buffer of type "table_type" of node with MAC address "node". For example: print table 1 rt
.end
- Turns off simulation and exits application. This must be called before closing simulation to correctly save log file.help
- Shows help.doxygen.exe
in console in folder to generate documentation. Open file in html/index.htmlCopyright 2022 Matej Fitoš
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Created by Matej Fitoš
Copyright © 2022 Matej Fitoš