def customNet(username, enableBlank, enableBasic, enableDhcp):
	user = username
	link_opts = {"bw":1000, "delay":10, "loss": 0, "use_htb": False}
	filename = "netanim_topo.xml"
	basic = enableBasic
	blank = enableBlank
	dhcp = enableDhcp

	print "enableBlank = ", enableBlank
	print "enableDhcp = ", enableDhcp
	print "enableBasic = ", enableBasic

	if(basic == "true" or blank == "true"):
		topo = basicTopo(link_opts = link_opts, filename = filename)
		net = Mininet(topo, switch = BridgeSwitch, controller = OVSController, link = TCLink)

	elif(dhcp == "true"):
		print("Setting up dhcp...")
		topo = dhcpTopo(link_opts = link_opts, filename = filename)
		net = Mininet(topo, switch = Router, controller = OVSController, link = TCLink)
	
	net.start()

	macs = random_macs(len(net.hosts))

	for offset, host in enumerate(net.hosts):
		#Set up default network with hardcoded ip addresses.
		if(basic == "true"):
			print "Capturing on hosts...", offset
			path = "/home/comhghall/Final-Year-Project/resources/" + str(host) + ".pcap"
			print "path = ", path
			host.cmd("tcpdump -u -w", path, "&")

		#Set up a blank network.
		elif(blank == "true" or dhcp == "true"):
			print "Capturing on hosts...", offset
			path = "/home/comhghall/Final-Year-Project/resources/" + str(host) + ".pcap"
			print "path = ", path
			interface = host.intf()
			print "Setting interfaces down..."
			host.cmd("ifconfig", interface, "down")
			host.cmd("ifconfig", interface, "0.0.0.0")
			host.cmd("ifconfig", interface, hex(macs[offset]))
			host.cmd("ifconfig", interface, "down")
			host.cmd("tcpdump -u -w", path, "&")

	for offset, switch in enumerate(net.switches):
		if(basic == "true" or blank == "true"):
			print "Capturing on switches...", offset
			print switch
			path = "/home/comhghall/Final-Year-Project/resources/" + str(switch) + "-eth0.pcap"
			print "path = ", path
			switch.cmd("tcpdump -i", switch, "-u -w", path, "&")

		if(dhcp == "true"):
			print "Capturing on switches...", offset
			print switch
			path = "/home/comhghall/Final-Year-Project/resources/" + str(switch) + "-eth0.pcap"
			print "path = ", path
			switch.cmd("sysctl -w net.ipv4.ip_forward=1")
			if str(switch)[0] != "r":
				print "Bridge switch..."
				switch.cmd("brctl", switch, "down")
				switch.cmd("brclt delbr", switch)
				switch.cmd("brctl addbr", switch)
				for interface in switch.intfNames():
					if interface != "lo":
						switch.cmd("ifconfig", interface, "down")
				for interface in switch.intfNames():
					if interface != "lo":
						switch.cmd("brctl addif", switch, interface)
				switch.cmd("brctl", switch, "up")
				for interface in switch.intfNames():
					if interface != "lo":
						switch.cmd("ifconfig", interface, "up")
				switch.cmd("tcpdump -i", switch, "-u -w", path, "&")
			else:
				print "Router..."
				switch.cmd("echo","",">/etc/dnsmasq.conf")
				for interface in switch.intfNames():
					if interface != "lo":
						switch.cmd("ifconfig", interface, "down")
						prefix,subnet_mask = random_subnet(24)
						dhcp_entry = "dhcp-range=" + socket.inet_ntoa(struct.pack('!L', prefix+10)) +"," + socket.inet_ntoa(struct.pack('!L', prefix+20))+",30s"
						print dhcp_entry
						switch.cmd("echo",dhcp_entry,">>/etc/dnsmasq.conf")
						switch.cmd("ifconfig", interface, "{0}/{1}".format(prefix+1, subnet_mask))
						switch.cmd("ifconfig", interface, "up")
						print interface
						if interface.count("eth"):
							print "Capturing on router..."
							path = "/home/comhghall/Final-Year-Project/resources/" + str(interface) + ".pcap"
							switch.cmd("tcpdump -i", interface, "-u -w", path, "&")
				switch.cmd("dnsmasq")

	net.terms = makeTabbedTerm(net.hosts, term = "xfce")
	net.terms = makeTabbedTerm(net.switches, term = "xfce")

	CLI(net)
	net.stop()