intrig-unicamp / mininet-wifi

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

AttributeError: 'Host' object has no attribute 'plot' when executing script #390

Closed ry4nzhu closed 3 years ago

ry4nzhu commented 3 years ago

I was trying to execute the following script:

#!/usr/bin/python3

'Example for handover'

from mininet.log import setLogLevel, info
from mininet.node import Controller
from mn_wifi.cli import CLI
from mn_wifi.net import Mininet_wifi

def topology():

    "Create a network."
    net = Mininet_wifi(controller=Controller)

    info("*** Creating nodes\n")
    sta1 = net.addStation('sta1', mac='00:00:00:00:00:01', ip='10.0.0.1/8')
    ap1 = net.addAccessPoint('ap1', ssid='new-ssid1', mode='g', channel='1', position='15,30,0')
    ap2 = net.addAccessPoint('ap2', ssid='new-ssid1', mode='g', channel='6', position='55,30,0')
    s3 = net.addSwitch('s3')
    h1 = net.addHost('h1', mac='00:00:00:00:00:02', ip='10.0.0.2/8')
    c1 = net.addController('c1')

    net.setPropagationModel(model="logDistance", exp=4.3)

    info("*** Configuring WiFi Nodes\n")
    net.configureWifiNodes()

    h1.plot(position='35,90,0')
    s3.plot(position='35,80,0')

    info("*** Creating links\n")
    net.addLink(ap1, s3)
    net.addLink(ap2, s3)
    net.addLink(h1, s3)

    net.plotGraph(max_x=100, max_y=100)

    net.startMobility(time=0)
    net.mobility(sta1, 'start', time=1, position='10,30,0')
    net.mobility(sta1, 'stop', time=80, position='60,30,0')
    net.stopMobility(time=80)

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

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

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

if __name__ == '__main__':
    setLogLevel('info')
    topology()

but I got AttributeError: 'Host' object has no attribute 'plot'. Is this method removed? Can anyone help me on how to set a position for the host and switch object in mininet?

ramonfontes commented 3 years ago

Yes. The plot() attribute has been removed from the Host object. However, you can implement your own plot() attribute in node.py.

ry4nzhu commented 3 years ago

Ok, if I comment out the h1.plot(position='35,90,0') and s3.plot(position='35,80,0') in the script, I cannot ping from sta1 to h1. Do you know how to make a station be able to ping the host connected to an AP?

ramonfontes commented 3 years ago

Did you check the association between station and ap, and the flow table in s3?

ry4nzhu commented 3 years ago
mininet-wifi> sta1 iwconfig
sta1-wlan0  IEEE 802.11  ESSID:"new-ssid1"  
          Mode:Managed  Frequency:2.412 GHz  Access Point: 02:00:00:00:01:00   
          Bit Rate:1 Mb/s   Tx-Power=14 dBm   
          Retry short limit:7   RTS thr:off   Fragment thr:off
          Encryption key:off
          Power Management:on
          Link Quality=70/70  Signal level=-36 dBm  
          Rx invalid nwid:0  Rx invalid crypt:0  Rx invalid frag:0
          Tx excessive retries:0  Invalid misc:0   Missed beacon:0

lo        no wireless extensions.

mininet-wifi> sta1 ping h1
PING 10.0.0.2 (10.0.0.2) 56(84) bytes of data.
^C
--- 10.0.0.2 ping statistics ---
3 packets transmitted, 0 received, 100% packet loss, time 2052ms

mininet-wifi> sta1 iwconfig
sta1-wlan0  IEEE 802.11  ESSID:off/any  
          Mode:Managed  Access Point: Not-Associated   Tx-Power=20 dBm   
          Retry short limit:7   RTS thr:off   Fragment thr:off
          Encryption key:off
          Power Management:on

lo        no wireless extensions.

It looks like the station is associated with ap1 first, but when I tried to ping h1, it is not associated anymore. And when I tried sh ovs-ofctl dump-flows s3, there is no output.

ramonfontes commented 3 years ago

Unfortunately, I'm unable to reproduce the issue. Please make sure that Network Manager is not running.

ry4nzhu commented 3 years ago

Ok it looks like the network manager somehow got active again. Close this.