Revision efc9a01c mininet/net.py

View differences:

mininet/net.py
81 81
from time import sleep
82 82

  
83 83
from mininet.cli import CLI
84
from mininet.log import info, error
84
from mininet.log import info, error, debug
85 85
from mininet.node import KernelSwitch, OVSKernelSwitch
86 86
from mininet.util import quietRun, fixLimits
87
from mininet.util import makeIntfPair, moveIntf, macColonHex
87
from mininet.util import createLink, macColonHex
88 88
from mininet.xterm import cleanUpScreens, makeXterms
89 89

  
90 90
DATAPATHS = [ 'kernel' ] #[ 'user', 'kernel' ]
......
150 150
           defaultIp: default IP address for intf 0
151 151
           returns: added host"""
152 152
        host = self.host( name )
153
        # for now, assume one interface per host.
154
        host.intfs.append( name + '-eth0' )
155 153
        self.hosts.append( host )
156 154
        self.nameToNode[ name ] = host
157 155
        # May wish to add this to actual object
......
175 173
        self.nameToNode[ name ] = sw
176 174
        return sw
177 175

  
178
    def addLink( self, src, srcPort, dst, dstPort ):
179
        """Add link.
180
           src: source Node
181
           srcPort: source port
182
           dst: destination Node
183
           dstPort: destination port"""
184
        srcIntf = src.intfName( srcPort )
185
        dstIntf = dst.intfName( dstPort )
186
        makeIntfPair( srcIntf, dstIntf )
187
        src.intfs.append( srcIntf )
188
        dst.intfs.append( dstIntf )
189
        src.ports[ srcPort ] = srcIntf
190
        dst.ports[ dstPort ] = dstIntf
191
        #info( '\n' )
192
        #info( 'added intf %s to src node %x\n' % ( srcIntf, src ) )
193
        #info( 'added intf %s to dst node %x\n' % ( dstIntf, dst ) )
194
        if src.inNamespace:
195
            #info( 'moving src w/inNamespace set\n' )
196
            moveIntf( srcIntf, src )
197
        if dst.inNamespace:
198
            #info( 'moving dst w/inNamespace set\n' )
199
            moveIntf( dstIntf, dst )
200
        src.connection[ srcIntf ] = ( dst, dstIntf )
201
        dst.connection[ dstIntf ] = ( src, srcIntf )
202

  
203 176
    def addController( self, controller ):
204 177
        """Add controller.
205 178
           controller: Controller class"""
......
315 288
        for srcId, dstId in sorted( topo.edges() ):
316 289
            src, dst = self.idToNode[ srcId ], self.idToNode[ dstId ]
317 290
            srcPort, dstPort = topo.port( srcId, dstId )
318
            self.addLink( src, srcPort, dst, dstPort )
291
            createLink( src, srcPort, dst, dstPort )
319 292
            info( '(%s, %s) ' % ( src.name, dst.name ) )
320 293
        info( '\n' )
321 294

  
......
368 341
            controller.start()
369 342
        info( '*** Starting %s switches\n' % len( self.switches ) )
370 343
        for switch in self.switches:
371
            info( switch.name )
344
            info( switch.name + ' ')
372 345
            switch.start( self.controllers )
373 346
        info( '\n' )
374 347

  
......
474 447
           l4Type: string, one of [ TCP, UDP ]
475 448
           verbose: verbose printing
476 449
           returns: results two-element array of server and client speeds"""
450
        log = info if verbose else debug
477 451
        if not hosts:
478 452
            hosts = [ self.hosts[ 0 ], self.hosts[ -1 ] ]
479 453
        else:
480 454
            assert len( hosts ) == 2
481 455
        host0, host1 = hosts
482
        info( '*** Iperf: testing ' + l4Type + ' bandwidth between ' )
483
        info( "%s and %s\n" % ( host0.name, host1.name ) )
456
        log( '*** Iperf: testing ' + l4Type + ' bandwidth between ' )
457
        log( "%s and %s\n" % ( host0.name, host1.name ) )
484 458
        host0.cmd( 'killall -9 iperf' )
485 459
        iperfArgs = 'iperf '
486 460
        bwArgs = ''
......
490 464
        elif l4Type != 'TCP':
491 465
            raise Exception( 'Unexpected l4 type: %s' % l4Type )
492 466
        server = host0.cmd( iperfArgs + '-s &' )
493
        if verbose:
494
            info( '%s\n' % server )
467
        log( '%s\n' % server )
495 468
        client = host1.cmd( iperfArgs + '-t 5 -c ' + host0.IP() + ' ' +
496 469
                           bwArgs )
497
        if verbose:
498
            info( '%s\n' % client )
470
        log( '%s\n' % client )
499 471
        server = host0.cmd( 'killall -9 iperf' )
500
        if verbose:
501
            info( '%s\n' % server )
472
        log( '%s\n' % server )
502 473
        result = [ self._parseIperf( server ), self._parseIperf( client ) ]
503 474
        if l4Type == 'UDP':
504 475
            result.insert( 0, udpBw )
505
        info( '*** Results: %s\n' % result )
476
        log( '*** Results: %s\n' % result )
506 477
        return result
507 478

  
508 479
    def iperfUdp( self, udpBw='10M' ):

Also available in: Unified diff