• Nenhum resultado encontrado

189 t r u e com um time ( ARP_TIMEOUT ) . Quanto ao seu d e s t i n o e l e e dado uma tag de F a l s e e

190 um time ( 5 ) , se em 5 segundos e l e nao e n c o n t r a r o ip , este pacote e ignorado , p o i s e l e

191 nao e x i s t e na rede .

192 " " "

193 #anotado o i p de f o n t e

194 s e l f . t a b l e _ i p [ packet_eth . next . p r o t o s r c ] = ( True , time . time ( ) + ARP_TIMEOUT )

195 #se o i p de d e s t i n o e s t i v e r na t a b e l a

196 i f packet_eth . next . p r o t o d s t i n s e l f . t a b l e _ i p :

197 #se o i p de d e s t i n o f o r f a l s e

198 i f not s e l f . t a b l e _ i p [ packet_eth . next . p r o t o d s t ] [ 0 ] :

199 #se o time dele e x p i r o u

200 i f time . time ( ) > s e l f . t a b l e _ i p [ packet_eth . next . p r o t o d s t ] [ 1 ] :

201 l o g . warning ("O host com i p %s nao pode s e r encontrado

na rede ", packet_eth . next . p r o t o d s t )

202 r e t u r n

203 e l s e:

204 #se o i p de d e s t i n o e x p i r o u

205 i f time . time ( ) > s e l f . t a b l e _ i p [ packet_eth . next . p r o t o d s t ] [ 1 ] :

206 #seta e l e como f a l s e

207 s e l f . t a b l e _ i p [ packet_eth . next . p r o t o d s t ] = ( False , s e l f . t a b l e _ i p [ packet_eth . next . p r o t o d s t ] [ 1 ] )

208 e l s e:#se o i p de d e s t i n o nao e s t i v e r na t a b e l a

209 s e l f . t a b l e _ i p [ packet_eth . next . p r o t o d s t ] = ( False , time . time ( ) + 5)

210 #so entao e executado o p r o t o c o l o ARP

211 s e l f . arp_responder ( p a c k e t _ i n , packet_eth , dpid )

212 e l s e:

213 l o g . debug (" Chegou um pacote I P no s w i t c h %s ", d p i d T o S t r ( event . dpid ) )

214 #executado o p r o t o c o l o de roteamento

215 s e l f . r o u t e ( p a c k e t _ i n , packet_eth , dpid )

216 r e t u r n

217

218 def launch ( ) :

219

220 def s t a r t _ s w i t c h ( event ) :

221 Router ( event . connection )# enviamos a conexao do evento para a

c l a s s e

222 core . openflow . addListenerByName (" ConnectionUp ", s t a r t _ s w i t c h )

codigos/router.py

1 from pox . core import core

2 from pox . l i b . u t i l import d p i d T o S t r

3 import pox . openflow . l i b o p e n f l o w _ 0 1 as o f

4 import pox . l i b . packet as pkt

5 import pox

6 from pox . l i b . packet . e t h e r n e t import e t h e r n e t

7 from pox . l i b . packet . ipv4 import ipv4

8 from pox . l i b . packet . arp import arp

9 10

11 #tempos para a i n s t a l a c a o de f l u x o s

12 FLOW_IDLE_TIMEOUT = o f . OFP_FLOW_PERMANENT

13 FLOW_HARD_TIMEOUT = o f . OFP_FLOW_PERMANENT

14

15 l o g = core . getLogger ( )

16

17 c l a s s E s p e c i f i c o ( o b j e c t ) :

18 def _ _ i n i t _ _ ( s e l f , connection ) :

19 s e l f . connection = connection

20 connection . a d d L i s t e n e r s ( s e l f )

21

22 def i n s t a l l _ f l o w ( s e l f , d l _ t y p e , nw_dst , p a c k e t _ i n , packet , p o r t ) :

23 " " "

24 metodo que i n s t a l a f l u x o s na t a b e l a de f l u x o s do comutador

25 " " "

26 i f p o r t == 65531:

27 l o g . debug (" I n s t a l a n d o f l u x o para todas as p o r t a s ")

28 e l s e:

29 l o g . debug (" I n s t a l a n d o f l u x o para a p o r t a %i " % p o r t )

30 msg = o f . ofp_flow_mod ( )

31 msg . match . d l _ t y p e = d l _ t y p e

32 msg . match . nw_dst = nw_dst

33 msg . match . i n _ p o r t = p a c k e t _ i n . i n _ p o r t

34 msg . match . d l _ t y p e = packet . type

35 msg . match . d l _ s r c = packet . s r c

36 msg . i d l e _ t i m e o u t = FLOW_IDLE_TIMEOUT#v e j a os tempo acima

37 msg . hard_timeout = FLOW_HARD_TIMEOUT#v e j a os tempo acima

38 i f p a c k e t _ i n . b u f f e r _ i d != −1 and p a c k e t _ i n . b u f f e r _ i d i s not None :

39 msg . b u f f e r _ i d = p a c k e t _ i n . b u f f e r _ i d

40 e l s e:

41 i f p a c k e t _ i n . data i s None :

42 r e t u r n

43 msg . data = p a c k e t _ i n . data

44 msg . a c t i o n s . append ( o f . o f p _ a c t i o n _ o u t p u t ( p o r t = p o r t ) )

45 s e l f . connection . send (msg)

46 r e t u r n

47

48 def i n s t a l l _ r u l e s ( s e l f , p a c k e t _ i n , packet ) :

49 " " "

50 metodo que i n s t a l a r e g r a s na rede toda

51 este componente so f u n c i o n a r a exclusivamente para essa rede , e um componente bem

52 e s p e c i f i c o que j a tem determinado suas p o r t a s de entrada e s a i d a como numero de h o s t s

53 e i p dos mesmos . Serve como exemplo de como c o n t r o l a r o f l u x o da rede .

54

55 Este componente ( j u n t o com este metodo ) f u n c i o n a em um c e n a r i o com t r e s s w i t c h e s l i g a d o s

56 e n t r e s i , cada um em sua subrede ( 1 0 . 0 . 1 . x ; 1 0 . 0 . 2 . x ; 1 0 . 0 . 3 . x ) , cada um com d o i s h o s t s

57 l i g a d o s nas p o r t a s 1 e 2 com i p s 1 0 . 0 . X . 2 ; 1 0 . 0 . X . 3 .

58 s0 l i g a d o a s1 pela p o r t a 3

59 s0 l i g a d o a s2 pela p o r t a 4

60 s1 l i g a d o a s0 pela p o r t a 3

61 s1 l i g a d o a s2 pela p o r t a 4

62 s2 l i g a d o a s0 pela p o r t a 3

63 s2 l i g a d o a s1 pela p o r t a 4

64 F lu xo de p o r t a d e s t i n o tcp 1234 sera comutado por s0 e s1 exclusivamente p e l a s p o r t a s 3 e 3

65 de cada switch , os demais pacotes nao poderao usar este caminho para f l u x o de dados , todos os dados

66 deverao c o n t o r n a r a rede . ( Ex . f l u x o normal de s0 para s1 devera passar por s2 )

67 " " "

68 #pega o proximo cabecaolho

69 p=packet . next

70 #v e r i f i c a se o pacote e ipv4 ou arp e pega seus i p s

71 i f i s i n s t a n c e ( p , ipv4 ) :

72 nw_src = p . s r c i p

73 nw_dst = p . d s t i p

74 d l _ t y p e = 0x0800

75 p = p . next

76 e l i f i s i n s t a n c e ( p , arp ) :

77 i f p . opcode <= 255:

78 nw_src = p . p r o t o s r c

79 nw_dst = p . p r o t o d s t

80 d l _ t y p e = 0x0806

81 e l s e:

82 r e t u r n

83 #sendo qualquer o u t r a c o i s a r e t o r n a

84 e l s e:

85 r e t u r n

86 #comeca as a t r i b u i c o e s de caminho

87 i f ( s t r ( nw_dst ) . s p l i t (’ . ’) ) [ 2 ] != ( s t r ( nw_src ) . s p l i t ( ’ . ’) ) [ 2 ] :

88 #esse caso e quando o d e s t i n o nao e l o c a l

89 i f ( s t r ( nw_src ) . s p l i t (’ . ’) ) [ 2 ] == " 1 ":

90 #esse caso e quando a f o n t e e de s0

91 i f p a c k e t _ i n . i n _ p o r t == 1 or p a c k e t _ i n . i n _ p o r t == 2 :#t a no s0 mesmo

92 i f packet . f i n d (" tcp ") != None and ( packet . f i n d (" tcp ") . d s t p o r t == 1234 or packet . f i n d (" tcp ") . s r c p o r t == 1234) :

93 i f ( s t r ( nw_dst ) . s p l i t (’ . ’) ) [ 2 ] == " 2 ":#se o d e s t i n o e s1

94 s e l f . i n s t a l l _ f l o w ( d l _ t y p e , nw_dst , p a c k e t _ i n , packet , 3)

95 r e t u r n

96 e l s e:#o d e s t i n o e s2

97 s e l f . i n s t a l l _ f l o w ( d l _ t y p e , nw_dst , p a c k e t _ i n , packet , 4)

98 r e t u r n

99 e l s e:

100 s e l f . i n s t a l l _ f l o w ( d l _ t y p e , nw_dst , p a c k e t _ i n , packet , 4)

101 r e t u r n

102 e l i f p a c k e t _ i n . i n _ p o r t == 4 :#t a no s1 d e s t i n o do s1

103 i f ( s t r ( nw_dst ) . s p l i t (’ . ’) ) [ 3 ] == " 2 ":

104 s e l f . i n s t a l l _ f l o w ( d l _ t y p e , nw_dst , p a c k e t _ i n , packet , 1)

105 r e t u r n

106 e l s e:

107 s e l f . i n s t a l l _ f l o w ( d l _ t y p e , nw_dst , p a c k e t _ i n , packet , 2)

108 r e t u r n

109 e l s e:#t a no s2 ou no s1 ( tcp p o r t 1234)

110 i f ( s t r ( nw_dst ) . s p l i t (’ . ’) ) [ 2 ] == " 3 ":#se o d e s t i n o e de s2

111 i f ( s t r ( nw_dst ) . s p l i t (’ . ’) ) [ 3 ] == " 2 ":#se o d e s t i n o e de 3.2

112 s e l f . i n s t a l l _ f l o w ( d l _ t y p e , nw_dst , p a c k e t _ i n , packet , 1)

113 r e t u r n

114 e l s e:

115 s e l f . i n s t a l l _ f l o w ( d l _ t y p e , nw_dst , p a c k e t _ i n , packet , 2)

116 r e t u r n

117 e l s e:#d e s t i n o nao e de s2 entao e de s1

118 #se e l e tem a p o r t tcp 1234 e f o n t e s0 entao e l e chegou pela p o r t a 3 e j a esta no s1

119 i f packet . f i n d (" tcp ") != None and ( packet . f i n d (" tcp ") . d s t p o r t == 1234 or packet . f i n d (" tcp ") . s r c p o r t ==

1234) :

120 i f ( s t r ( nw_dst ) . s p l i t (’ . ’) ) [ 3 ] == " 2 ":# se o d e s t i n o e 2.2

121 s e l f . i n s t a l l _ f l o w ( d l _ t y p e , nw_dst , p a c k e t _ i n , packet , 1)

122 r e t u r n

123 e l s e:#se o d e s t i n o e 2.3

124 s e l f . i n s t a l l _ f l o w ( d l _ t y p e , nw_dst , p a c k e t _ i n , packet , 2)

125 r e t u r n

126 e l s e:#f o n t e s0 passando pelo s2 com d e s t i n o a s1

127 s e l f . i n s t a l l _ f l o w ( d l _ t y p e , nw_dst , p a c k e t _ i n , packet , 4)

128 r e t u r n

129 e l i f ( s t r ( nw_src ) . s p l i t (’ . ’) ) [ 2 ] == " 2 ":

130 #esse caso e quando a f o n t e e de s1

131 i f p a c k e t _ i n . i n _ p o r t == 1 or p a c k e t _ i n . i n _ p o r t == 2 :#t a no s1 mesmo

132 i f packet . f i n d (" tcp ") != None and ( packet . f i n d (" tcp ") . d s t p o r t == 1234 or packet . f i n d (" tcp ") . s r c p o r t == 1234) :

133 i f ( s t r ( nw_dst ) . s p l i t (’ . ’) ) [ 2 ] == " 1 ":#se o d e s t i n o e s0

134 s e l f . i n s t a l l _ f l o w ( d l _ t y p e , nw_dst , p a c k e t _ i n , packet , 3)

135 r e t u r n

136 e l s e:#o d e s t i n o e s2

137 s e l f . i n s t a l l _ f l o w ( d l _ t y p e , nw_dst , p a c k e t _ i n , packet , 4)

138 r e t u r n

139 e l s e:

140 s e l f . i n s t a l l _ f l o w ( d l _ t y p e , nw_dst , p a c k e t _ i n , packet , 4)

141 r e t u r n

142 e l i f p a c k e t _ i n . i n _ p o r t == 4 :#pode s e r o s0 ou o s2 inunda

143 s e l f . i n s t a l l _ f l o w ( d l _ t y p e , nw_dst , p a c k e t _ i n , packet , o f . OFPP_FLOOD )

144 e l s e:

145 i f ( s t r ( nw_dst ) . s p l i t (’ . ’) ) [ 2 ] == " 1 ":#se o d e s t i n o e s0

146 i f ( s t r ( nw_dst ) . s p l i t (’ . ’) ) [ 3 ] == " 2 ":#se o d e s t i n o e 1.2

147 s e l f . i n s t a l l _ f l o w ( d l _ t y p e , nw_dst , p a c k e t _ i n , packet , 1)

148 r e t u r n

149 e l s e:

150 s e l f . i n s t a l l _ f l o w ( d l _ t y p e , nw_dst , p a c k e t _ i n , packet , 2)

151 r e t u r n

152 e l s e:

153 r e t u r n

154 e l i f ( s t r ( nw_src ) . s p l i t (’ . ’) ) [ 2 ] == " 3 ":

155 #esse caso e quando a f o n t e e de s2

156 i f p a c k e t _ i n . i n _ p o r t == 1 or p a c k e t _ i n . i n _ p o r t == 2 :#t a no s2 mesmo

157 i f ( s t r ( nw_dst ) . s p l i t (’ . ’) ) [ 2 ] == " 1 ":

158 s e l f . i n s t a l l _ f l o w ( d l _ t y p e , nw_dst , p a c k e t _ i n , packet , 3)

159 r e t u r n

160 e l s e:

161 s e l f . i n s t a l l _ f l o w ( d l _ t y p e , nw_dst , p a c k e t _ i n , packet , 4)

162 r e t u r n

163 e l i f p a c k e t _ i n . i n _ p o r t == 4 :#pode s e r o s0 ou o s1 inunda

164 s e l f . i n s t a l l _ f l o w ( d l _ t y p e , nw_dst , p a c k e t _ i n , packet , o f . OFPP_FLOOD )

165 r e t u r n

166 e l s e:

167 r e t u r n

168 e l s e:

169 r e t u r n

170 #esse caso e quando o d e s t i n o e l o c a l , bastando o l h a r seu d e s t i n o ( u l t i m o q u a r t e t o do i p )

171 e l i f ( s t r ( nw_dst ) . s p l i t (’ . ’) ) [ 3 ] == " 2 ":#para a p o r t a 1

172 s e l f . i n s t a l l _ f l o w ( d l _ t y p e , nw_dst , p a c k e t _ i n , packet , 1)

173 r e t u r n

174 e l i f ( s t r ( nw_dst ) . s p l i t (’ . ’) ) [ 3 ] == " 3 ":#para a p o r t a 2

175 s e l f . i n s t a l l _ f l o w ( d l _ t y p e , nw_dst , p a c k e t _ i n , packet , 2)

176 r e t u r n

177 #qualquer o u t r o caso r e t o r n a

178 e l s e:

179 r e t u r n

180

181 def _ h a n d l e _ P a c k e t I n ( s e l f , event ) :

182 " " "

183 E s c u l t a as mensagens P a c k e t I n da rede

184 " " "

185 packet_eth = event . parsed

186 p a c k e t _ i n = event . ofp

187

188 i f not packet_eth . parsed :

189 l o g . warning (" Pacote f o i ignorado p o i s nao ha cabecalhos ")

190 r e t u r n

191

192 i f packet_eth . type == e t h e r n e t . LLDP_TYPE :

193 # I g n o r a pacote LLDP

194 r e t u r n

195

196 #i n s t a l a as r e g r a s a medida que os pacotes chegam no comutador e vao para o c o n t r o l a d o r

197 s e l f . i n s t a l l _ r u l e s ( p a c k e t _ i n , packet_eth )

198 r e t u r n

199

200 def launch ( ) :

201

202 def s t a r t _ s w i t c h ( event ) :

203 E s p e c i f i c o ( event . connection )# enviamos a conexao do evento para a c l a s s e

204 core . openflow . addListenerByName (" ConnectionUp ", s t a r t _ s w i t c h )

codigos/especifico.py

Apêndice C

API MiniNet (MiniGUI)

Este é o código utilizado para a criação da API MiniGUI criada neste trabalho que tem como objetivo fornecer uma interface gráfica para a inicialização do CLI do Mi-niNet. Caso tenha alguma dúvida sobre as opções de inicialização do CLI do MiniNet consulte o capitulo 6. A interface mostra as opções de inicialização do CLI do MiniNet e inicia o CLI no Shell. Pode ser útil para quem começa a utilizar o MiniNet e não conhece ou lembra todas as opções de inicialização.

Para executar esta API, crie um arquivo com o nome de minigui.py no diretório mininet/examples (por exemplo) e execute-o na máquina virtual da seguinte ma-neira:

$ sudo python -O /mininet/examples/minigui.py

Pode-se utilizar para entender melhor a estrutura do MiniNet. Esta interface grá-fica foi criada com a utilização da bibliotecaTkinterdo Python, seu código pode ser visto a seguir. A interface é auto explicativa (Figura C.1).

1 " " "

2 THE MININET GUI

3 author : Lucas Costa ( l u c a s r c . rodri@gmail . com)

4 " " "

5 import os

6 import commands

7 import sys

8 from m i n i n e t . cl e an import cleanup

9 from m i n i n e t . c l i import C L I

10 from m i n i n e t . l o g import lg , LEVELS , i n f o , s e t L o g L e v e l

11 from m i n i n e t . net import M i n i n e t , i n i t

12 from m i n i n e t . node import KernelSwitch , Host , C o n t r o l l e r , C o n t r o l l e r P a r a m s , NOX

13 from m i n i n e t . node import RemoteController , UserSwitch , OVSKernelSwitch

14 from m i n i n e t . topo import SingleSwitchTopo , LinearTopo , SingleSwitchReversedTopo

15 from m i n i n e t . t o p o l i b import TreeTopo

16 from m i n i n e t . u t i l import makeNumeric

Figura C.1: MiniGUI API minigui.py (API de inicialização do CLI do MiniNet).

17 from T k i n t e r import

18 from t k F i l e D i a l o g import askopenfilename

19

20 c l a s s c u r r y :

21 def _ _ i n i t _ _ ( s e l f , fun , args , ∗∗kwargs ) :

22 s e l f . fun = fun

23 s e l f . pending = args [ : ]

24 s e l f . kwargs = kwargs . copy ( )

25 def _ _ c a l l _ _ ( s e l f , args , ∗∗kwargs ) :

26 i f kwargs and s e l f . kwargs :

27 kw = s e l f . kwargs . copy ( )

28 kw . update ( kwargs )

29 e l s e:

30 kw = kwargs or s e l f . kwargs

31 r e t u r n s e l f . fun (( s e l f . pending + args ) , ∗∗kw )

32

33 def event_lambda ( f , args , ∗∗kwds ) :

34 r e t u r n lambda event , f=f , args=args , kwds=kwds : f ( args , ∗∗kwds )

35

36 c l a s s MiniNetGui :

37 def _ _ i n i t _ _ ( s e l f , parent ) :

38 s e l f . m i n i n e t = None

39 s e l f . c o n t r o l l e r = I n t V a r ( )

40 s e l f . s w i t c h = I n t V a r ( )

41 s e l f . t o p o l og y = I n t V a r ( )

42 s e l f . s c r i p t = I n t V a r ( )

43 s e l f . xterm = I n t V a r ( )

44 s e l f . c o n t r o l l e r = 1

45 s e l f . s w i t c h = 2

46 s e l f . t o p o l og y = 3

47 s e l f . s c r i p t = 10

48 s e l f . xterm = 20

49 s e l f . mac = 31

50 s e l f . ping = 40

51 s e l f . i p e r f = 50

52 s e l f . f i l e n a m e _ t o p o = None

53 s e l f . f i l e n a m e _ s c r i p t = None

54 s e l f . myLastButtonInvoked = None

55 parent . t i t l e (" MININET by Lucas ")

56 s e l f . myParent = parent

57 ###t o t a l frame

58 s e l f . myframe = Frame ( parent )

59 s e l f . myframe . pack ( )

60 ###t o t a l frame

61 ###top frame

62 s e l f . top_frame = Frame ( s e l f . myframe , pady=" 3m")

63 s e l f . top_frame . pack ( )

64 ###top frame

65 ###middle frame

66 s e l f . middle_frame = Frame ( s e l f . myframe , r e l i e f =RIDGE , h e i g h t =150, width =300)

67 s e l f . middle_frame . pack ( s i d e=TOP , expand=NO, f i l l =NONE)

68 ###middle frame

69 ###bottom frame

70 s e l f . bottom_frame = Frame ( s e l f . myframe , r e l i e f =RIDGE , h e i g h t =150, width =300)

71 s e l f . bottom_frame . pack ( s i d e=TOP , expand=NO, f i l l =NONE, anchor=W)

72 ###bottom frame

73 ###buttons frame

74 s e l f . buttons_frame = Frame ( s e l f . myframe , r e l i e f =RIDGE , h e i g h t =75, width =300,pady=" 3m")

75 s e l f . buttons_frame . pack ( s i d e=TOP , expand=NO, f i l l =NONE, anchor=E )

76 ###buttons frame

77 ###c o n t r o l l e r frame

78 s e l f . top1_middle_frame = Frame ( s e l f . middle_frame , r e l i e f =RIDGE , h e i g h t =120, width =300)

79 s e l f . top1_middle_frame . pack ( s i d e=TOP , expand=NO, f i l l =NONE, anchor=

W, pady=" 3m")

80 s e l f . top_top1_middle_frame = Frame ( s e l f . top1_middle_frame , r e l i e f = RIDGE , h e i g h t =60, width =300)

81 s e l f . top_top1_middle_frame . pack ( s i d e=TOP , expand=NO, f i l l =NONE, anchor=W)

82 s e l f . bottom_top1_middle_frame = Frame ( s e l f . top1_middle_frame , r e l i e f

=RIDGE , h e i g h t =60, width =300)

83 s e l f . bottom_top1_middle_frame . pack ( s i d e=TOP , expand=NO, f i l l =NONE, anchor=W)

84 ###c o n t r o l l e r frame

85 ###s w i t c h frame

86 s e l f . top2_middle_frame = Frame ( s e l f . middle_frame , r e l i e f =RIDGE , h e i g h t =120, width =300)

87 s e l f . top2_middle_frame . pack ( s i d e=TOP , expand=NO, f i l l =NONE, anchor=

W)

88 s e l f . top_top2_middle_frame = Frame ( s e l f . top2_middle_frame , r e l i e f = RIDGE , h e i g h t =60, width =300)

89 s e l f . top_top2_middle_frame . pack ( s i d e=TOP , expand=NO, f i l l =NONE, anchor=W)

90 ###s w i t c h frame

91 ###t o p o l og y frame

92 s e l f . middle_middle_frame = Frame ( s e l f . middle_frame , r e l i e f =RIDGE , h e i g h t =50, width =300)

93 s e l f . middle_middle_frame . pack ( s i d e=TOP , expand=NO, f i l l =NONE, pady="

3m")

94 s e l f . frm1_middle_middle_frame = Frame ( s e l f . middle_middle_frame , r e l i e f =RIDGE , h e i g h t =10, width =300)

95 s e l f . frm1_middle_middle_frame . pack ( s i d e=TOP , expand=NO, f i l l =NONE, anchor=W)

96 s e l f . frm2_middle_middle_frame = Frame ( s e l f . middle_middle_frame , r e l i e f =RIDGE , h e i g h t =10, width =300)

97 s e l f . frm2_middle_middle_frame . pack ( s i d e=TOP , expand=NO, f i l l =NONE, anchor=W)

98 s e l f . frm3_middle_middle_frame = Frame ( s e l f . middle_middle_frame , r e l i e f =RIDGE , h e i g h t =10, width =300)

99 s e l f . frm3_middle_middle_frame . pack ( s i d e=TOP , expand=NO, f i l l =NONE, anchor=W)

100 s e l f . frm4_middle_middle_frame = Frame ( s e l f . middle_middle_frame , r e l i e f =RIDGE , h e i g h t =10, width =300)

101 s e l f . frm4_middle_middle_frame . pack ( s i d e=TOP , expand=NO, f i l l =NONE, anchor=W)

102 s e l f . frm5_middle_middle_frame = Frame ( s e l f . middle_middle_frame , r e l i e f =RIDGE , h e i g h t =10, width =300)

103 s e l f . frm5_middle_middle_frame . pack ( s i d e=TOP , expand=NO, f i l l =NONE, anchor=W)

104 s e l f . frm6_middle_middle_frame = Frame ( s e l f . middle_middle_frame , r e l i e f =RIDGE , h e i g h t =10, width =300)

105 s e l f . frm6_middle_middle_frame . pack ( s i d e=TOP , expand=NO, f i l l =NONE, anchor=E )

106 ###t o p o l og y frame

107 ###s c r i p t frame

108 s e l f . bottom_middle_frame = Frame ( s e l f . middle_frame , r e l i e f =RIDGE , h e i g h t =50, width =300)

109 s e l f . bottom_middle_frame . pack ( s i d e=TOP , expand=NO, f i l l =NONE, anchor=W, pady=" 3m")

110 s e l f . frm1_bottom_middle_frame = Frame ( s e l f . bottom_middle_frame , r e l i e f =RIDGE , h e i g h t =10, width =300)

111 s e l f . frm1_bottom_middle_frame . pack ( s i d e=TOP , expand=NO, f i l l =NONE, anchor=W)

112 s e l f . frm2_bottom_middle_frame = Frame ( s e l f . bottom_middle_frame , r e l i e f =RIDGE , h e i g h t =10, width =300)

113 s e l f . frm2_bottom_middle_frame . pack ( s i d e=TOP , expand=NO, f i l l =NONE, anchor=W)

114 ###s c r i p t frame

115 ###o p t i o n s frame

116 s e l f . top_bottom_frame = Frame ( s e l f . bottom_frame , r e l i e f =RIDGE , h e i g h t

=75, width =300,pady=" 3m")

117 s e l f . top_bottom_frame . pack ( s i d e=TOP , anchor=W)

118 s e l f . t o p _ b o t t o m _ l e f t _ f r a m e = Frame ( s e l f . top_bottom_frame , r e l i e f = RIDGE , h e i g h t =75, width =300,pady=" 3m")

119 s e l f . t o p _ b o t t o m _ l e f t _ f r a m e . pack ( s i d e=LEFT , anchor=W)

120 s e l f . t o p _ b o t t o m _ r i g h t _ f r a m e = Frame ( s e l f . top_bottom_frame , r e l i e f = RIDGE , h e i g h t =75, width =300,pady=" 3m", padx=" 3m")

121 s e l f . t o p _ b o t t o m _ r i g h t _ f r a m e . pack ( s i d e=LEFT , anchor=W)

122 ###o p t i o n s frame

123 ### t i t l e

124 s e l f . t e x t _ t i t l e = Label ( s e l f . top_frame , t e x t="THE MININET GUI ", f o n t = (’ Times ’,’ 16 ’,’ bold ’) )

125 s e l f . t e x t _ t i t l e . pack ( s i d e=" top ", f i l l =" both ", expand=True )

126 ### t i t l e

127 ###c o n t r o l l e r args

128 s e l f . t e x t _ c o n t r o l l e r = Label ( s e l f . top_top1_middle_frame , t e x t="

C o n t r o l l e r Type : ", f o n t = (’ Times ’,’ 12 ’,’ bold ’) )

129 s e l f . t e x t _ c o n t r o l l e r . pack ( s i d e=" top ", anchor=W)

130 s e l f . r a d i o 1 _ c o n t r o l l e r = Radiobutton ( s e l f . top_top1_middle_frame , t e x t=" C o n t r o l l e r ’ r e f ’ ", v a r i a b l e=s e l f . c o n t r o l l e r ,

131 command=lambda c o n t r o l l e r = 1

: s e l f . r a d i o C o n t r o l l e r ( c o n t r o l l e r ) )

132 s e l f . r a d i o 1 _ c o n t r o l l e r . pack ( s i d e=" top ", anchor=W)

133 s e l f . r a d i o 1 _ c o n t r o l l e r . s e l e c t ( )

134 s e l f . r a d i o 2 _ c o n t r o l l e r = Radiobutton ( s e l f . top_top1_middle_frame , t e x t=" C o n t r o l l e r ’ remote ’ ", v a r i a b l e=s e l f . c o n t r o l l e r ,

135 value =5,command=lambda

c o n t r o l l e r = 2 : s e l f . r a d i o C o n t r o l l e r ( c o n t r o l l e r ) )

136 s e l f . r a d i o 2 _ c o n t r o l l e r . pack ( s i d e=" top ", anchor=W)

137 s e l f . r a d i o 3 _ c o n t r o l l e r = Radiobutton ( s e l f . bottom_top1_middle_frame , t e x t=" C o n t r o l l e r ’ remote −−i p =’ ", v a r i a b l e=s e l f . c o n t r o l l e r ,

138 value =6,command=lambda

c o n t r o l l e r = 3 : s e l f . r a d i o C o n t r o l l e r ( c o n t r o l l e r ) )

139 s e l f . r a d i o 3 _ c o n t r o l l e r . pack ( s i d e=" l e f t ", anchor=W)

140 s e l f . t e x t _ i p _ c o n t r o l l e r = E n t r y ( s e l f . bottom_top1_middle_frame , width =15,background=’ gray ’)

141 s e l f . t e x t _ i p _ c o n t r o l l e r . pack ( s i d e=" l e f t ", f i l l =" both ", expand=True , anchor=E )

142 s e l f . t e x t _ i p _ c o n t r o l l e r . c o n f i g ( s t a t e=DISABLED )

143 ###c o n t r o l l e r args

144 ###s w i t c h args

145 s e l f . t e x t _ s w i t c h = Label ( s e l f . top_top2_middle_frame , t e x t=" Switch Type : ", f o n t = (’ Times ’,’ 12 ’,’ bold ’) )

146 s e l f . t e x t _ s w i t c h . pack ( s i d e=" top ", anchor=W)

147 s e l f . r a d i o 1 _ s w i t c h = Radiobutton ( s e l f . top_top2_middle_frame , t e x t="

Switch ’ k e r n e l ’ ", v a r i a b l e=s e l f . switch ,

148 command=lambda s w i t c h = 1 :

s e l f . r a d i o S w i t c h ( s w i t c h ) )

149 s e l f . r a d i o 1 _ s w i t c h . pack ( s i d e=" top ", anchor=W)

150 s e l f . r a d i o 1 _ s w i t c h . c o n f i g ( s t a t e=DISABLED )### The k e r n e l s w i t c h t h i s o f f i n t h i s v e r s i o n###

151 s e l f . r a d i o 2 _ s w i t c h = Radiobutton ( s e l f . top_top2_middle_frame , t e x t="

Switch ’ ovsk ’ ", v a r i a b l e=s e l f . switch ,

152 value =7,command=lambda s w i t c h

= 2 : s e l f . r a d i o S w i t c h ( s w i t c h ) )

153 s e l f . r a d i o 2 _ s w i t c h . pack ( s i d e=" top ", anchor=W)

154 s e l f . r a d i o 2 _ s w i t c h . s e l e c t ( )

155 s e l f . r a d i o 3 _ s w i t c h = Radiobutton ( s e l f . top_top2_middle_frame , t e x t="

Switch ’ user ’ ", v a r i a b l e=s e l f . switch ,

156 value =8,command=lambda s w i t c h

= 3 : s e l f . r a d i o S w i t c h ( s w i t c h ) )

157 s e l f . r a d i o 3 _ s w i t c h . pack ( s i d e=" l e f t ", anchor=W)

158 ###s w i t c h args

159 ###t o p o l og y args

160 s e l f . t e x t _ t o p o l o g y = Label ( s e l f . frm1_middle_middle_frame , t e x t="

Topology Type : ", f o n t = (’ Times ’,’ 12 ’,’ bold ’) )

161 s e l f . t e x t _ t o p o l o g y . pack ( s i d e=" top ", anchor=W)

162 ###

163 s e l f . r a d i o 1 _ t o p o l o g y = Radiobutton ( s e l f . frm2_middle_middle_frame , t e x t=" l i n e a r ", v a r i a b l e=s e l f . topology ,

164 command=lambda t o p ol o g y = 1 :

s e l f . r a d i o T o p o l o g y ( t op o l o g y ) )

165 s e l f . r a d i o 1 _ t o p o l o g y . pack ( s i d e=" l e f t ", anchor=W)

166 s e l f . t e x t 1 _ t o p o l o g y = E n t r y ( s e l f . frm2_middle_middle_frame , width =4, background=’ gray ’)

167 s e l f . t e x t 1 _ t o p o l o g y . pack ( s i d e=" l e f t ", f i l l =" both ", expand=True , anchor=E )

168 s e l f . t e x t 1 _ t o p o l o g y . i n s e r t ( 0 ," 2 ")

169 s e l f . t e x t 1 _ t o p o l o g y . c o n f i g ( s t a t e=DISABLED )

170 ###

171 ###

172 s e l f . r a d i o 2 _ t o p o l o g y = Radiobutton ( s e l f . frm3_middle_middle_frame , t e x t=" t r e e ", v a r i a b l e=s e l f . topology ,

173 value =2,command=lambda

t o p ol o g y = 2 : s e l f . r a d i o T o p o l o g y ( to p o l o g y ) )

174 s e l f . r a d i o 2 _ t o p o l o g y . pack ( s i d e=" l e f t ", anchor=W)

175 s e l f . t e x t 2 1 _ t o p o l o g y = E n t r y ( s e l f . frm3_middle_middle_frame , width =4, background=’ gray ’)

176 s e l f . t e x t 2 1 _ t o p o l o g y . pack ( s i d e=" l e f t ", f i l l =" both ", expand=True , anchor=E )

177 s e l f . t e x t 2 1 _ t o p o l o g y . i n s e r t ( 0 ," 2 ")

178 s e l f . t e x t 2 1 _ t o p o l o g y . c o n f i g ( s t a t e=DISABLED )

179 s e l f . t e x t 2 2 _ t o p o l o g y = E n t r y ( s e l f . frm3_middle_middle_frame , width =4, background=’ gray ’)

180 s e l f . t e x t 2 2 _ t o p o l o g y . pack ( s i d e=" l e f t ", f i l l =" both ", expand=True , anchor=E )

181 s e l f . t e x t 2 2 _ t o p o l o g y . i n s e r t ( 0 ," 2 ")

182 s e l f . t e x t 2 2 _ t o p o l o g y . c o n f i g ( s t a t e=DISABLED )

183 ###

184 ###

185 s e l f . r a d i o 3 _ t o p o l o g y = Radiobutton ( s e l f . frm4_middle_middle_frame , t e x t=" s i n g l e ", v a r i a b l e=s e l f . topology ,

186 value =3,command=lambda

t o p ol o g y = 3 : s e l f . r a d i o T o p o l o g y ( to p o l o g y ) )

187 s e l f . r a d i o 3 _ t o p o l o g y . pack ( s i d e=" l e f t ", anchor=W)

188 s e l f . r a d i o 3 _ t o p o l o g y . s e l e c t ( )

189 s e l f . t e x t 3 _ t o p o l o g y = E n t r y ( s e l f . frm4_middle_middle_frame , width =4, background=’ white ’)

190 s e l f . t e x t 3 _ t o p o l o g y . pack ( s i d e=" l e f t ", f i l l =" both ", expand=True , anchor=E )

191 s e l f . t e x t 3 _ t o p o l o g y . i n s e r t ( 0 ," 2 ")

192 ###

193 ###

194 s e l f . r a d i o 4 _ t o p o l o g y = Radiobutton ( s e l f . frm5_middle_middle_frame , t e x t=" custom ", v a r i a b l e=s e l f . topology ,

195 value =4,command=lambda

t o p ol o g y = 4 : s e l f . r a d i o T o p o l o g y ( to p o l o g y ) )

196 s e l f . r a d i o 4 _ t o p o l o g y . pack ( s i d e=" l e f t ", anchor=W)

197 s e l f . t e x t 4 _ t o p o l o g y = E n t r y ( s e l f . frm5_middle_middle_frame , width =30, background=’ gray ’)

198 s e l f . t e x t 4 _ t o p o l o g y . pack ( s i d e=" l e f t ", f i l l =" both ", expand=True , anchor=E )

199 s e l f . t e x t 4 _ t o p o l o g y . c o n f i g ( s t a t e=DISABLED )

200 s e l f . b u t t o n _ t o p o l o g y = Button ( s e l f . frm5_middle_middle_frame , command

=s e l f . b u t t o n _ t o p o l o g y )

201 s e l f . b u t t o n _ t o p o l o g y . c o n f i g u r e ( t e x t=" browser ", h e i g h t =1, padx=" 0m", pady=" 0m")

202 s e l f . b u t t o n _ t o p o l o g y . pack ( s i d e=" l e f t ")

203 s e l f . b u t t o n _ t o p o l o g y . bind ("<Return>", s e l f . b u t t o n _ t o p o l o g y _ a )

204 s e l f . b u t t o n _ t o p o l o g y . c o n f i g ( s t a t e=DISABLED )

205 s e l f . text_custom = Label ( s e l f . frm6_middle_middle_frame , t e x t=" The c l a s s must have the name o f ’ Mytopo ’ ! ! ! ", f o n t = (’ Times ’,’ 11 ’, bold ’) )

206 s e l f . text_custom . pack ( s i d e=" top ", anchor=E )

207 ###

208 ###t o p o l og y args

209 ###s c r i p t args

210 s e l f . t e x t _ s c r i p t = Label ( s e l f . frm1_bottom_middle_frame , t e x t="

S c r i p t : ", f o n t = (’ Times ’,’ 12 ’,’ bold ’) )

211 s e l f . t e x t _ s c r i p t . pack ( s i d e=" top ", anchor=W)

212 s e l f . c h e c k _ s c r i p t = Checkbutton ( s e l f . frm2_bottom_middle_frame , v a r i a b l e=s e l f . s c r i p t , command=s e l f . c h e c k S c r i p t )

213 s e l f . c h e c k _ s c r i p t . pack ( s i d e=" l e f t ", anchor=W)

214 s e l f . t e x t _ s c r i p t = E n t r y ( s e l f . frm2_bottom_middle_frame , width =37, background=’ gray ’)

215 s e l f . t e x t _ s c r i p t . pack ( s i d e=" l e f t ", f i l l =" both ", expand=True , anchor

=E )

216 s e l f . t e x t _ s c r i p t . c o n f i g ( s t a t e=DISABLED )

217 s e l f . b u t t o n _ s c r i p t = Button ( s e l f . frm2_bottom_middle_frame , command=

s e l f . b u t t o n _ s c r i p t )

218 s e l f . b u t t o n _ s c r i p t . c o n f i g u r e ( t e x t=" browser ", h e i g h t =1, padx=" 0m", pady=" 0m")

219 s e l f . b u t t o n _ s c r i p t . pack ( s i d e=" l e f t ")

220 s e l f . b u t t o n _ s c r i p t . bind ("<Return>", s e l f . b u t t o n _ s c r i p t _ a )

221 s e l f . b u t t o n _ s c r i p t . c o n f i g ( s t a t e=DISABLED )

222 ###s c r i p t args

223 ###o p t i o n s args

224 s e l f . t e x t _ a c t i v e = Label ( s e l f . t o p _ b o t t o m _ l e f t _ f r a m e , t e x t=" A c t i v e : "

, f o n t = (’ Times ’,’ 12 ’,’ bold ’) )

225 s e l f . t e x t _ a c t i v e . pack ( s i d e=" top ", anchor=W)

226 s e l f . check_xterm = Checkbutton ( s e l f . t o p _ b o t t o m _ l e f t _ f r a m e , t e x t="

xterm ", v a r i a b l e=s e l f . xterm , command=s e l f . checkXterm )

227 s e l f . check_xterm . pack ( s i d e=" l e f t ", anchor=W)

228 s e l f . check_mac = Checkbutton ( s e l f . t o p _ b o t t o m _ l e f t _ f r a m e , t e x t="−−

mac", v a r i a b l e=s e l f . mac , command=s e l f . checkMac )

229 s e l f . check_mac . s e l e c t ( )

230 s e l f . check_mac . pack ( s i d e=" top ", anchor=W)

231 s e l f . t e x t _ t e s t s = Label ( s e l f . t o p _ b o t t o m _ r i g h t _ f r a m e , t e x t=" T e s t s : ", f o n t = (’ Times ’,’ 12 ’,’ bold ’) )

232 s e l f . t e x t _ t e s t s . pack ( s i d e=" top ", anchor=W)

233 s e l f . check_ping = Checkbutton ( s e l f . t o p _ b o t t o m _ r i g h t _ f r a m e , t e x t="

p i n g a l l ", v a r i a b l e=s e l f . ping , command=s e l f . checkPing )

234 s e l f . check_ping . pack ( s i d e=" l e f t ", anchor=W)

235 s e l f . c h e c k _ i p e r f = Checkbutton ( s e l f . t o p _ b o t t o m _ r i g h t _ f r a m e , t e x t="

i p e r f ", v a r i a b l e=s e l f . i p e r f , command=s e l f . c h e c k I p e r f )

236 s e l f . c h e c k _ i p e r f . pack ( s i d e=" top ", anchor=W)

237 ###o p t i o n s args

238 ###buttons args

239 s e l f . button1 = Button ( s e l f . buttons_frame , command=s e l f . buttonRun , f o n t = (’ Times ’,’ 12 ’,’ bold ’) )

240 s e l f . button1 . c o n f i g u r e ( t e x t=" Run Mi n i Ne t ", h e i g h t =1, width =15)

241 s e l f . button1 . pack ( s i d e=" top ", anchor=SE )

242 s e l f . button1 . bind ("<Return>", s e l f . buttonRun_a )

243 s e l f . button1 . f o c u s _ f o r c e ( )

244 s e l f . button2 = Button ( s e l f . buttons_frame , command=s e l f . buttonClose , f o n t = (’ Times ’,’ 12 ’,’ bold ’) )

245 s e l f . button2 . c o n f i g u r e ( t e x t=" Close GUI ", h e i g h t =1, width =15)

246 s e l f . button2 . pack ( s i d e=" top ", anchor=SE )

247 s e l f . button2 . bind ("<Return>", s e l f . b u t t o n C l o s e _ a )

248 ###buttons args

249

250 def setCustom ( s e l f , name , value ) :

251 " Set custom parameters f o r MininetRunner . "

252 i f name i n ( ’TOPOS ’, ’ s w i t c h e s ’, ’ h o s t s ’, ’ c o n t r o l l e r s ’ ) :

253 # Update d i c t i o n a r i e s

254 param = name . upper ( )

255 g l o b a l s ( ) [ param ] . update ( value )

256 e l i f name == ’ v a l i d a t e ’:

257 # Add custom v a l i d a t e f u n c t i o n

258 s e l f . v a l i d a t e = value

259 e l s e:

260 # Add or modify g l o b a l v a r i a b l e or c l a s s

261 g l o b a l s ( ) [ name ] = value

262

263 def parseCustomFile ( s e l f , fileName ) :

264 " Parse custom f i l e and add params b e f o r e p a r s i n g cmd−l i n e o p t i o n s . "

265 custom = {}

266 i f os . path . i s f i l e ( fileName ) :

267 e x e c f i l e ( fileName , custom , custom )

268 f o r name i n custom :

269 s e l f . setCustom ( name , custom [ name ] )

270 e l s e:

271 r a i s e Exception ( ’ could not f i n d custom f i l e : %s ’ % fileName )

272

273 def b u t t o n C l o s e ( s e l f ) :

274 s e l f . myParent . d e s t r o y ( )

275

276 def b u t t o n C l o s e _ a ( s e l f , event ) :

277 s e l f . b u t t o n 2 C l i c k ( )

278

279 def buttonRun ( s e l f ) :

280 p r i n t " \ n

∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗

"

281 p r i n t " do not f o r g e t t o e x i t the C L I w i t h the command ’< C t r l >+D ’ or

’ e x i t ’ "

282 p r i n t "

∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗\

n "

283 i p c o n t r o l l e r = S t r i n g V a r ( )

284 i p c o n t r o l l e r = s e l f . t e x t _ i p _ c o n t r o l l e r . get ( )

285 i f i p c o n t r o l l e r == " ":

286 i p c o n t r o l l e r = " 1 2 7 . 0 . 0 . 1 "

287 l i n e a r t o p o = s e l f . t e x t 1 _ t o p o l o g y . get ( )

288 i f l i n e a r t o p o == " ":

289 l i n e a r t o p o = 2

290 t r e e t o p o _ d e p t h = s e l f . t e x t 2 1 _ t o p o l o g y . get ( )

291 i f t r e e t o p o _ d e p t h == " ":

292 t r e e t o p o _ d e p t h = 1

293 t r e e t o p o _ f a n o u t = s e l f . t e x t 2 2 _ t o p o l o g y . get ( )

294 i f t r e e t o p o _ f a n o u t == " ":

295 t r e e t o p o _ f a n o u t = 2

296 s i n g l e t o p o = s e l f . t e x t 3 _ t o p o l o g y . get ( )

297 i f s i n g l e t o p o == " ":

298 s i n g l e t o p o = 2

299 i f s e l f . xterm == 20:

300 x = F a l s e

301 e l s e:

302 x = True

303 i f s e l f . mac == 30:

304 m = F a l s e

305 e l s e:

306 m = True

307 #checks the to p o l o g y s e l e c t e d

308 i f s e l f . t o po l o g y == 1 :

309 topo = LinearTopo ( k =i n t ( l i n e a r t o p o ) )

310 e l i f s e l f . t o p o l o gy == 2 :

311 topo = TreeTopo ( depth=i n t ( t r e e t o p o _ d e p t h ) )

312 e l i f s e l f . t o p o l o gy == 3 :

313 topo = Si ngl eSw itc hTo po ( k=i n t ( s i n g l e t o p o ) )

314 e l s e:

315 #The c l a s s must have the name o f ’ Mytopo ’

316 s e l f . parseCustomFile ( s e l f . f i l e n a m e _ t o p o )

317 topo = MyTopo ( )

318 #checks the s e l e c t e d s w i t c h

319 i f s e l f . s w i t c h == 1 :

320 s w i t c h = K e r n e l S w i t c h

321 e l i f s e l f . s w i t c h == 2 :

322 s w i t c h = OVSKernelSwitch

323 e l s e:

324 s w i t c h = UserSwitch

325 #checks the s e l e c t e d c o n t r o l l e r

326 i f s e l f . c o n t r o l l e r == 1 :

327 c o n t r o l l e r = C o n t r o l l e r

328 e l i f s e l f . c o n t r o l l e r == 2 :

329 c o n t r o l l e r = R e mo t e Co n tr o ll e r

330 e l s e:

331 c o n t r o l l e r = c u r r y ( RemoteController , d e f a u l t I P=i p c o n t r o l l e r )

332 #c r e a t i n g the network

333 net = M i n i n e t ( topo = topo , c o n t r o l l e r = c o n t r o l l e r , s w i t c h = switch , autoSetMacs=m, cleanup=True , xterms=x )

334 #s t a r t the network

335 net . s t a r t ( )

336 i f s e l f . ping == 41:

337 net . p i n g A l l ( )

338 i f s e l f . i p e r f == 51:

339 net . i p e r f ( )

340 p r i n t " \ n

∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗

"

341 p r i n t " don ’ t f o r g e t t o e x i t the C L I w i t h the command ’< C t r l >+D ’ or

’ e x i t ’ "

342 p r i n t "

∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗\

n "

343 i n f o ( ∗∗∗ Running C L I \ n ’ )

344 i f s e l f . f i l e n a m e _ s c r i p t == None :

345 C L I ( net )

346 e l s e:

347 C L I ( net , s c r i p t=s e l f . f i l e n a m e _ s c r i p t )

348 C L I ( net )

349 i n f o ( ∗∗∗ Stopping network ’ )

350 net . stop ( )

351

352 def buttonRun_a ( s e l f , event ) :

353 s e l f . buttonRun ( )

354

355 def b u t t o n _ t o p o l o g y ( s e l f ) :

356 s e l f . f i l e n a m e _ t o p o = askopenfilename ( f i l e t y p e s =[(" a l l f i l e s ","") , ("

p y t h o n f i l e s ",". py ") ] )

357 s e l f . t e x t 4 _ t o p o l o g y . d e l e t e ( 0 , END)

358 s e l f . t e x t 4 _ t o p o l o g y . i n s e r t ( 0 , s e l f . f i l e n a m e _ t o p o )

359

360 def b u t t o n _ t o p o l o g y _ a ( s e l f , event ) :

361 s e l f . b u t t o n _ t o p o l o g y ( )

362

363 def b u t t o n _ s c r i p t ( s e l f ) :

364 s e l f . f i l e n a m e _ s c r i p t = askopenfilename ( f i l e t y p e s =[(" a l l f i l e s ","") , (" p y t h o n f i l e s ",". py ") ] )

365 s e l f . t e x t _ s c r i p t . d e l e t e ( 0 ,END)

366 s e l f . t e x t _ s c r i p t . i n s e r t ( 0 , s e l f . f i l e n a m e _ s c r i p t )

367

368 def b u t t o n _ s c r i p t _ a ( s e l f , event ) :

369 s e l f . b u t t o n _ s c r i p t ( )

370

371 def r a d i o C o n t r o l l e r ( s e l f , c o n t r o l l e r ) :

372 i f c o n t r o l l e r == 3 :

373 s e l f . t e x t _ i p _ c o n t r o l l e r . c o n f i g ( s t a t e=NORMAL)

374 s e l f . t e x t _ i p _ c o n t r o l l e r . c o n f i g u r e ( background=’ white ’)

375 e l s e:

376 s e l f . t e x t _ i p _ c o n t r o l l e r . d e l e t e ( 0 , END)

377 s e l f . t e x t _ i p _ c o n t r o l l e r . c o n f i g ( s t a t e=DISABLED )

378 s e l f . t e x t _ i p _ c o n t r o l l e r . c o n f i g u r e ( background=’ gray ’)

379 s e l f . c o n t r o l l e r = c o n t r o l l e r

380

381 def r a d i o S w i t c h ( s e l f , s w i t c h ) :

382 s e l f . s w i t c h = s w i t c h

383

384 def r a d i o T o p o l o g y ( s e l f , t o p ol o g y ) :

385 i f t o p o l o gy == 1 :

386 s e l f . t e x t 1 _ t o p o l o g y . c o n f i g ( s t a t e=NORMAL)

387 s e l f . t e x t 1 _ t o p o l o g y . c o n f i g u r e ( background=’ white ’)

388 s e l f . t e x t 2 1 _ t o p o l o g y . c o n f i g ( s t a t e=DISABLED )

389 s e l f . t e x t 2 1 _ t o p o l o g y . c o n f i g u r e ( background=’ gray ’)

390 s e l f . t e x t 2 2 _ t o p o l o g y . c o n f i g ( s t a t e=DISABLED )

391 s e l f . t e x t 2 2 _ t o p o l o g y . c o n f i g u r e ( background=’ gray ’)

392 s e l f . t e x t 3 _ t o p o l o g y . c o n f i g ( s t a t e=DISABLED )

393 s e l f . t e x t 3 _ t o p o l o g y . c o n f i g u r e ( background=’ gray ’)

394 s e l f . t e x t 4 _ t o p o l o g y . c o n f i g ( s t a t e=DISABLED )

395 s e l f . t e x t 4 _ t o p o l o g y . c o n f i g u r e ( background=’ gray ’)

396 s e l f . b u t t o n _ t o p o l o g y . c o n f i g ( s t a t e=DISABLED )

397 e l i f t o po l o g y == 2 :

398 s e l f . t e x t 2 1 _ t o p o l o g y . c o n f i g ( s t a t e=NORMAL)

399 s e l f . t e x t 2 1 _ t o p o l o g y . c o n f i g u r e ( background=’ white ’)

400 s e l f . t e x t 2 2 _ t o p o l o g y . c o n f i g ( s t a t e=NORMAL)

401 s e l f . t e x t 2 2 _ t o p o l o g y . c o n f i g u r e ( background=’ white ’)

402 s e l f . t e x t 1 _ t o p o l o g y . c o n f i g ( s t a t e=DISABLED )

403 s e l f . t e x t 1 _ t o p o l o g y . c o n f i g u r e ( background=’ gray ’)

404 s e l f . t e x t 3 _ t o p o l o g y . c o n f i g ( s t a t e=DISABLED )

405 s e l f . t e x t 3 _ t o p o l o g y . c o n f i g u r e ( background=’ gray ’)

406 s e l f . t e x t 4 _ t o p o l o g y . c o n f i g ( s t a t e=DISABLED )

407 s e l f . t e x t 4 _ t o p o l o g y . c o n f i g u r e ( background=’ gray ’)

408 s e l f . b u t t o n _ t o p o l o g y . c o n f i g ( s t a t e=DISABLED )

409 e l i f t o po l o g y == 3 :

410 s e l f . t e x t 3 _ t o p o l o g y . c o n f i g ( s t a t e=NORMAL)

411 s e l f . t e x t 3 _ t o p o l o g y . c o n f i g u r e ( background=’ white ’)

412 s e l f . t e x t 1 _ t o p o l o g y . c o n f i g ( s t a t e=DISABLED )

413 s e l f . t e x t 1 _ t o p o l o g y . c o n f i g u r e ( background=’ gray ’)

414 s e l f . t e x t 2 1 _ t o p o l o g y . c o n f i g ( s t a t e=DISABLED )

415 s e l f . t e x t 2 1 _ t o p o l o g y . c o n f i g u r e ( background=’ gray ’)

416 s e l f . t e x t 2 2 _ t o p o l o g y . c o n f i g ( s t a t e=DISABLED )

417 s e l f . t e x t 2 2 _ t o p o l o g y . c o n f i g u r e ( background=’ gray ’)

418 s e l f . t e x t 4 _ t o p o l o g y . c o n f i g ( s t a t e=DISABLED )

419 s e l f . t e x t 4 _ t o p o l o g y . c o n f i g u r e ( background=’ gray ’)

420 s e l f . b u t t o n _ t o p o l o g y . c o n f i g ( s t a t e=DISABLED )

421 e l s e:

422

423 s e l f . t e x t 4 _ t o p o l o g y . c o n f i g ( s t a t e=NORMAL)

424 s e l f . t e x t 4 _ t o p o l o g y . c o n f i g u r e ( background=’ white ’)

425 s e l f . b u t t o n _ t o p o l o g y . c o n f i g ( s t a t e=NORMAL)

426 s e l f . t e x t 1 _ t o p o l o g y . c o n f i g ( s t a t e=DISABLED )

427 s e l f . t e x t 1 _ t o p o l o g y . c o n f i g u r e ( background=’ gray ’)

428 s e l f . t e x t 2 1 _ t o p o l o g y . c o n f i g ( s t a t e=DISABLED )