intrig-unicamp / mininet-wifi

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

Problems with any mode except g for containernet-wifi and mininet-wifi #462

Closed dohlenaugur closed 1 year ago

dohlenaugur commented 1 year ago

Hello,

I am using containernet-wifi with mininet 2.3.1b1 on Ubuntu 20.04 focal.

I am new to the networking field and have so far only tested networks with mode "g", where everything worked fine out of the box. But when I try to start the 6GHz.py from the mininet examples, I can not ping with >> sta1 ping sta2

Do I have to set up the connection manually? A similar network with mode "g" seems to work fine with ping. I tried also ac mode, but I cant get any connection as well. Also I turned network-manager off, but it seemed to have no effect.

Thanks

ramonfontes commented 1 year ago

But when I try to start the 6GHz.py from the mininet examples, I can not ping with >> sta1 ping sta2

https://github.com/intrig-unicamp/mininet-wifi/blob/master/examples/6GHz.py#L13

Do I have to set up the connection manually? A similar network with mode "g" seems to work fine with ping. I tried also ac mode, but I cant get any connection as well.

Please describe what you did with more details. Otherwise, we won't be able to help you.

dohlenaugur commented 1 year ago

Thank you for the quick answer,

So ax does not work at all right now? I read in the issue here https://github.com/intrig-unicamp/mininet-wifi/issues/429 that there was a patch?

For the ac:

When I start:

"Starting network"
    net = Mininet_wifi()

    info("*** Creating nodes\n")
    ap1 = net.addAccessPoint('ap1', ssid='new-ssid', mac='00:00:00:00:00:01',
                             mode='g', channel='1',
                             failMode="standalone",
                             position='50,50,0')
    net.addStation('sta1', mac='00:00:00:00:00:02', ip='10.0.0.1/8',
                   position='30,60,0')
    net.addStation('sta2', mac='00:00:00:00:00:03', ip='10.0.0.2/8',
                   position='70,30,0')

    info("*** Configuring propagation model\n")
    net.setPropagationModel(model="logDistance", exp=4.5)

    # modified module
    #net.setModule('./mac80211_hwsim.ko')

    info("*** Configuring nodes\n")
    net.configureNodes()

    if '-p' not in args:
        net.plotGraph(max_x=100, max_y=100)

    info("*** Starting network\n")
    net.build()
    ap1.start([])

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

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

I can type in the CLI >> sta1 ping sta2 and I get a return of the time.

But when I try

    "Starting network"
    net = Mininet_wifi()

    info("*** Creating nodes\n")
    ap1 = net.addAccessPoint('ap1', ssid='new-ssid', mac='00:00:00:00:00:01',
                             mode='ac', channel='184',
                             failMode="standalone",
                             position='50,50,0')
    net.addStation('sta1', mac='00:00:00:00:00:02', ip='10.0.0.1/8',
                   position='30,60,0')
    net.addStation('sta2', mac='00:00:00:00:00:03', ip='10.0.0.2/8',
                   position='70,30,0')

    info("*** Configuring propagation model\n")
    net.setPropagationModel(model="logDistance", exp=4.5)

    # modified module
    #net.setModule('./mac80211_hwsim.ko')

    info("*** Configuring nodes\n")
    net.configureNodes()

    if '-p' not in args:
        net.plotGraph(max_x=100, max_y=100)

    info("*** Starting network\n")
    net.build()
    ap1.start([])

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

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

I was not able to ping with the same command. I was not sure, if I have to use encryption or other parameters, but everything I tried did not lead to a connection. Additionally I tried one station with an ap linked to a host, but ping was also only possible with mode g. Same thing with Mininet_wifi(link=wmediumd, wmediumd_mode=interference,)

ramonfontes commented 1 year ago

So ax does not work at all right now? I read in the issue here https://github.com/intrig-unicamp/mininet-wifi/issues/429 that there was a patch?

Do you have any comment about the regulatory domain? -> https://github.com/intrig-unicamp/mininet-wifi/issues/429#issuecomment-1081928048

For the ac:

Please confirm you have channel 184 enabled in your system

dohlenaugur commented 1 year ago

Please confirm you have channel 184 enabled in your system

Could you tell me how to do so? (Do you mean with lttng?)

But I saw, that ax supports channel 1 (which seemed to work with 802.11g) and I had the same problem with ping

ap1 = net.addAccessPoint('ap1', ssid='new-ssid', mac='00:00:00:00:00:01',
                             mode='ax', channel='1',
                             freq=2.4,
                             failMode="standalone",
                             position='50,50,0')

so when I switch the ax to g, everything works fine

ramonfontes commented 1 year ago

Could you tell me how to do so?

Wireless tools such as iw.

But I saw, that ax supports channel 1 (which seemed to work with 802.11g)

Channel is not relevant here. Frequencies in this case are different independently of the channel. Please make sure you have enabled 6GHz channels in the regulatory domain.

dohlenaugur commented 1 year ago

6GHz is not really important for me, I just want a faster mode than g (so n would be sufficient as well).

I tried this setup now:


net = Containernet(
        autoAssociation=True,
        link=wmediumd,
        wmediumd_mode=interference,
    )
    info("*** Creating nodes\n")
    ap1 = net.addAccessPoint(
        'ap1',
        ssid='ap1-ssid',
        mode='n',  # g, a, n, ac, ax
        channel=36,  # 36 for mode 802.11n --> frequency.py line 38 , ax, a, g support channel 1
        failMode="standalone",
        position=str(2) + ',0,0',
        range='35'
    )
    sta1 = net.addStation(
        'sta1',
        mac='00:00:00:00:00:02',
        ip='10.0.0.21/24',
        position='0,0,0',
        cls=DockerSta,
        dimage='edgeslamsim:full',
        range='35',
    )

    c1 = net.addController('c1')
    d1 = net.addDocker('d1', ip='10.0.0.91/24', dimage="edgeslamsim:full")  # host with docker attached

    info("*** Configuring Propagation Model\n")
    net.setPropagationModel(model="logDistance", exp=4)

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

    # net.addLink(ap1, host)
    net.addLink(ap1, d1)  # make wired link between docker and ap

    info("*** Starting network\n")
    net.build()
    c1.start()
    ap1.start([c1])
    CLI(net)
    info("*** Stopping network\n")
    net.stop()

When I use "$ iw list | grep Frequencies -A 24" for sta1 I get

Frequencies:
            * 2412 MHz [1] (20.0 dBm)
            * 2417 MHz [2] (20.0 dBm)
            * 2422 MHz [3] (20.0 dBm)
            * 2427 MHz [4] (20.0 dBm)
            * 2432 MHz [5] (20.0 dBm)
            * 2437 MHz [6] (20.0 dBm)
            * 2442 MHz [7] (20.0 dBm)
            * 2447 MHz [8] (20.0 dBm)
            * 2452 MHz [9] (20.0 dBm)
            * 2457 MHz [10] (20.0 dBm)
            * 2462 MHz [11] (20.0 dBm)
            * 2467 MHz [12] (20.0 dBm)
            * 2472 MHz [13] (20.0 dBm)
            * 2484 MHz [14] (disabled)
    Band 2:
        Capabilities: 0x107e
            HT20/HT40
            SM Power Save disabled
            RX Greenfield
            RX HT20 SGI
            RX HT40 SGI
            No RX STBC
            Max AMSDU length: 3839 bytes
            DSSS/CCK HT40
--
        Frequencies:
            * 5180 MHz [36] (23.0 dBm)
            * 5200 MHz [40] (23.0 dBm)
            * 5220 MHz [44] (23.0 dBm)
            * 5240 MHz [48] (23.0 dBm)
            * 5260 MHz [52] (20.0 dBm) (radar detection)
            * 5280 MHz [56] (20.0 dBm) (radar detection)
            * 5300 MHz [60] (20.0 dBm) (radar detection)
            * 5320 MHz [64] (20.0 dBm) (radar detection)
            * 5500 MHz [100] (26.0 dBm) (radar detection)
            * 5520 MHz [104] (26.0 dBm) (radar detection)
            * 5540 MHz [108] (26.0 dBm) (radar detection)
            * 5560 MHz [112] (26.0 dBm) (radar detection)
            * 5580 MHz [116] (26.0 dBm) (radar detection)
            * 5600 MHz [120] (26.0 dBm) (radar detection)
            * 5620 MHz [124] (26.0 dBm) (radar detection)
            * 5640 MHz [128] (26.0 dBm) (radar detection)
            * 5660 MHz [132] (26.0 dBm) (radar detection)
            * 5680 MHz [136] (26.0 dBm) (radar detection)
            * 5700 MHz [140] (26.0 dBm) (radar detection)
            * 5745 MHz [149] (13.0 dBm)
            * 5765 MHz [153] (13.0 dBm)
            * 5785 MHz [157] (13.0 dBm)
            * 5805 MHz [161] (13.0 dBm)
            * 5825 MHz [165] (13.0 dBm)
--
        Frequencies:
            * 902 MHz [-301] (disabled)
            * 903 MHz [-300] (disabled)
            * 903 MHz [-300] (disabled)
            * 904 MHz [-300] (disabled)
            * 904 MHz [-300] (disabled)
            * 905 MHz [-300] (disabled)
            * 905 MHz [-300] (disabled)
            * 906 MHz [-300] (disabled)
            * 906 MHz [-300] (disabled)
            * 907 MHz [-300] (disabled)
            * 907 MHz [-300] (disabled)
            * 908 MHz [-299] (disabled)
            * 908 MHz [-299] (disabled)
            * 909 MHz [-299] (disabled)
            * 909 MHz [-299] (disabled)
            * 910 MHz [-299] (disabled)
            * 910 MHz [-299] (disabled)
            * 911 MHz [-299] (disabled)
            * 911 MHz [-299] (disabled)
            * 912 MHz [-299] (disabled)
            * 912 MHz [-299] (disabled)
            * 913 MHz [-298] (disabled)
            * 913 MHz [-298] (disabled)
            * 914 MHz [-298] (disabled)
root@sta1:~# iw dev
phy#8
    Interface sta1-wlan0
        ifindex 49
        wdev 0x800000001
        addr 00:00:00:00:00:02
        ssid ap1-ssid
        type managed
        channel 36 (5180 MHz), width: 20 MHz, center1: 5180 MHz
        txpower 1.00 dBm

So both 1 and 36 should be enabled right? And in frequency.py, mode n with the 5 GHz channel 36 is possible. But when I try to ping with >> sta1 ping d1, I get no connection. With mode g and channel 1, it works fine. So I dont understand why.

Also I tried to connect by hand, and I see the ap1 from sta1, but when I tried "$ iw sta1-wlan0 connect ap1-ssid" I got: $ command failed: Operation already in progress (-114)

ramonfontes commented 1 year ago

Did you run the code in debug mode? Do you have any useful information about it? Does the image have all the wireless dependencies??

I have to be honest that sometimes I'm getting confused. First you use mn-wifi; then you use containernet; You have openned an issue for 6GHz and you use 5GHz. Please use the mailing list for random topics.

dohlenaugur commented 1 year ago

OK, I apologize I could have named the issue better.

The mininet code was just for me to debug, if it may work with mininet, but not with containernet.

What I want is to use containernet-wifi with a mode faster than g (best would be n, ac or ax, but 6GHz is not necessary). I tried out the 6GHz.py, because it seemed to be the fastest, but I could not make anything except mode g work so far, no matter if I use only mininet-wifi or containernet-wifi.

Like I said, g seems to work fine but e.g. n does not connect. I can see inside the docker container, that the interface should be fine and I can scan for the access point, but I can not connect.

What dependencies could be missing?

Also when I look at the logs in the console, it seems that the station will get channel 1 mode g freq 2.4 per default, but if I set them explicitly to 36, n, 5.18 I see no changes in not connecting

ramonfontes commented 1 year ago

What dependencies could be missing?

Did you run the code in debug mode??

Also when I look at the logs in the console, it seems that the station will get channel 1 mode g freq 2.4 per default, but if I set them explicitly to 36, n, 5.18 I see no changes in not connecting

It seems that you don't know mac80211 and Linux wireless tools.

dohlenaugur commented 1 year ago

Did you run the code in debug mode??

When I run it with setLogLevel('debug') I get:

*** errRun: ['grep', '-c', 'processor', '/proc/cpuinfo'] 
20
  0*** Setting resource limits
*** Creating nodes
*** errRun: ['which', 'ovs-vsctl'] 
/usr/bin/ovs-vsctl
  0*** errRun: ['ovs-vsctl', '-t', '1', 'show'] 
967a556b-c7a6-42f0-b672-dfcb6a934e9d
    ovs_version: "2.13.8"
  0*** errRun: ['ovs-vsctl', '--version'] 
ovs-vsctl (Open vSwitch) 2.13.8
DB Schema 8.2.0
  0_popen ['mnexec', '-cd', 'env', 'PS1=\x7f', 'bash', '--norc', '--noediting', '-is', 'mininet:ap1'] 57555*** ap1 : ('unset HISTFILE; stty -echo; set +m',)
unset HISTFILE; stty -echo; set +m

added intf lo (0) to node ap1
*** ap1 : ('ifconfig', 'lo', 'up')
Created docker container object sta1
image: sim:full
dcmd: /bin/bash
sta1: kwargs {'ip': '10.0.0.21/24', 'ip6': '2001:0:0:0:0:0:0:1/64', 'channel': 1, 'band': 20, 'freq': 2.4, 'mode': 'g', 'encrypt': '', 'passwd': None, 'ieee80211w': None, 'mac': '00:00:00:00:00:02', 'position': '0,0,0', 'range': '35'}
Docker container sta1 started
*** errRun: ['which', 'mnexec'] 
/usr/bin/mnexec
  0*** errRun: ['which', 'ip', 'addr'] 
/usr/sbin/ip
  1_popen ['docker', 'exec', '-it', 'mn.sta1', 'env', 'PS1=\x7f', 'bash', '--norc', '-is', 'mininet:sta1'] 57733*** sta1 : ('unset HISTFILE; stty -echo; set +m',)
unset HISTFILE; stty -echo; set +m
sta1: update resources {'cpu_quota': -1}
*** errRun: ['which', 'controller'] 
/usr/local/bin/controller
  0*** errRun: ['which', 'mnexec'] 
/usr/bin/mnexec
  0*** errRun: ['which', 'ifconfig'] 
/usr/sbin/ifconfig
  0_popen ['mnexec', '-cd', 'env', 'PS1=\x7f', 'bash', '--norc', '--noediting', '-is', 'mininet:c1'] 57792*** c1 : ('unset HISTFILE; stty -echo; set +m',)
unset HISTFILE; stty -echo; set +m
*** errRun: ['which', 'telnet'] 
/usr/bin/telnet
  0*** c1 : ('echo A | telnet -e A 127.0.0.1 6653',)
Telnet escape character is 'A'.
Trying 127.0.0.1...
telnet: Unable to connect to remote host: Connection refused
Created docker container object d1
image: sim:full
dcmd: /bin/bash
d1: kwargs {'ip': '10.0.0.91/24'}
Docker container d1 started
*** errRun: ['which', 'mnexec'] 
/usr/bin/mnexec
  0*** errRun: ['which', 'ifconfig'] 
/usr/sbin/ifconfig
  0_popen ['docker', 'exec', '-it', 'mn.d1', 'env', 'PS1=\x7f', 'bash', '--norc', '-is', 'mininet:d1'] 57925*** d1 : ('unset HISTFILE; stty -echo; set +m',)
unset HISTFILE; stty -echo; set +m
d1: update resources {'cpu_quota': -1}
*** Configuring Propagation Model
*** Configuring wifi nodes
Loading 2 virtual wifi interfaces
Created mac80211_hwsim device with ID 0
Created mac80211_hwsim device with ID 1
rfkill unblock 66
*** sta1 : ('ip link set wlan0 down',)
*** sta1 : ('ip link set wlan0 name sta1-wlan0',)
*** ap1 : ('ip link set wlan1 down',)
*** ap1 : ('ip link set wlan1 name ap1-wlan1',)
*** ap1 : ('ip link set ap1-wlan1 up',)

added intf sta1-wlan0 (0) to node sta1
*** sta1 : ('ip link set', 'sta1-wlan0', 'down')
*** sta1 : ('ip link set', 'sta1-wlan0', 'address', '00:00:00:00:00:02')
*** sta1 : ('ip link set', 'sta1-wlan0', 'up')
*** sta1 : ('ip addr flush ', 'sta1-wlan0')
*** sta1 : ('ip addr add 10.0.0.21/24 brd + dev sta1-wlan0 && ip -6 addr add 2001:0:0:0:0:0:0:1/64 dev sta1-wlan0',)
RTNETLINK answers: Permission denied
*** sta1 : ('ip -6 addr flush ', 'sta1-wlan0')
*** sta1 : ('ip -6 addr add', '2001:0:0:0:0:0:0:1/64', 'dev', 'sta1-wlan0')
RTNETLINK answers: Permission denied
*** sta1 : ('ip link set lo up',)

added intf ap1-wlan1 (1) to node ap1
*** ap1 : ('ip link set', 'ap1-wlan1', 'up')
*** ap1 : ('ethtool -K', <WirelessLink ap1-wlan1>, 'gro', 'off')
getting mac address from ap1-wlan1
_popen ['mnexec', '-da', '57555', 'ip', 'addr', 'show', 'ap1-wlan1'] 58090
02:00:00:00:01:00*** ap1 : ('ip link set', 'ap1-wlan1', 'down')
*** ap1 : ('ip link set', 'ap1-wlan1', 'address', '02:00:00:00:01:00')
*** ap1 : ('ip link set', 'ap1-wlan1', 'up')
*** sta1 : ('iw dev', 'sta1-wlan0 set txpower fixed 100')
*** ap1 : ('iw dev', 'ap1-wlan1 set txpower fixed 100')
Name of wmediumd config: /tmp/mn_wmd_config_k3gwoawq.cfg
Name of wmediumd log: /tmp/mn_wmd_log_d2l5byjj.log
*** Connecting to wmediumd server /var/run/wmediumd.sock
*** ap1 : ("echo 'interface=ap1-wlan1\ndriver=nl80211\nssid=ap1-ssid\nwds_sta=1\nhw_mode=a\nchannel=36\nwmm_enabled=1\nieee80211n=1\nctrl_interface=/var/run/hostapd\nctrl_interface_group=0' > mn57547_ap1-wlan1.apconf",)
> > > > > > > > > *** ap1 : ('hostapd -B mn57547_ap1-wlan1.apconf ',)
ap1-wlan1: interface state UNINITIALIZED->ENABLED
ap1-wlan1: AP-ENABLED 
*** ap1 : ('ip link set', 'ap1-wlan1', 'down')
*** ap1 : ('ip link set', 'ap1-wlan1', 'address', '02:00:00:00:01:00')
*** ap1 : ('ip link set', 'ap1-wlan1', 'up')
*** sta1 : ('iw dev', 'sta1-wlan0 set txpower fixed 100')
*** ap1 : ('iw dev', 'ap1-wlan1 set txpower fixed 100')
*** errRun: ip link add name ap1-eth2 address 8e:b8:c2:a7:84:e9 type veth peer name d1-eth0 address 8a:fc:0f:22:ea:fe  
  0*** errRun: ['ip', 'link', 'set', 'ap1-eth2', 'netns', '57555'] 
  0*** errRun: ['ip', 'link', 'set', 'd1-eth0', 'netns', '57866'] 
  0
added intf ap1-eth2 (2) to node ap1
*** ap1 : ('ifconfig', 'ap1-eth2', 'up')
*** ap1 : ('ethtool -K', <TCIntf ap1-eth2>, 'gro', 'off', 'tx', 'on', 'rx', 'on')

added intf d1-eth0 (0) to node d1
moving d1-eth0 into namespace for d1 
*** d1 : ('ifconfig', 'd1-eth0', 'up')
*** d1 : ('ethtool -K', <TCIntf d1-eth0>, 'gro', 'off', 'tx', 'on', 'rx', 'on')
*** ap1 : ('ovs-vsctl', 'add-port', <OVSAP ap1: lo:127.0.0.1,ap1-wlan1:None,ap1-eth2:None pid=57555> , <TCIntf ap1-eth2>)
ovs-vsctl: no bridge named ap1
*** ap1 : ('ifconfig', <TCIntf ap1-eth2>, 'up')
*** Starting network
*** Configuring nodes
*** d1 : ('ip', 'address', 'flush', 'dev', 'd1-eth0')
*** d1 : ('ip', 'address', 'add', '10.0.0.91/24', 'dev', 'd1-eth0')
*** d1 : ('ifconfig lo up',)
_popen ['docker', 'exec', '-t', 'mn.sta1', 'iwconfig', 'sta1-wlan0', 'essid', 'ap1-ssid', 'ap', '02:00:00:00:01:00'] 58125
added intf sta1-wlan0 (0) to node sta1
*** sta1 : ('ip link set', 'sta1-wlan0', 'up')
*** sta1 : ('ethtool -K', <WirelessLink sta1-wlan0>, 'gro', 'off')
*** errRun: ['which', 'controller'] 
/usr/local/bin/controller
  0*** c1 : ('controller ptcp:6653 1>/tmp/c1.log 2>/tmp/c1.log &',)
[1] 58157
*** ap1 : ('ovs-vsctl', '-- --id=@ap1c1 create Controller target=\\"tcp:127.0.0.1:6653\\" max_backoff=1000 -- --if-exists del-br ap1 -- add-br ap1 -- set bridge ap1 controller=[@ap1c1] other_config:datapath-id=1000000000000001 fail_mode=standalone other-config:disable-in-band=true other-config:dp-desc=ap1 -- add-port ap1 ap1-wlan1 -- set Interface ap1-wlan1 ofport_request=1 -- add-port ap1 ap1-eth2 -- set Interface ap1-eth2 ofport_request=2')
d9df5ddc-7ed2-49ec-8ac0-9baabfa636a7
*** Starting CLI:
*** errRun: ['stty', 'echo', 'sane', 'intr', '^C'] 

It seems that you don't know mac80211 and Linux wireless tools.

I am new to networking, so I have played around with tools like ifconfig, ip and iw a bit. But because wifi inside mininet-wf worked with 802.11g out of the box, I do not know what mininet requires to do manually, if it would be necessary now. I expected, that mininet would configure everything to a workable deafault state. So I do not see, where the issue is, because I can see the ap, just not connect to it.

ramonfontes commented 1 year ago

Code seems ok! Is network manager running??

dohlenaugur commented 1 year ago

It seems like I have only set network manager off for ax (which still does not connect, even without network manager), but when I tried it for n and ac, I now got the ping sta1 to d1. The first ping message took way longer, than with g, so most probably I have canceled it too early.

But what I am wondering right now is, why I get only 7151 Kbits/sec with iperf over 2m distance with mode n, while with mode g I got 34Mbit/sec.

Do you think ax not connecting with channel 1 is because of the missing 6GHz in the iw list I posted? Because I thought 802.11ax also supports 2.4 and 5GHz?

But anyway, thank you very much for your time and help, after all my debugging with ax, I forgot about network manager for the other modes.

ramonfontes commented 1 year ago

But what I am wondering right now is, why I get only 7151 Kbits/sec with iperf over 2m distance with mode n, while with mode g I got 34Mbit/sec.

The bitrate supported by other technologies mush be added to wmediumd signal table and updated in wmediumd might be required if you are using wmediumd. PRs are welcome!

Do you think ax not connecting with channel 1 is because of the missing 6GHz in the iw list I posted? Because I thought 802.11ax also supports 2.4 and 5GHz?

https://mininet-wifi.github.io/usage/#supportedModes

dohlenaugur commented 1 year ago

Thank you very much.

PRs are welcome!

I will see if I have time after finishing my current project.

One last question: I tried using TC instead of wmedium now (WirelessLink) and 802.11n seems to be fine, but with 802.11ac, the behaviour even with TC seems kind of odd. Do you have any idea, why this could be? (Measured bandwidth with iperf TCP)

Bandwidth_containernet

dohlenaugur commented 1 year ago

For other peoples interest, I want to add, that my first issues (no connection with 802.11n) could be caused by the regulatory domain. When I set it via sudo iw reg set XX I started to get a connection (XX being the 2 characters of the country code). A hint was Frequency 5180 (primary) not allowed for AP mode, flags: 0x853 NO-IR in the debug message