Author Topic: Wireless Network Simulator for LWMesh  (Read 6120 times)

0 Members and 1 Guest are viewing this topic.

Offline fgargiuloTopic starter

  • Contributor
  • Posts: 22
  • Country: ar
Re: Wireless Network Simulator for LWMesh
« Reply #25 on: April 12, 2017, 01:50:38 pm »
Do you have any example where you use the sleep function? I'm having some trouble adding that functionality to my application. It seems that after calling asm("wfi"), no more code is executed (ever). I'm pretty sure i'm doing something wrong. Thanks.
« Last Edit: April 12, 2017, 01:54:49 pm by fgargiulo »
 

Online ataradov

  • Super Contributor
  • ***
  • Posts: 11262
  • Country: us
    • Personal site
Re: Wireless Network Simulator for LWMesh
« Reply #26 on: April 12, 2017, 04:36:55 pm »
Do you have any example where you use the sleep function?
I will come up with one this weekend.

It seems that after calling asm("wfi"), no more code is executed (ever). I'm pretty sure i'm doing something wrong.
You are probably not doing anything wrong.  There is a problem with this implementation, actually.

In a real core "wfi" will wake up if interrupt is enabled in the peripheral, even if it is disabled in the NVIC to actually call the interrupt handler.

In this implementation, there is no NVIC, so interrupt handlers must be enabled, but they are not really needed in LwMesh.

So I will need to add a simulated NVIC. To make it all work as in real system.

I was also thinking about it, and it probably would not be too hard to add arbitrary signal attenuation between the nodes. This will let you specify the walls and buildings. It will work something like this. Assume you have 2 nodes in the configuration handler with IDs 0 and 1.

You will specify additional attenuation value between the nodes:
Code: [Select]
att 0 1 1000
att 1 0 1000

This will create bidirectional attenuation of 1000 dBm (basically total block). You will have to manually identify nodes that should be connected, of course. This will probably be easier with some  sort of config generation tool.
Alex
 

Offline fgargiuloTopic starter

  • Contributor
  • Posts: 22
  • Country: ar
Re: Wireless Network Simulator for LWMesh
« Reply #27 on: April 12, 2017, 07:21:30 pm »
That's really awesome Alex. I'll start working on the config generation tool. I really appreciate your help.
 

Online ataradov

  • Super Contributor
  • ***
  • Posts: 11262
  • Country: us
    • Personal site
Re: Wireless Network Simulator for LWMesh
« Reply #28 on: April 14, 2017, 07:32:00 pm »
Added both things. On my machine, I get about 10x increase in speed:
Code: [Select]
200000000 cycles in 7607 ms => 26291573 cycles/sec       --- with wfi
200000000 cycles in 74895 ms => 2670405 cycles/sec       --- without wfi

Get a new version from GitHub, and updated example attached. Format of the new path loss command:
Quote
Additional Path Loss

This command defines additional path loss between two nodes, a node and a noise source, or a sniffer and a node.

This command can be used to simulate obstacles (like walls and buildings), or non-uniform environments. It can also be used to artificially force certain routing configurations. Introduced path loss is symmetrical in both directions for configurations where both sides are nodes.

Additional path loss is defined by the loss parameter. The negative values represent additional signal amplification.

Format:

loss   <receiver> <transmitter> <loss>

    receiver -- name of the receiver device (can be a node or a sniffer)
    transmitter -- name of the transmitter device (can be a node or a noise source)
    loss -- additional path loss between the devices (dBm)

Example:

noise   R_0   R_1   10.0

And as far as WFI goes, as you will see, I added this code to the main loop:
Code: [Select]
    if (!NWK_Busy())
      asm("wfi");

This makes sure that as long as stack has nothing to do, device sleeps, while waiting on interrupts. There are two sources of interrupts at the moment - the radio, and the timer. Timer interrupts every 10 ms to maintain software timers, and radio interrupts when frames are received and sent.

This makes sure that stack is not blocked when it is busy processing the frames.

But this does not really take into account application needs. In this case application is very simple, and it is not a problem, but more complex application may want to indicate that they are also busy doing useful things at the moment, ad node should not sleep.

To indicate that application is busy, it must call NWK_Lock(), and when it is done it must call NWK_Unlock(). NWK_Lock() and  NWK_Unlock() must come in symmetrical pairs, since one simply increments a counter, and another one decrements. Once counter is 0 - the stack is ready for sleep.
Alex
 

Online ataradov

  • Super Contributor
  • ***
  • Posts: 11262
  • Country: us
    • Personal site
Re: Wireless Network Simulator for LWMesh
« Reply #29 on: April 14, 2017, 07:34:12 pm »
I only did very basic testing on all this, so please report any problems.
Alex
 

Offline fgargiuloTopic starter

  • Contributor
  • Posts: 22
  • Country: ar
Re: Wireless Network Simulator for LWMesh
« Reply #30 on: April 18, 2017, 12:57:35 pm »
I've been testing the modifications and it all works awesome. The speed improvement and the new attenuation functionality lets me simulate lots of different environments. I'll let you know if i find any issues.

So far so good I've been able to test a network of 240 nodes. I'd like to move to a network of more than 256 nodes, but I've seen that some variables of the stack are initialized as uint8_t, maybe limiting max number of nodes. Am i right?
 

Online ataradov

  • Super Contributor
  • ***
  • Posts: 11262
  • Country: us
    • Personal site
Re: Wireless Network Simulator for LWMesh
« Reply #31 on: April 18, 2017, 04:41:17 pm »
The only thing that is really limited is routing table. It does make sense to just go and change all uint8_t in loops to int. This change was already done, but I never got to release that version of LwMesh.
Alex
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf