Giuseppe1992 / Distrinet

Distributed Network emulator, based on Mininet
MIT License
17 stars 16 forks source link

create a switch with more than 40 links blocks the emulations #62

Open Giuseppe1992 opened 4 years ago

Giuseppe1992 commented 4 years ago

If the network contains a switch that has more than 40 links, it blocks the creation of the network. I tried with a star network with 41 switches.

My guess is that the ssh command used to start the switch is too long.

Distrinet/mininet/mininet/cloudswitch.py

    def vsctl( self, *args, **kwargs ):
        "Run ovs-vsctl command (or queue for later execution)"
        if self.batch:
            cmd = ' '.join( str( arg ).strip() for arg in args )
            self.commands.append( cmd )
        else:
            return self.cmd( 'ovs-vsctl', *args, **kwargs )

...

    def start( self, controllers ):
        "Start up a new OVS OpenFlow switch using ovs-vsctl"
        int( self.dpid, 16 )  # DPID must be a hex string
        # Command to add interfaces
        intfs = ''.join( ' -- add-port %s %s' % ( self, intf ) +
                         self.intfOpts( intf )
                         for intf in self.intfList()
                         if self.ports[ intf ] and not intf.IP() )
        # Command to create controller entries
        clist = [ ( self.name + c.name, '%s:%s:%d' %
                  ( c.protocol, c.IP(), c.port ) )
                  for c in controllers ]
        if self.listenPort:
            clist.append( ( self.name + '-listen',
                            'ptcp:%s' % self.listenPort ) )
        ccmd = '-- --id=@%s create Controller target=\\"%s\\"'
        if self.reconnectms:
            ccmd += ' max_backoff=%d' % self.reconnectms
        cargs = ' '.join( ccmd % ( name, target )
                          for name, target in clist )
        # Controller ID list
        cids = ','.join( '@%s' % name for name, _target in clist )
        # Try to delete any existing bridges with the same name
        if not self.isOldOVS():
            cargs += ' -- --if-exists del-br %s' % self
        # One ovs-vsctl command to rule them all!
        self.vsctl( cargs +
                    ' -- add-br %s' % self +
                    ' -- set bridge %s controller=[%s]' % ( self, cids  ) +
                    self.bridgeOpts() +
                    intfs )
        # If necessary, restore TC config overwritten by OVS
        if not self.batch:
            for intf in self.intfList():
                self.TCReapply( intf )

in my case the *args parameter in the vsctl function is:

"-- --id=@s1c0 create Controller target=\"tcp:192.168.0.1:6653\" max_backoff=1000 -- --id=@s1-listen create Controller target=\"ptcp:6654\" max_backoff=1000 -- --if-exists del-br s1 -- add-br s1 -- set bridge s1 controller=[@s1c0,@s1-listen] other_config:datapath-id=0000000000000001 fail_mode=secure other-config:disable-in-band=true other-config:dp-desc=s1 -- add-port s1 s1-eth1 -- set Interface s1-eth1 ofport_request=1 -- add-port s1 s1-eth2 -- set Interface s1-eth2 ofport_request=2 -- add-port s1 s1-eth3 -- set Interface s1-eth3 ofport_request=3 -- add-port s1 s1-eth4 -- set Interface s1-eth4 ofport_request=4 -- add-port s1 s1-eth5 -- set Interface s1-eth5 ofport_request=5 -- add-port s1 s1-eth6 -- set Interface s1-eth6 ofport_request=6 -- add-port s1 s1-eth7 -- set Interface s1-eth7 ofport_request=7 -- add-port s1 s1-eth8 -- set Interface s1-eth8 ofport_request=8 -- add-port s1 s1-eth9 -- set Interface s1-eth9 ofport_request=9 -- add-port s1 s1-eth10 -- set Interface s1-eth10 ofport_request=10 -- add-port s1 s1-eth11 -- set Interface s1-eth11 ofport_request=11 -- add-port s1 s1-eth12 -- set Interface s1-eth12 ofport_request=12 -- add-port s1 s1-eth13 -- set Interface s1-eth13 ofport_request=13 -- add-port s1 s1-eth14 -- set Interface s1-eth14 ofport_request=14 -- add-port s1 s1-eth15 -- set Interface s1-eth15 ofport_request=15 -- add-port s1 s1-eth16 -- set Interface s1-eth16 ofport_request=16 -- add-port s1 s1-eth17 -- set Interface s1-eth17 ofport_request=17 -- add-port s1 s1-eth18 -- set Interface s1-eth18 ofport_request=18 -- add-port s1 s1-eth19 -- set Interface s1-eth19 ofport_request=19 -- add-port s1 s1-eth20 -- set Interface s1-eth20 ofport_request=20 -- add-port s1 s1-eth21 -- set Interface s1-eth21 ofport_request=21 -- add-port s1 s1-eth22 -- set Interface s1-eth22 ofport_request=22 -- add-port s1 s1-eth23 -- set Interface s1-eth23 ofport_request=23 -- add-port s1 s1-eth24 -- set Interface s1-eth24 ofport_request=24 -- add-port s1 s1-eth25 -- set Interface s1-eth25 ofport_request=25 -- add-port s1 s1-eth26 -- set Interface s1-eth26 ofport_request=26 -- add-port s1 s1-eth27 -- set Interface s1-eth27 ofport_request=27 -- add-port s1 s1-eth28 -- set Interface s1-eth28 ofport_request=28 -- add-port s1 s1-eth29 -- set Interface s1-eth29 ofport_request=29 -- add-port s1 s1-eth30 -- set Interface s1-eth30 ofport_request=30 -- add-port s1 s1-eth31 -- set Interface s1-eth31 ofport_request=31 -- add-port s1 s1-eth32 -- set Interface s1-eth32 ofport_request=32 -- add-port s1 s1-eth33 -- set Interface s1-eth33 ofport_request=33 -- add-port s1 s1-eth34 -- set Interface s1-eth34 ofport_request=34 -- add-port s1 s1-eth35 -- set Interface s1-eth35 ofport_request=35 -- add-port s1 s1-eth36 -- set Interface s1-eth36 ofport_request=36 -- add-port s1 s1-eth37 -- set Interface s1-eth37 ofport_request=37 -- add-port s1 s1-eth38 -- set Interface s1-eth38 ofport_request=38 -- add-port s1 s1-eth39 -- set Interface s1-eth39 ofport_request=39 -- add-port s1 s1-eth40 -- set Interface s1-eth40 ofport_request=40"
dsaucez commented 4 years ago

Hum, I don't think it is a problem with bash, @Giuseppe1992 what's the result of

getconf ARG_MAX

on the machines you are using?

Giuseppe1992 commented 4 years ago
giuseppe@MacBook-Pro-di-Giuseppe ~ % getconf ARG_MAX
262144
dsaucez commented 4 years ago

ok, so much bigger than the number of bytes in your example.

can you try with the code:

    def start( self, controllers ):
        "Start up a new OVS OpenFlow switch using ovs-vsctl"
        int( self.dpid, 16 )  # DPID must be a hex string
        # Command to create controller entries
        clist = [ ( self.name + c.name, '%s:%s:%d' %
                  ( c.protocol, c.IP(), c.port ) )
                  for c in controllers ]
        if self.listenPort:
            clist.append( ( self.name + '-listen',
                            'ptcp:%s' % self.listenPort ) )
        ccmd = '-- --id=@%s create Controller target=\\"%s\\"'
        if self.reconnectms:
            ccmd += ' max_backoff=%d' % self.reconnectms
        cargs = ' '.join( ccmd % ( name, target )
                          for name, target in clist )
        # Controller ID list
        cids = ','.join( '@%s' % name for name, _target in clist )
        # Try to delete any existing bridges with the same name
        if not self.isOldOVS():
            cargs += ' -- --if-exists del-br %s' % self
        # One ovs-vsctl command to rule them all!
        self.vsctl( cargs +
                    ' -- add-br %s' % self +
                    ' -- set bridge %s controller=[%s]' % ( self, cids  ) +
                    self.bridgeOpts() +
                    intfs )

        # Command to add interfaces
        for intf in self.intfList():
                if self.ports[ intf ] and not intf.IP():
                    cmd = ' -- add-port %s %s' % ( self, intf )                 
                    cmd = cmd + self.intfOpts( intf )
                    self.vsctl( cmd )

        # If necessary, restore TC config overwritten by OVS
        if not self.batch:
            for intf in self.intfList():
                self.TCReapply( intf )