intrig-unicamp / mininet-wifi

Emulator for Software-Defined Wireless Networks
https://mn-wifi.readthedocs.io/
Other
447 stars 241 forks source link

twoRayPropagation model #385

Closed ChrisCharma closed 2 years ago

ChrisCharma commented 3 years ago

Hello, I have a simple adhoc network with two stations. I used the twoRayGround propagation model and I get this error. image Is there something I have to do? Thank you.

ramonfontes commented 3 years ago

I cannot reproduce the issue. I suggest you to do git pull and run sudo make install.

ChrisCharma commented 3 years ago

The code is this one. I did a git pull and make install, but it didn't work. Does this work for you? Thnak you.

import sys
from mininet.log import setLogLevel, info
from mn_wifi.link import wmediumd, adhoc
from mn_wifi.cli import CLI
from mn_wifi.net import Mininet_wifi
from mn_wifi.wmediumdConnector import interference, error_prob
from mininet.node import Controller, RemoteController

def topology(args):
    "Create a network."
    net = Mininet_wifi(link=wmediumd, wmediumd_mode=interference)

    # info( '*** Adding controller\n' )
    # c0 = net.addController(name='c0')

    info("*** Creating nodes\n")
    kwargs = dict()
    if '-a' in args:
        kwargs['range'] = 100

    s1 = net.addStation('s1', range='100',
                        position='100,200,0', **kwargs)
    s2 = net.addStation('s2', range='100',
                        position='200,200,0', **kwargs)

    net.setPropagationModel(model="twoRayGround")

    info("*** Configuring wifi nodes\n")
    net.configureWifiNodes()

    info("*** Creating links\n")
    # MANET routing protocols supported by proto:
    # babel, batman_adv, batmand and olsr
    # WARNING: we may need to stop Network Manager if you want
    # to work with babel
    protocols = ['babel', 'batman_adv', 'batmand', 'olsrd', 'olsrd2']
    kwargs = dict()
    for proto in args:
        if proto in protocols:
            kwargs['proto'] = proto

    net.addLink(s1, cls=adhoc, intf='s1-wlan0',
                ssid='adhocNet', mode='g', channel=5,
                ht_cap='HT40+', **kwargs)
    net.addLink(s2, cls=adhoc, intf='s2-wlan0',
                ssid='adhocNet', mode='g', channel=5,
                **kwargs)

    net.plotGraph(max_x=1500, max_y=500)

    info("*** Starting network\n")
    net.build()

    # info( '*** Starting controllers\n')
    # for controller in net.controllers:
    #     controller.start()

    info("\n*** Addressing...\n")
    if 'proto' not in kwargs:
        s1.setIP6('2001::1/64', intf="s1-wlan0")
        s2.setIP6('2001::2/64', intf="s2-wlan0")

    info("*** Running CLI\n")
    CLI(net)

    info("*** Stopping network\n")
    net.stop()

if __name__ == '__main__':
    setLogLevel('info')
    topology(sys.argv)
ramonfontes commented 3 years ago

Okay. You're setting the signal range. That's why I was unable to reproduce the issue.

Just fixed it https://github.com/intrig-unicamp/mininet-wifi/commit/fb030179c1572a817242893ff0086289b685c4ae!

ChrisCharma commented 3 years ago

Great! Thank you.

ChrisCharma commented 3 years ago

Hello, With twoRayGround there is no limitation at distance. e.g I could ping with txpower=1dBm in distance of 80km. Also, I don't see any changes in packet losses or RTT as I change distance and txpower. It seems like thay are all fixed.

ChrisCharma commented 3 years ago

Hello @ramonfontes , Do you know what may be the problem? Should I try something? Thank you.

ramonfontes commented 3 years ago

This might be a problem with the propagation model implemented in either Mininet-WiFi https://github.com/intrig-unicamp/mininet-wifi/blob/master/mn_wifi/propagationModels.py or wmediumd https://github.com/ramonfontes/wmediumd/blob/mininet-wifi/wmediumd/config.c#L249

ChrisCharma commented 3 years ago

I see that in twoRayGround antenna height has a role in the equation and the method. I tried to change it for my two nodes, but I get this error: image

As you can see the value of height changes but after that something happens and affect the method setAntennaGain as well.

ramonfontes commented 3 years ago

A small change is necessary in your PR. Actually, I should review that first. Antenna Height is not implemented in wmediumd as you can see in L147. That's why you got the error.

You can either comment L365 or implement the antenna height in wmediumd.

ramonfontes commented 2 years ago

Closing due to inactivity