-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpratica-1-III.py
48 lines (40 loc) · 1.22 KB
/
pratica-1-III.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#Exercise practice of the course Advanced Topics in Computer Networks at UFRPE/Brazil
#Author: Kleber Leal and Glauco Goncalves, PhD
import atexit
from mininet.net import Mininet
from mininet.topo import Topo
from mininet.cli import CLI
from mininet.log import info,setLogLevel
from mininet.link import TCLink
net = None
def createTopo():
topo=Topo()
#Create Nodes
topo.addHost("h1")
topo.addHost("h2")
topo.addHost("h3")
topo.addHost("h4")
topo.addSwitch('s1')
topo.addSwitch('s2')
topo.addSwitch('s3')
#Create links
topo.addLink('s1','s2',bw=100,delay='100ms',loss=10)
topo.addLink('s1','s3')
topo.addLink('h1','s2')
topo.addLink('h2','s2')
topo.addLink('h3','s3')
topo.addLink('h4','s3')
return topo
def startNetwork():
topo = createTopo()
global net
net = Mininet(topo=topo, autoSetMacs=True, link=TCLink)
net.start()
CLI(net)
def stopNetwork():
if net is not None:
net.stop()
if __name__ == '__main__':
atexit.register(stopNetwork)
setLogLevel('info')
startNetwork()