def do_x( self, line ): """Create an X11 tunnel to the given node, optionally starting a client.""" args = line.split() if not args: error( 'usage: x node [cmd args]...\n' ) else: node = self.mn[ args[ 0 ] ] cmd = args[ 1: ] self.mn.terms += runX11( node, cmd )
def do_x( self, line ): """Create an X11 tunnel to the given component, optionally starting a client.""" args = line.split() if not args: error( 'usage: x comp [cmd args]...\n' ) else: comp = self.cn[ args[ 0 ] ] cmd = args[ 1: ] self.cn.terms += runX11( comp.node, cmd )
def myNetwork(): net = Mininet(topo=None, build=False) info('*** Adding controller\n') info('*** Add switches\n') S1 = net.addSwitch('S1', cls=OVSKernelSwitch, failMode='standalone') S2 = net.addSwitch('S2', cls=OVSKernelSwitch, failMode='standalone') S3 = net.addSwitch('S3', cls=OVSKernelSwitch, failMode='standalone') S4 = net.addSwitch('S4', cls=OVSKernelSwitch, failMode='standalone') S5 = net.addSwitch('S5', cls=OVSKernelSwitch, failMode='standalone') S6 = net.addSwitch('S6', cls=OVSKernelSwitch, failMode='standalone') R1 = net.addHost('R1', cls=Node, ip='0.0.0.0') R2 = net.addHost('R2', cls=Node, ip='0.0.0.0') R3 = net.addHost('R3', cls=Node, ip='0.0.0.0') R4 = net.addHost('R4', cls=Node, ip='0.0.0.0') R5 = net.addHost('R5', cls=Node, ip='0.0.0.0') info('*** Add hosts\n') T1 = net.addHost('T1', cls=Host) T2 = net.addHost('T2', cls=Host) info('*** Add links\n') delay = 5 T1S1 = {'bw': 1, 'delay': str(delay) + 'ms', 'max_queue_size': 10000} links = [[S1, T1], [S2, T1], [S2, R2], [S4, R2], [S4, R5], [S4, R4], [S6, R4], [S5, T2], [S6, T2], [S1, R1], [S3, R1], [S3, R3], [S5, R3], [S3, R5]] for s, t in links: #print "\n",s, t, net.addLink(s, t, cls=TCLink, **T1S1) info('*** Starting network\n') net.build() info('*** Starting controllers\n') for controller in net.controllers: controller.start() info('*** Starting switches\n') net.get('S1').start([]) net.get('S2').start([]) net.get('S3').start([]) net.get('S4').start([]) net.get('S5').start([]) net.get('S6').start([]) info('*** Post configure switches and hosts\n') R1.cmd('sysctl -w net.ipv4.ip_forward=1') R2.cmd('sysctl -w net.ipv4.ip_forward=1') R3.cmd('sysctl -w net.ipv4.ip_forward=1') R4.cmd('sysctl -w net.ipv4.ip_forward=1') R5.cmd('sysctl -w net.ipv4.ip_forward=1') ips = [[T1, "T1-eth0", "10.0.1.2", "10.0.1.1"], [T1, "T1-eth1", "10.0.2.2", "10.0.2.1"], [R1, "R1-eth0", "10.0.1.1"], [R1, "R1-eth1", "10.0.3.1"], [R2, "R2-eth0", "10.0.2.1"], [R2, "R2-eth1", "10.0.4.1"], [R3, "R3-eth0", "10.0.3.2"], [R3, "R3-eth1", "10.0.5.1"], [R4, "R4-eth0", "10.0.4.2"], [R4, "R4-eth1", "10.0.6.1"], [R5, "R5-eth0", "10.0.4.3"], [R5, "R5-eth1", "10.0.3.3"], [T2, "T2-eth0", "10.0.5.2", "10.0.5.1"], [T2, "T2-eth1", "10.0.6.2", "10.0.6.1"]] for x in ips: cmd = "ifconfig " + x[1] + " " + x[2] + " netmask 255.255.255.0" # print cmd x[0].cmd(cmd) if len(x) < 4: continue cmd = "route add default gw " + x[3] + " dev " + x[1] # print cmd x[0].cmd(cmd) routersRouting = [ [R1, "10.0.2.0/24", "R1-eth1", "10.0.3.3"], [R1, "10.0.4.0/24", "R1-eth1", "10.0.3.3"], [R1, "10.0.6.0/24", "R1-eth1", "10.0.3.3"], [R1, "10.0.5.0/24", "R1-eth1", "10.0.3.2"], #[R1, "10.0.5.0/24", "R1-eth1", "10.0.3.2"], [R2, "10.0.3.0/24", "R2-eth1", "10.0.4.3"], [R2, "10.0.1.0/24", "R2-eth1", "10.0.4.3"], [R2, "10.0.5.0/24", "R2-eth1", "10.0.4.3"], [R2, "10.0.6.0/24", "R2-eth1", "10.0.4.2"], [R4, "10.0.2.0/24", "R4-eth0", "10.0.4.1"], [R4, "10.0.1.0/24", "R4-eth0", "10.0.4.3"], [R4, "10.0.3.0/24", "R4-eth0", "10.0.4.3"], [R4, "10.0.5.0/24", "R4-eth0", "10.0.4.3"], [R3, "10.0.1.0/24", "R3-eth0", "10.0.3.1"], [R3, "10.0.2.0/24", "R3-eth0", "10.0.3.3"], [R3, "10.0.4.0/24", "R3-eth0", "10.0.3.3"], [R3, "10.0.6.0/24", "R3-eth0", "10.0.3.3"], [R5, "10.0.6.0/24", "R5-eth0", "10.0.4.2"], [R5, "10.0.2.0/24", "R5-eth0", "10.0.4.1"], [R5, "10.0.5.0/24", "R5-eth1", "10.0.3.2"], [R5, "10.0.1.0/24", "R5-eth1", "10.0.3.1"], ] for x in routersRouting: cmd = 'route add -net ' + x[1] + ' gw ' + x[3] + ' dev ' + x[2] # print cmd x[0].cmd(cmd) T1.cmd("ip rule add from 10.0.1.2 table 1") T1.cmd("ip rule add from 10.0.2.2 table 2") T1.cmd("ip route add 10.0.1.0/24 dev T1-eth0 scope link table 1") T1.cmd("ip route add default via 10.0.1.1 dev T1-eth0 table 1") T1.cmd("ip route add 10.0.2.0/24 dev T1-eth1 scope link table 2") T1.cmd("ip route add default via 10.0.2.1 dev T1-eth1 table 2") T2.cmd("ip rule add from 10.0.5.2 table 1") T2.cmd("ip rule add from 10.0.6.2 table 2") T2.cmd("ip route add 10.0.5.0/24 dev T2-eth0 scope link table 1") T2.cmd("ip route add default via 10.0.5.1 dev T2-eth0 table 1") T2.cmd("ip route add 10.0.6.0/24 dev T2-eth1 scope link table 2") T2.cmd("ip route add default via 10.0.6.1 dev T2-eth1 table 2") T2.cmd("ping -c2 10.0.1.2") T2.cmd("ping -c2 10.0.2.2") T1.cmd("ping -c2 10.0.5.2") T1.cmd("ping -c2 10.0.6.2") cli_cmd = "iperf -c 10.0.5.2" srv_cmd = "iperf -s" tcpdump_cmd = "tcpdump -i any -nv port 5001 -s0" srvNode = T2 cliNode = T1 termTc, popenTc = runX11(cliNode, "xterm -e " + tcpdump_cmd) time.sleep(2) termSr, popenSr = runX11(srvNode, "xterm -e " + srv_cmd) time.sleep(1) termCl, popenCl = runX11(cliNode, "xterm -e " + cli_cmd) # popenSr. popenCl.wait() time.sleep(1) popenSr.terminate() time.sleep(4) popenTc.terminate() # CLI(net) net.stop()
s2.cmd( 'ovs-vsctl -- set port core2-eth2 qos=@newqos -- --id=@newqos create qos type=linux-htb queues=0=@q0,1=@q1 -- \ --id=@q0 create queue other-config:min-rate=2000 other-config:max-rate=10000000 -- \ --id=@q1 create queue other-config:min-rate=1000000 other-config:max-rate=10000000' ) ## Set premium user flows in priority queue add_premium_flow_qos = 'ovs-ofctl -OOpenFlow13 add-flow core2 \ priority=10,table=0,ip,ip_src={0},ip_dst={1},\ actions=set_queue:1,output:2'.format(h1.IP(), h3.IP()) print add_premium_flow_qos s2.cmd(add_premium_flow_qos) xterms = [] [tunnel, term] = runX11( h3, 'vlc-wrapper --rtp-caching=1 rtp://@:5004 --meta-title="premium user:receiving video"' ) xterms.append(term) [tunnel, term] = runX11( h4, 'vlc-wrapper --rtp-caching=1 rtp://@:5004 --meta-title="regular user:receiving video"' ) xterms.append(term) [term] = makeTerm(h5, title='UDP Noise Receiver', cmd="iperf -u -s -i 1") print h5.IP() xterms.append(term) [term] = makeTerm(h2, title='Udp Noise Sender: bash; iperf -u -c IP -b 5M -t 10') xterms.append(term)
def myNetwork(): net = Mininet(topo=None, build=False) info('*** Adding controller\n') info('*** Add switches\n') s1 = net.addSwitch('s1', cls=OVSKernelSwitch, failMode='standalone') s2 = net.addSwitch('s2', cls=OVSKernelSwitch, failMode='standalone') s3 = net.addSwitch('s3', cls=OVSKernelSwitch, failMode='standalone') info('*** Add hosts\n') h1 = net.addHost('h1', cls=Host) h2 = net.addHost('h2', cls=Host) info('*** Add links\n') linkProp1 = {'bw': 1, 'delay': '100ms'} linkProp2 = {'bw': 2, 'delay': '100ms'} linkProp3 = {'bw': 3, 'delay': '100ms'} net.addLink(h1, s1, cls=TCLink, **linkProp1) net.addLink(h1, s2, cls=TCLink, **linkProp2) net.addLink(h1, s3, cls=TCLink, **linkProp3) net.addLink(h2, s1, cls=TCLink, **linkProp1) net.addLink(h2, s2, cls=TCLink, **linkProp2) net.addLink(h2, s3, cls=TCLink, **linkProp3) info('*** Starting network\n') net.build() info('*** Starting controllers\n') for controller in net.controllers: controller.start() info('*** Starting switches\n') net.get('s1').start([]) net.get('s2').start([]) net.get('s3').start([]) info('*** Post configure switches and hosts\n') h1.cmd("ifconfig h1-eth0 10.0.1.1 netmask 255.255.255.0") h1.cmd("ifconfig h1-eth1 192.168.2.1 netmask 255.255.255.0") h1.cmd("ifconfig h1-eth2 172.16.3.1 netmask 255.255.255.0") h2.cmd("ifconfig h2-eth0 10.0.1.2 netmask 255.255.255.0") h2.cmd("ifconfig h2-eth1 192.168.2.2 netmask 255.255.255.0") h2.cmd("ifconfig h2-eth2 172.16.3.2 netmask 255.255.255.0") # CLI(net) # waitTime = 120 # # host = "h1" # dtHdr = "" # dtBdy = "" # dtRes = "" # for intf in xrange(3): # dtHdr += "dt%d1=$(cat /sys/class/net/%s-eth%d/statistics/tx_bytes); \n"%(intf, host, intf) # dtBdy += "dt%d=$(cat /sys/class/net/%s-eth%d/statistics/tx_bytes); "%(intf, host, intf) \ # + "dt%dr=$(echo $dt%d-$dt%d1|bc); dt%d1=$dt%d; \n" %(intf, intf, intf, intf, intf) # dtRes += "$dt%dr $dt%d "%(intf, intf) # getstatcmd = """ # %s # sleep 1; # tm0=$(date "+%%s"); # for x in `seq %d`; # do tm=$(date "+%%s"); # tmr=$(echo $tm-$tm0|bc); # %s # echo $tmr $tm %s; # sleep 1; # done | tee /tmp/dt.csv # """%(dtHdr, waitTime, dtBdy, dtRes) # # print getstatcmd # getstatcmd = "python ./dynamic_plot.py" # for intf in xrange(3): # getstatcmd += " %s-eth%d"%(host, intf) # # server = "./goserver.sh 9876" # client = "./goclient.sh 10.0.1.2 9876" # primaryDown = "ifconfig h2-eth0 down" # primaryUp = "ifconfig h2-eth0 up" server = "iperf -s" client = "iperf -c 10.0.1.2 -t 200" # otherDown = "ifconfig h2-eth1 down; ifconfig h2-eth2 down" # otherUp = "ifconfig h2-eth1 up; ifconfig h2-eth2 up" # markAsBackup = "kill -USR1 `cat /tmp/tcpClient.pid`" # # writeExe("/tmp/getstat", getstatcmd) # # termSt, popenSt = runX11(h1, "xterm -e "+"/tmp/getstat") # time.sleep(3) termSr, popenSr = runX11(h2, "xterm -e " + server) termCl, popenCl = runX11(h1, "xterm -e " + client) # time.sleep(15) # h1.cmd(markAsBackup) # time.sleep(20) # h2.cmd(primaryDown) # time.sleep(20) # h2.cmd(primaryUp) # time.sleep(20) # h2.cmd(otherDown) # time.sleep(20) # h2.cmd(otherUp) time.sleep(25) popenSt.terminate() popenCl.terminate() popenSr.terminate() net.stop()
def myNetwork(): net = Mininet(topo=None, build=False, ipBase='10.0.0.0/8') info('*** Adding controller\n') info('*** Add switches\n') s2 = net.addSwitch('s2', cls=OVSKernelSwitch, failMode='standalone') s1 = net.addSwitch('s1', cls=OVSKernelSwitch, failMode='standalone') s3 = net.addSwitch('s3', cls=OVSKernelSwitch, failMode='standalone') s4 = net.addSwitch('s4', cls=OVSKernelSwitch, failMode='standalone') info('*** Add hosts\n') h2 = net.addHost('h2', cls=Host, ip='10.0.0.2', defaultRoute=None) h6 = net.addHost('h6', cls=Host, ip='10.0.0.6', defaultRoute=None) h1 = net.addHost('h1', cls=Host, ip='10.0.0.1', defaultRoute=None) h4 = net.addHost('h4', cls=Host, ip='10.0.0.4', defaultRoute=None) h5 = net.addHost('h5', cls=Host, ip='10.0.0.5', defaultRoute=None) h3 = net.addHost('h3', cls=Host, ip='10.0.0.3', defaultRoute=None) info('*** Add links\n') hs = {'bw': 2, 'delay': '50ms'} net.addLink(h1, s1, cls=TCLink, **hs) net.addLink(h2, s1, cls=TCLink, **hs) net.addLink(h3, s2, cls=TCLink, **hs) net.addLink(h4, s2, cls=TCLink, **hs) net.addLink(h5, s3, cls=TCLink, **hs) net.addLink(h6, s3, cls=TCLink, **hs) ss = {'bw': 6, 'delay': '10ms'} net.addLink(s1, s4, cls=TCLink, **ss) net.addLink(s2, s4, cls=TCLink, **ss) net.addLink(s3, s4, cls=TCLink, **ss) info('*** Starting network\n') net.build() info('*** Starting controllers\n') for controller in net.controllers: controller.start() info('*** Starting switches\n') net.get('s2').start([]) net.get('s1').start([]) net.get('s3').start([]) net.get('s4').start([]) info('*** Post configure switches and hosts\n') server = "./server.sh" client1 = "./client.sh /home/viscous/Documents/f1/ 10.0.0.6" client2 = "./client.sh /home/viscous/Documents/f2/ 10.0.0.6" client3 = "./client.sh /home/viscous/Documents/f3/ 10.0.0.6" client4 = "./client.sh /home/viscous/Documents/f4/ 10.0.0.6" client5 = "./client.sh /home/viscous/Documents/f5/ 10.0.0.6" termSr, popenSr = runX11(h6, "xterm -e " + server) termCl1, popenCl1 = runX11(h1, "xterm -e " + client1) termCl2, popenCl2 = runX11(h2, "xterm -e " + client2) termCl3, popenCl3 = runX11(h3, "xterm -e " + client3) termCl4, popenCl4 = runX11(h4, "xterm -e " + client4) termCl5, popenCl5 = runX11(h5, "xterm -e " + client5) popenCl1.wait() popenCl2.wait() popenCl3.wait() popenCl4.wait() popenCl5.wait() time.sleep(5) popenSr.terminate() # CLI(net) net.stop()