Search Mailing List Archives


Limit search to: Subject & Body Subject Author
Sort by: Reverse Sort
Limit to: All This Week Last Week This Month Last Month
Select Date Range     through    

[mininet-discuss] mininet not obeying to mac specification, when creating a host.

Carlos Ferreira carlosmf.pt at gmail.com
Wed Dec 21 10:29:01 PST 2016


Hello!

I have created a python program to create a testing topology.
For some reason, when I use the "addHost" method and use the argument
"mac" to specify the mac address for the host interface, mininet
ignores the provided mac address an seems to create and specify the
hosts with random mac addresses.
I do not know why this is happening...

This is my Python program
#### Starts here

#!/usr/bin/python2

"""
    Custom Network Topology

     2 different zones each controlled by a different Controller
     Each controller manages 3 OpenFlow switches
     Each OF Switch has 3 hosts connected
     Each zone has a triangle shaped topology, where all switches are
conected to the controller

     2 Switches from each zone, interconnect the two zones
      - Switch 2 from Zone 1 connects to the Switch 1 from Zone 2
      - Switch 3 from Zone 1 connects to the Switch 2 from Zone 2

     The two controllers are remote controllers, residing outside from
the mininet environment.

"""
from struct import pack
from mininet.net import Mininet
from mininet.node import RemoteController
from mininet.log import setLogLevel
from mininet.cli import CLI


def byteStr2HexStr(byteStr):
    return ''.join([str.format("{:02X}", ord(x)) for x in byteStr]).strip()

setLogLevel('info')


net = Mininet(build=False)

c1 = net.addController("c1", controller=RemoteController,
ip='192.168.1.254', port=6631)
c2 = net.addController("c2", controller=RemoteController,
ip='192.168.1.254', port=6632)

c1_s1 = net.addSwitch("c1_s1", protocols='OpenFlow13',
dpid=byteStr2HexStr(pack("!Q", 1)), mac='01:00:00:01:01:00')
c1_s2 = net.addSwitch("c1_s2", protocols='OpenFlow13',
dpid=byteStr2HexStr(pack("!Q", 2)), mac='01:00:00:01:02:00')
c1_s3 = net.addSwitch("c1_s3", protocols='OpenFlow13',
dpid=byteStr2HexStr(pack("!Q", 3)), mac='01:00:00:01:03:00')
c2_s1 = net.addSwitch("c2_s1", protocols='OpenFlow13',
dpid=byteStr2HexStr(pack("!Q", 4)), mac='01:00:00:02:01:00')
c2_s2 = net.addSwitch("c2_s2", protocols='OpenFlow13',
dpid=byteStr2HexStr(pack("!Q", 5)), mac='01:00:00:02:02:00')
c2_s3 = net.addSwitch("c2_s3", protocols='OpenFlow13',
dpid=byteStr2HexStr(pack("!Q", 6)), mac='01:00:00:02:03:00')
switches_c1 = [c1_s1, c1_s2, c1_s3]
switches_c2 = [c2_s1, c2_s2, c2_s3]


c1_s1_h1 = net.addHost("c1_s1_h1",
privateDirs=['/home/mininet/Scenarios/Hosts/{}'.format("c1_s1_h1")],
ip='0.0.0.0',  mac='01:00:00:01:01:01')
c1_s1_h2 = net.addHost("c1_s1_h2",
privateDirs=['/home/mininet/Scenarios/Hosts/{}'.format("c1_s1_h2")],
ip='0.0.0.0',  mac='01:00:00:01:01:02')
c1_s1_h3 = net.addHost("c1_s1_h3",
privateDirs=['/home/mininet/Scenarios/Hosts/{}'.format("c1_s1_h3")],
ip='0.0.0.0',  mac='01:00:00:01:01:03')
c1_s2_h1 = net.addHost("c1_s2_h1",
privateDirs=['/home/mininet/Scenarios/Hosts/{}'.format("c1_s2_h1")],
ip='0.0.0.0',  mac='01:00:00:01:02:01')
c1_s2_h2 = net.addHost("c1_s2_h2",
privateDirs=['/home/mininet/Scenarios/Hosts/{}'.format("c1_s2_h2")],
ip='0.0.0.0',  mac='01:00:00:01:02:02')
c1_s2_h3 = net.addHost("c1_s2_h3",
privateDirs=['/home/mininet/Scenarios/Hosts/{}'.format("c1_s2_h3")],
ip='0.0.0.0',  mac='01:00:00:01:02:03')
c1_s3_h1 = net.addHost("c1_s3_h1",
privateDirs=['/home/mininet/Scenarios/Hosts/{}'.format("c1_s3_h1")],
ip='0.0.0.0',  mac='01:00:00:01:03:01')
c1_s3_h2 = net.addHost("c1_s3_h2",
privateDirs=['/home/mininet/Scenarios/Hosts/{}'.format("c1_s3_h2")],
ip='0.0.0.0',  mac='01:00:00:01:03:02')
c1_s3_h3 = net.addHost("c1_s3_h3",
privateDirs=['/home/mininet/Scenarios/Hosts/{}'.format("c1_s3_h3")],
ip='0.0.0.0',  mac='01:00:00:01:03:03')

c2_s1_h1 = net.addHost("c1_s1_h1",
privateDirs=['/home/mininet/Scenarios/Hosts/{}'.format("c2_s1_h1")],
ip='0.0.0.0',  mac='01:00:00:02:01:01')
c2_s1_h2 = net.addHost("c1_s1_h2",
privateDirs=['/home/mininet/Scenarios/Hosts/{}'.format("c2_s1_h2")],
ip='0.0.0.0',  mac='01:00:00:02:01:02')
c2_s1_h3 = net.addHost("c1_s1_h3",
privateDirs=['/home/mininet/Scenarios/Hosts/{}'.format("c2_s1_h3")],
ip='0.0.0.0',  mac='01:00:00:02:01:03')
c2_s2_h1 = net.addHost("c1_s2_h1",
privateDirs=['/home/mininet/Scenarios/Hosts/{}'.format("c2_s2_h1")],
ip='0.0.0.0',  mac='01:00:00:02:02:01')
c2_s2_h2 = net.addHost("c1_s2_h2",
privateDirs=['/home/mininet/Scenarios/Hosts/{}'.format("c2_s2_h2")],
ip='0.0.0.0',  mac='01:00:00:02:02:02')
c2_s2_h3 = net.addHost("c1_s2_h3",
privateDirs=['/home/mininet/Scenarios/Hosts/{}'.format("c2_s2_h3")],
ip='0.0.0.0',  mac='01:00:00:02:02:03')
c2_s3_h1 = net.addHost("c1_s3_h1",
privateDirs=['/home/mininet/Scenarios/Hosts/{}'.format("c2_s3_h1")],
ip='0.0.0.0',  mac='01:00:00:02:03:01')
c2_s3_h2 = net.addHost("c1_s3_h2",
privateDirs=['/home/mininet/Scenarios/Hosts/{}'.format("c2_s3_h2")],
ip='0.0.0.0',  mac='01:00:00:02:03:02')
c2_s3_h3 = net.addHost("c1_s3_h3",
privateDirs=['/home/mininet/Scenarios/Hosts/{}'.format("c2_s3_h3")],
ip='0.0.0.0',  mac='01:00:00:02:03:03')
hosts = [c1_s1_h1, c1_s1_h2, c1_s1_h3, c1_s2_h1, c1_s2_h2, c1_s2_h3,
c1_s3_h1, c1_s3_h2, c1_s3_h3, c2_s1_h1, c2_s1_h2, c2_s1_h3, c2_s2_h1,
c2_s2_h2, c2_s2_h3, c2_s3_h1, c2_s3_h2, c2_s3_h3]


net.addLink(c1_s1_h1, c1_s1)
net.addLink(c1_s1_h2, c1_s1)
net.addLink(c1_s1_h3, c1_s1)
net.addLink(c1_s2_h1, c1_s2)
net.addLink(c1_s2_h2, c1_s2)
net.addLink(c1_s2_h3, c1_s2)
net.addLink(c1_s3_h1, c1_s3)
net.addLink(c1_s3_h2, c1_s3)
net.addLink(c1_s3_h3, c1_s3)

net.addLink(c2_s1_h1, c2_s1)
net.addLink(c2_s1_h2, c2_s1)
net.addLink(c2_s1_h3, c2_s1)
net.addLink(c2_s2_h1, c2_s2)
net.addLink(c2_s2_h2, c2_s2)
net.addLink(c2_s2_h3, c2_s2)
net.addLink(c2_s3_h1, c2_s3)
net.addLink(c2_s3_h2, c2_s3)
net.addLink(c2_s3_h3, c2_s3)

net.addLink(c1_s2, c2_s1)
net.addLink(c1_s3, c2_s2)

net.build()

for switch in switches_c1:
    switch.start([c1])

for switch in switches_c2:
    switch.start([c2])

for host in hosts:
    host.cmdPrint("dhclient {} &".format(host.defaultIntf().name))

CLI(net)
net.stop()
### Ends Here.


I start this program, named "testing_scenario.py", inside the Ubuntu
VM provided in the mininet website, by using the following console
command:
sudo ./testing_scenario.py




-- 

Carlos Miguel Ferreira
Researcher at Telecommunications Institute
Aveiro - Portugal
Work E-mail - cmf at av.it.pt
Skype & GTalk -> carlosmf.pt at gmail.com
LinkedIn -> http://www.linkedin.com/in/carlosmferreira


More information about the mininet-discuss mailing list