intrig-unicamp / mininet-wifi

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

mininet-wifi container with python3 #330

Closed nomanmazhar closed 2 years ago

nomanmazhar commented 3 years ago

Hi,

1:- I am using containernet from "https://github.com/containernet/containernet"

2:- But for wifi i install containernet from "https://github.com/ramonfontes/containernet.git"

the topology made in first containernet does not work in the second containernet.

Both uses different version of python.

please guide me how can i run topology made in python3 to run in wifi based container.

thanks

regards noman

ramonfontes commented 3 years ago

Did you compile the code with the same Python version (sudo make install)?

nomanmazhar commented 3 years ago

Yes i have compiled using python3 Also i am using UBUNTU 20.04LTS the wifi container net successfully install but when i compile my topology it gave following error

INFO:main:Adding controller INFO:main:Adding docker containers INFO:main:Adding switches INFO:main:Creating links Traceback (most recent call last): File "nomanTopo.py", line 278, in topoloy() File "nomanTopo.py", line 164, in topoloy net.addLink(s1, s5, bw=BW_CORE_TO_DISTRIBUTION) File "/usr/local/lib/python3.8/dist-packages/containernet-3.0-py3.8.egg/containernet/net.py", line 314, in addLink self.conn.setdefault('src', []) AttributeError: 'Containernet' object has no attribute 'conn'

nomanmazhar commented 3 years ago

example topology

!/usr/bin/python

""" This is the most simple example to showcase Containernet. """ from containernet.cli import CLI from containernet.link import TCLink from containernet.net import Containernet from mininet.node import Controller from mininet.log import info, setLogLevel

setLogLevel('info')

net = Containernet(controller=Controller)

info(' Adding controller\n') net.addController('c0') info(' Adding docker containers\n') d1 = net.addDocker('d1', ip='10.0.0.251', dimage="ubuntu:trusty") d2 = net.addDocker('d2', ip='10.0.0.252', dimage="ubuntu:trusty") info(' Adding switches\n') s1 = net.addSwitch('s1') s2 = net.addSwitch('s2') info(' Creating links\n') net.addLink(d1, s1) net.addLink(s1, s2, cls=TCLink, delay='100ms', bw=1) net.addLink(s2, d2) info(' Starting network\n') net.start() info(' Testing connectivity\n') net.ping([d1, d2]) info(' Running CLI\n') CLI(net) info(' Stopping network') net.stop()

nomanmazhar commented 3 years ago

this example topology produce same error

nomanmazhar commented 3 years ago

i have compile the containernet using "sudo make install"

please let me know how to compile the code .....

what command i need to use

nomanmazhar commented 3 years ago

Also the containernet-wifi is running perfectly fine

only getting erro in containernet_example.py

ramonfontes commented 3 years ago

I didn't check the other sample files. I can only confirm the wifi example.

nomanmazhar commented 3 years ago

In Containernet_wifi if i try to add link it gave error

*** Adding docker containers sta1: kwargs {'ip': '10.0.0.3', 'ip6': '2001:0:0:0:0:0:0:1/64', 'channel': 1, 'freq': 2.4, 'band': 20, 'mode': 'g', 'mac': '00:02:00:00:00:10', 'cpu_shares': 20} sta1: update resources {'cpu_quota': -1, 'cpu_shares': 20} sta2: kwargs {'ip': '10.0.0.4', 'ip6': '2001:0:0:0:0:0:0:2/64', 'channel': 1, 'freq': 2.4, 'band': 20, 'mode': 'g', 'mac': '00:02:00:00:00:11', 'cpu_shares': 20} sta2: update resources {'cpu_quota': -1, 'cpu_shares': 20} Traceback (most recent call last): File "containernet_wifi.py", line 47, in topology() File "containernet_wifi.py", line 23, in topology net.addLink(sta1, ap1) File "/usr/local/lib/python3.8/dist-packages/containernet-3.0-py3.8.egg/containernet/net.py", line 314, in addLink self.conn.setdefault('src', []) AttributeError: 'Containernet' object has no attribute 'conn'

this is the topology i try to run

!/usr/bin/python

""" This is the most simple example to showcase Containernet. """ from containernet.net import Containernet from containernet.node import DockerSta from containernet.cli import CLI from containernet.term import makeTerm from mininet.log import info, setLogLevel

def topology(): net = Containernet()

info('*** Adding docker containers\n')
sta1 = net.addStation('sta1', ip='10.0.0.3', mac='00:02:00:00:00:10',
                      cls=DockerSta, dimage="ubuntu:trusty", cpu_shares=20)
sta2 = net.addStation('sta2', ip='10.0.0.4', mac='00:02:00:00:00:11',
                      cls=DockerSta, dimage="ubuntu:trusty", cpu_shares=20)
ap1 = net.addAccessPoint('ap1')
c0 = net.addController('c0')

net.addLink(sta1, ap1)
net.addLink(sta2, ap1)  
info('*** Configuring WiFi nodes\n')
net.configureWifiNodes()

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

makeTerm(sta1, cmd="bash -c 'apt-get update && apt-get install iw;'")
makeTerm(sta2, cmd="bash -c 'apt-get update && apt-get install iw;'")

#sta1.cmd('iw dev sta1-wlan0 connect new-ssid')
#sta2.cmd('iw dev sta2-wlan0 connect new-ssid')

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

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

if name == 'main': setLogLevel('info') topology()

ramonfontes commented 3 years ago

Fixed https://github.com/ramonfontes/containernet/commit/d5a59585920c676d893be53db52f50cd31de644c.

nomanmazhar commented 3 years ago

thanks a lot for your great support

Yes now every thing works perfect....

Best Regards Noman