<s> """<STR_LIT>""" <EOL> from mininet . net import Mininet <EOL> from mininet . node import Controller <EOL> from mininet . log import setLogLevel , info , warn <EOL> def validatePort ( switch , intf ) : <EOL> "<STR_LIT>" <EOL> ofport = int ( switch . cmd ( '<STR_LIT>' , intf , <EOL> '<STR_LIT>' ) ) <EOL> if ofport != switch . ports [ intf ] : <EOL> warn ( '<STR_LIT>' , intf , '<STR_LIT>' , ofport , '<STR_LIT:\n>' ) <EOL> return <NUM_LIT:0> <EOL> else : <EOL> return <NUM_LIT:1> <EOL> def testPortNumbering ( ) : <EOL> """<STR_LIT>""" <EOL> net = Mininet ( controller = Controller ) <EOL> info ( '<STR_LIT>' ) <EOL> net . addController ( '<STR_LIT>' ) <EOL> info ( '<STR_LIT>' ) <EOL> h1 = net . addHost ( '<STR_LIT>' , ip = '<STR_LIT>' ) <EOL> h2 = net . addHost ( '<STR_LIT>' , ip = '<STR_LIT>' ) <EOL> h3 = net . addHost ( '<STR_LIT>' , ip = '<STR_LIT>' ) <EOL> h4 = net . addHost ( '<STR_LIT>' , ip = '<STR_LIT>' ) <EOL> h5 = net . addHost ( '<STR_LIT>' , ip = '<STR_LIT>' ) <EOL> info ( '<STR_LIT>' ) <EOL> s1 = net . addSwitch ( '<STR_LIT>' ) <EOL> info ( '<STR_LIT>' ) <EOL> net . addLink ( h1 , s1 ) <EOL> net . addLink ( h2 , s1 ) <EOL> net . addLink ( h3 , s1 ) <EOL> net . addLink ( h4 , s1 ) <EOL> net . addLink ( h5 , s1 , port1 = <NUM_LIT:1> , port2 = <NUM_LIT:9> ) <EOL> info ( '<STR_LIT>' ) <EOL> net . start ( ) <EOL> info ( '<STR_LIT>' <EOL> '<STR_LIT>' ) <EOL> for intfs in s1 . intfList ( ) : <EOL> if not intfs . name == "<STR_LIT>" : <EOL> info ( intfs , '<STR_LIT>' , s1 . ports [ intfs ] , <EOL> '<STR_LIT:\n>' ) <EOL> info ( '<STR_LIT>' , intfs , <EOL> '<STR_LIT>' , s1 . ports [ intfs ] , '<STR_LIT>' ) <EOL> if validatePort ( s1 , intfs ) : <EOL> info ( '<STR_LIT>' ) <EOL> print '<STR_LIT:\n>' <EOL> net . pingAll ( ) <EOL> print '<STR_LIT:\n>' <EOL> info ( '<STR_LIT>' ) <EOL> net . stop ( ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> setLogLevel ( '<STR_LIT:info>' ) <EOL> testPortNumbering ( ) </s>
