Wireless Network Simulator

Go To Last Post
14 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

For the past few weeks I've been working on a very interesting project. This is a free and open source wireless network simulator called NetSim.

Here is a short description of what NetSim is:

NetSim is a wireless network simulator. NetSim is primarily designed for use by developers of the network stacks. It can also be used for initial design, development and debugging of the final applications, but its use in this capacity may be limited because of the way simulated peripherals are designed.

Simulated devices implement a wireless system on a chip (SoC) based on an ARMv6-M-compatible MCU (Cortex-M0) and an abstract IEEE 802.15.4 radio transceiver. By default simulated system runs at 1 MHz, which is usually fast enough for a networking stack and a simple application.

More detailed description and a source code is available at GitHub.

I've made NetSim so that I could test things like routing algorithms in a reproducible environment without having a ton of hardware and constant reprogramming.

I don't expect that too many people will want to use it, but may be someone will find it useful.

I've prepared an easy to use package for evaluation (attached). Note that from this point on everything is command line only, so be prepared and you've been warned :)

In the package you will find:
1. LwMesh_Sim - patch for LwMesh v1.2.1 that adds NetSim radio support. Just extract this archive on top of LwMesh.
2. sniffer - sniffer log viewer. It is based on my old project of a sniffer written in Python. Simply run "python sniffer.py" to get it working.
3. netsim - precompiled Linux version (x64 only).
4. netsim.exe - precompiled Windows version.
5. PingPong.bin - binary firmware image compiled from LwMesh_Sim/apps/PingPong.
6. PingPong_4x4.cfg - network configuration file for the simulator.

In PingPong application, node 0 randomly selects a destination address and sends a frame to that address. Receiving node selects a new address, and process goes on like this.
Destination address is selected from a predefined range, which is configurable from the config.h file.

PingPong_4x4.cfg configures a network of 16 nodes located in a 4x4 grid 20 meters apart.

To start simulation simply run "netsim.exe PingPong_4x4.cfg".

On my system 4x4 simulation runs 2.9 (or 3.3 depending on the core model) times faster than real time.

The same application, but in 10x10 configuration runs 2.9 (or 2.3) times slower than real time. So real time is somewhere in between :)

After playing with this simulator for a while, I've already observed a few things that might be improved, especially for big networks. Now it is time to do something about that.

Attachment(s): 

NOTE: I no longer actively read this forum. Please ask your question on www.eevblog.com/forum if you want my answer.

Last Edited: Fri. Oct 16, 2015 - 12:37 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Also, if you will actually try to run yourself, I'd really like to know configuration of your system (mostly type and frequency of the CPU) and time it took to finish standard simulation. Time is printed at the end of simulation.

NOTE: I no longer actively read this forum. Please ask your question on www.eevblog.com/forum if you want my answer.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi Alexru,

 

 I was googling a lot for a Linux based 15.4 (Zigbee) simulator.   Thank you very much for your simulator. 

I have also watched your youtube videos on Lightweight Mesh software from Atmel.

 

I have few questions on simulator.

 

My activity is to change Network frame (Atmel's LwMesh code) and test on to the target board (any Atmel evolution/Development boards).

Since my changes are involved in Network layers, it requires to test with multiple network nodes in a mesh network.  That means I need to have multiple boards to work with.

 

This triggered me to search Simulated environment on a Linux/Windows PC where development can be fast.  Fortunately I found your NetSim.  After spending some time  I realized that this works on both platforms (I ran it on Linux).   

 

Can you please kindly spend some time in clarifying my below doubts. This will help me in saving lot of time.

 

-  Will I be able to test my changes LwMesh on NetSim?

-  Do I need to port NetSim to test my changes?

-  How do I validate my changes?

-  How close the results of NetSim with Real time results?

-  What is the best way to test my changes (Network Layer) in LwMesh?  How many boards Do I need?

 

regards

Bhagavan

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

bhagavansprasad wrote:
-  Will I be able to test my changes LwMesh on NetSim?

 

In theory, yes. I don't know how practical it would be. Unless you are doing something tricky (like new routing algorithm, or something similar), in most cases it is faster to use the real hardware. In the end you will have to verify your results on the hardware anyway.

 

bhagavansprasad wrote:
-  Do I need to port NetSim to test my changes?

 

You don't need to do anything to the NetSim itself, but you will heed to port low-level stack levels to the virtual MCU. I'm attaching all the necessary support files and example application.

 

bhagavansprasad wrote:
-  How close the results of NetSim with Real time results?

 

From an RF point of view the results are very close, like scary close. But you need to remember that simulated processor runs at 1 MHz, so if your real processor is faster, then some timings will change. But in mist cases being faster is not a problem.

 

bhagavansprasad wrote:
-  What is the best way to test my changes (Network Layer) in LwMesh?  How many boards Do I need?

Depends on what those changes are.

 

Attachment(s): 

NOTE: I no longer actively read this forum. Please ask your question on www.eevblog.com/forum if you want my answer.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thank you very much for quick reply.

 

>>.... verify your results on the hardware anyway.

Yes of-course, I need to test it on HW.  But working on multiple HWs, I feel it take long time, especially with network layer changes where routing is involved.

There is a reason behind the point I am making. 

 

Some time back I worked on RSTP (Rapid Spawning Tree Protocol) where I could test everything on simulated environment in a Linux PC. Otherwise it would have been multiple PCs.

 

I have a basic question, what is the purpose of the NetSim (Please excuse me, if my question sounds stupid). What is it simulating?

 

When I am compiling, it is compiling for 'arm' but I replace with 'gcc' 

Even I got some compilation errors where 'nwk' related files are not found.  I copied them from 'LwMesh121'.  Finally I could build it for Linux '.elf' image

 

I am not sure, whether I could successfully built or completely mess it up :(

 

regards

Bhagavan

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

bhagavansprasad wrote:
I have a basic question, what is the purpose of the NetSim (Please excuse me, if my question sounds stupid). What is it simulating?
It is simulating Cortex-M0 MCU with integrated radio and associated over the air communication with focus on physical modeling of the RF signal propagation.

 

bhagavansprasad wrote:
When I am compiling, it is compiling for 'arm' but I replace with 'gcc'
What?

 

bhagavansprasad wrote:
Even I got some compilation errors where 'nwk' related files are not found.  I copied them from 'LwMesh121'.  Finally I could build it for Linux '.elf' image
What I sent in that file is only a patch for LwMesh, it has to be applied to a package downloaded from the site.

 

You may need to change your application to work in a simulated environment, of course.

NOTE: I no longer actively read this forum. Please ask your question on www.eevblog.com/forum if you want my answer.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Trying to understand LwMesh_sim

 

- Are you targeting this simulator to run on to PC (Linux)?  Making it pure simulator without any HW to test basic functionality like Phy (Building frames), NWLayer (Routing algorithm, routing table updates).

 

>>Unless you are doing something tricky (like new routing algorithm, or something similar),

Why do we need to change routing algorithm?  As long as data passed to NW layer with correct format.  i.e Through Phy Layer.

 

I built image for Linux using gcc.  It is core dumping at run time.  It is crashing in HAL_TimerInit function in halTimer.c file. 

It obvious because it is trying to execute below pre-processed statement where the address is invalid.

(*(volatile uint32_t *)(0x02000004)) = 0; 

 

What is the meaning of above statement in case real HW.  What could be the equivalent statement in case of simulator?

 

regards

Bhagavan

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

bhagavansprasad wrote:
- Are you targeting this simulator to run on to PC (Linux)?  Making it pure simulator without any HW to test basic functionality like Phy (Building frames), NWLayer (Routing algorithm, routing table updates).
That is correct. The goal is to debug networking part and RF environment. It is not a general purpose simulator.

 

bhagavansprasad wrote:
>>Unless you are doing something tricky (like new routing algorithm, or something similar),

Why do we need to change routing algorithm?  As long as data passed to NW layer with correct format.  i.e Through Phy Layer.

I don't know. Maybe you have something better in mind, or you are doing scientific research, for example.

 

bhagavansprasad wrote:
I built image for Linux using gcc.  It is core dumping at run time.  It is crashing in HAL_TimerInit function in halTimer.c file. 

It obvious because it is trying to execute below pre-processed statement where the address is invalid.

(*(volatile uint32_t *)(0x02000004)) = 0;

The code in LwMesh_sim is a porting layer for the LwMesh itself, it is compiled with the LwMesh-based application using arm-none-eabi compiler. The resulting binary is passed to the simulator.

NOTE: I no longer actively read this forum. Please ask your question on www.eevblog.com/forum if you want my answer.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

If it is a simulator (Not general purpose) they why are you building image using cross compiler ( arm-none-eabi)?  Are going to run simulator on specific HW?

 

>>I don't know. Maybe you have something better in mind, or you are doing scientific research, for example.

My only confidence is,  if I could test STP & RSTP protocols (L2 or Just above MAC layer protocol) why not LwMesh?  I don't see any difference.  Both has tables, both operates on L2.

Regarding me, basically I became a freelance developer after working with few IT companies.  I conduct training and do develop products

 

Can you please explain meaning of below statement in hal ....simulator.h file

 

(*(volatile uint32_t *)(0x02000004)) = 0; 

What is the meaning of above statement in case of real HW.  What could be the equivalent statement in case of simulator?  Because simulator runs on a PC where you can't value to directly into some memory location (In case of Linux, Not sure above windows).  

If understand the purpose of above statement I have to re-write entire hal/simulater/inc/simulater.h file.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

bhagavansprasad wrote:
If it is a simulator (Not general purpose) they why are you building image using cross compiler ( arm-none-eabi)?  Are going to run simulator on specific HW?

 

There are two parts to the simulator. One is a simulation environment itself (available on GitHub) that runs on a PC and it emulates Cortex-M0 MCU with a radio peripheral (essentially RF SoC). This one you compile and run on your PC using normal gcc from your system.

 

The simulator takes normal binaries, the same bianies you will normally program into your MCU flash memory. Those binaries have to be built with arm-none-eabi-gcc compiler, because they have to be built for Cortex-M0, that's the MCU main simulator program simulates.

 

The simulated MCU is not a specific existing device, it is a virtual device with unique (and very limited) peripheral set. Essentially peripherals include RF radio, a timer and a small control module. Those peripherals are designed for fast simulation.

 

bhagavansprasad wrote:
Can you please explain meaning of below statement in hal ....simulator.h file

 

The address 0x02000004 is an address of a simulated register SYS_TIMER_COUNTER. You know because 0x02000000 is an offset of the timer peripheral (SOC_ID_SYS_TIMER = 0x02) and 4 is an offset of this register.

 

bhagavansprasad wrote:
What is the meaning of above statement in case of real HW. What could be the equivalent statement in case of simulator?
There is no "real" HW, this statement is only valis within a simulated MCU environment.

 

bhagavansprasad wrote:
Because simulator runs on a PC where you can't value to directly into some memory location (In case of Linux, Not sure above windows). 
Again, you are confusing two parts of the simulator. The part you are looking at does not run on an OS.

 

NOTE: I no longer actively read this forum. Please ask your question on www.eevblog.com/forum if you want my answer.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

What stops from running LwMesh_sim as a simulator on Linux PC?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

Because it is the code that is written to access a radio transceiver as a peripheral that is only available inside the simulated environment, it does nothing by itself. Also, it is just a patch that should be applied to a full version of LwMesh.

 

By analogy, what stops you from taking any AVR project and compiling and running it on a PC? That project will access peripherals that don't exist on a PC (Timers, ADC, IO ports).

NOTE: I no longer actively read this forum. Please ask your question on www.eevblog.com/forum if you want my answer.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hello Alex,

 

I'm really interested in using your simulation software for my application. I've asked you in another opportunity for some advice regarding network topology for a system with 1000 nodes. I was hoping to use your simulation software for testing some modifications to the stack and in order to understand the behaviour of the whole network with that many nodes.

 

I started by compiling the PingPong example, but after a few debug lines, i keep getting an error of an unhandled write (Error: unhandled word write @ 0x480f4c0e = 0x00000008). I used the makefile inside the project folder and i added the missing files of the LWMesh directly from the source codes of Atmel Website (all files from network and system layer). Am i missing something? I would really aprecciate your help.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Note that you are replying to a two year old post.

I don't think that Alex is active on the forum any longer?

 

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...