Esempio n. 1
0
	def do_ifconfigs( self, _line ):
		display.section("Showing Interface Configuration")
		sh = 'ifconfig -a'
		display.subsection('Hosts')
		for h in self.mn.hosts:
			h.cmdPrint( sh )
		display.subsection('Controller')
		self.doPrint( sh )
Esempio n. 2
0
	def do_netstats( self, _line ):
		display.section("Routing Tables")
		sh = 'netstat -rn'
		display.subsection('Hosts')
		for h in self.mn.hosts:
			h.cmdPrint( sh )
		display.subsection('Controller')
		self.doPrint( sh )
Esempio n. 3
0
 def do_stats(self, _):
     display.section("OpenFlow: Sent/Received Packets")
     display.message(
         'Packets passing through a switch on the way host with IP address = "nw_dst"'
     )
     for s in self.mn.switches:
         display.subsection('%s - Traffic' % s.name)
         self.doPrint(
             'sudo ovs-ofctl dump-flows %s | grep -e "n_packets=[1-9]*.*n_bytes=[1-9]*.*nw_dst=10.10.[1-9].[1-9]" -To'
             % (s.name))
Esempio n. 4
0
	def do_info( self, line ):
		locals = self.getLocals()
		_nodes = line.split()
		display.section("All functions")
		if not (_nodes):
			_nodes = self.mn.keys()
		for n in _nodes:
			if not (locals.__contains__(n)):
				break
			obj = locals[n]
			display.subsection('%s (%s)' % (n, obj.IP()))
			print(dir(obj))
Esempio n. 5
0
	def do_paths( self, line ):
		# Algorithm input
		switches = self.mn.topo.switches()
		weights = [ ( 's'+str(i[0]), 's'+str(i[1]), i[2] )
			for i in self.mn.topo._slinks ]
		# Least cost paths to every node
		display.section("Least-cost paths to other nodes")
		display.message('From -> To\tCost\t\tFull Shortest Path')
		for start in switches:
			display.subsection('%s' % start)
			for end in switches:
				if (start == end):
					continue
				route = get_routing_decision( start, weights, end )
				cost = get_route_cost( [route] )
				display.message('%s   -> %s\t%s\t\t%s' % (start, end, cost, route))
Esempio n. 6
0
	def do_ips( self, _ ):
		display.section("IP Addresses")
		locals = self.getLocals()
		def showIP( *keys ):
			for key in keys:
				display.message('%s\t%s' % ( key.name, key.IP() ))
		def showAll( *keys ):
			for key in keys:
				display.message('%s\t%s\t%s' % ( key.name, key.IP(), key.MAC() ))
		# For each node
		display.subsection('Controllers')
		for c in self.mn.controllers:
			showIP( locals[c.name] )
		display.subsection('Switches')
		for s in self.mn.switches:
			showIP( locals[s.name] )
		display.subsection('Hosts')
		for h in self.mn.hosts:
			showAll( locals[h.name] )