def initTopology(self, topo): self.controller = PySwitchController() sw1 = OpenflowSwitch( name="s1", port_count=2, of_id=1, expire_entries=config.get("model.flow_entry_expiration")) sw2 = OpenflowSwitch( name="s2", port_count=2, of_id=2, expire_entries=config.get("model.flow_entry_expiration")) cl1 = SymExecSender(name="h1", mymac=(0x00, 0xBA, 0xAD, 0xF0, 0x0D, 0x01), max_pkts=config.get("nice_model.max_pkts"), max_burst=config.get("nice_model.max_burst")) cl2 = Replier(name="h2", mymac=(0x00, 0x01, 0x02, 0x03, 0x04, 0x05)) sw1.initTopology({0: (cl1, 0), 1: (sw2, 0)}) sw2.initTopology({0: (sw1, 1), 1: (cl2, 0)}) cl1.initTopology({0: (sw1, 0)}) cl2.initTopology({0: (sw2, 1)}) self.clients.append(cl1) self.clients.append(cl2) self.switches.append(sw1) self.switches.append(sw2) self.switches_idx[sw1.getOpenflowID()] = sw1 self.switches_idx[sw2.getOpenflowID()] = sw2 # start callbacks self.controller.start_callbacks.append( lambda: self.controller.install()) self.controller.start_callbacks.append( lambda: self.controller.addSwitch(sw1)) self.controller.start_callbacks.append( lambda: self.controller.addSwitch(sw2))
def initTopology(self, topo): # Define the controller self.controller = PySwitchController(version="pyswitch") # Define the switches sw1 = OpenflowSwitch(name="s1", port_count=2, of_id=1, expire_entries=config.get("model.flow_entry_expiration")) sw2 = OpenflowSwitch(name="s2", port_count=3, of_id=2, expire_entries=config.get("model.flow_entry_expiration")) # Define the clients and thier addresses mac1 = (0x00, 0x01, 0x02, 0x03, 0x04, 0x00) mac2 = (0x00, 0x01, 0x02, 0x03, 0x05, 0x05) cl1 = Arrival(name="h1", mymac=mac1, dstmac=mac2, \ pkts=config.get("pyswitch_model.pkts"), sequential=config.get("pyswitch_model.sequential")) cl2 = Replier(name="h2", mymac=mac2) # We want host mobility active on client 2 cl2.move_host = config.get("pyswitch_model.move_host") cl2.move_host_switch = (sw2, 1, 2) if cl2.move_host: self.invariants = [NoDropMobileInvariant] else: self.invariants = [NoLoopInvariant, StrictDirectRouteInvariant] # topology connections: sw1 port 0 is connected to port 0 of cl1, port 1 connected to port 0 of sw2 sw1.initTopology({0: (cl1, 0), 1: (sw2, 0)}) sw2.initTopology({0: (sw1, 1), 1: (cl2, 0), 2: (None, None)}) cl1.initTopology({0: (sw1, 0)}) cl2.initTopology({0: (sw2, 1)}) # Add clients and switches to the model list self.clients.append(cl1) self.clients.append(cl2) self.switches.append(sw1) self.switches.append(sw2) self.switches_idx[sw1.getOpenflowID()] = sw1 self.switches_idx[sw2.getOpenflowID()] = sw2 # start callbacks self.controller.start_callbacks.append(lambda: self.controller.install()) self.controller.start_callbacks.append(lambda: self.controller.addSwitch(sw1)) self.controller.start_callbacks.append(lambda: self.controller.addSwitch(sw2))
def __init__(self, name, port_count, of_id, expire_entries=False, stop_when_no_match = False): OpenflowSwitch.__init__(self, name, port_count, of_id, expire_entries) self.bufferMap = {} self.newBuffers = [] self.packetTranslator = None self.packetsSent = [] self.queriesSent = [] self.portMap = {} self.controllers = {} self.realIfaces = {} self.realOfIds = {} self.stop_when_no_match = stop_when_no_match
def process_packet(self): del self.newBuffers[:] packetsToProcess = [] for p in self.ports_object: # if ports were used, DPOR would not work port = self.ports_object[p] pkt = None if len(port.in_buffer) > 0: pkt = port.in_buffer[0] if pkt is None: continue packetsToProcess.append((p, pkt)) self.packetsSent = [] self.queriesSent = [] ret = OpenflowSwitch.process_packet(self) resultingPackets, resultingQueries = self.packetTranslator.processPacket(self, packetsToProcess, len(self.packetsSent) + len(self.queriesSent)) for swtype in self.portMap: if swtype.type not in self.bufferMap: self.bufferMap[swtype.type] = {} for packet in resultingQueries[swtype.type]: for key in self.newBuffers: (pkt, p) = self.packet_store[key] if packet.in_port == self.portMap[swtype][p]: self.bufferMap[swtype.type][key] = packet.buffer_id break result, errors = Comparator.compareResults(self, resultingPackets, resultingQueries, self.packetsSent, self.queriesSent) if not result: self.state.testPoint("no_matching_packets") print errors print self.queriesSent print self.packetsSent print resultingPackets print resultingQueries assert not self.stop_when_no_match stats = self.packetTranslator.checkFlowStats(self) result, errors = Comparator.compareFlowStats(self, stats) if not result: self.state.testPoint("no_matching_packets") print errors print stats assert not self.stop_when_no_match stats = self.packetTranslator.checkPortStats(self) result, errors = Comparator.comparePortStats(self, stats) if not result: self.state.testPoint("no_matching_packets") print errors print stats assert not self.stop_when_no_match return ret
def initTopology(self, topo): self.controller = LoadBalancerController( use_fixed=config.get("loadbalancer_model.use_fixed_version")) r1 = TcpServer(name="replica1", mymac=(0, 0xee, 0xee, 0, 0, 1), myip=(20, 0, 0, 1)) r2 = TcpServer(name="replica2", mymac=(0, 0xee, 0xee, 0, 0, 2), myip=(20, 0, 0, 2)) # sw1 = OpenflowSwitch(name="s1", port_count=4, of_id=0x000102030401) sw1 = OpenflowSwitch( name="s1", port_count=3, of_id=0x000102030401, expire_entries=config.get("model.flow_entry_expiration")) cl1 = TcpClient(name="h1", mymac=(0, 0xcc, 0xcc, 0, 0, 0x01), myip=(1, 0, 0, 1), pkts=config.get("loadbalancer_model.connections"), destip=(20, 0, 0, 5)) # cl2 = TcpClient(name="h2", mymac=(0, 0xcc, 0xcc, 0, 0, 0x02), myip=(128, 0, 0, 1), pkts=self.num_pkts_to_inject) # sw1.initTopology({0: (r1, 0), 1: (r2, 0), 2: (cl1, 0), 3: (cl2, 0)}) sw1.initTopology({0: (r1, 0), 1: (r2, 0), 2: (cl1, 0)}) cl1.initTopology({0: (sw1, 2)}) # cl2.initTopology({0: (sw1, 3)}) r1.initTopology({0: (sw1, 0)}) r2.initTopology({0: (sw1, 1)}) self.clients.append(cl1) # self.clients.append(cl2) self.clients.append(r1) self.clients.append(r2) self.switches.append(sw1) self.switches_idx[sw1.getOpenflowID()] = sw1 # start callbacks self.controller.start_callbacks.append( lambda: self.controller.install()) self.controller.start_callbacks.append( lambda: self.controller.addSwitch(sw1))
def initTopology(self, topo): self.controller = PySwitchController(version="pyswitch") sw1 = OpenflowSwitch(name="s1", port_count=2, of_id=1, expire_entries=config.get("model.flow_entry_expiration")) sw2 = OpenflowSwitch(name="s2", port_count=2, of_id=2, expire_entries=config.get("model.flow_entry_expiration")) mac1 = (0x00, 0x01, 0x02, 0x03, 0x04, 0x00) mac2 = (0x00, 0x01, 0x02, 0x03, 0x05, 0x05) cl1 = Arrival(name="h1", mymac=mac1, dstmac=mac2, \ pkts=config.get("pyswitch_model.pkts"), sequential=config.get("pyswitch_model.sequential")) cl2 = Replier(name="h2", mymac=mac2) sw1.initTopology({0: (cl1, 0), 1: (sw2, 0)}) sw2.initTopology({0: (sw1, 1), 1: (cl2, 0)}) cl1.initTopology({0: (sw1, 0)}) cl2.initTopology({0: (sw2, 1)}) self.clients.append(cl1) self.clients.append(cl2) self.switches.append(sw1) self.switches.append(sw2) self.switches_idx[sw1.getOpenflowID()] = sw1 self.switches_idx[sw2.getOpenflowID()] = sw2 # start callbacks self.controller.start_callbacks.append(lambda: self.controller.install()) self.controller.start_callbacks.append(lambda: self.controller.addSwitch(sw1)) self.controller.start_callbacks.append(lambda: self.controller.addSwitch(sw2))
def initTopology(self, topo): self.controller = PySwitchController() sw1 = OpenflowSwitch(name="s1", port_count=2, of_id=1, expire_entries=config.get("model.flow_entry_expiration")) sw2 = OpenflowSwitch(name="s2", port_count=2, of_id=2, expire_entries=config.get("model.flow_entry_expiration")) cl1 = SymExecSender(name="h1", mymac=(0x00, 0xBA, 0xAD, 0xF0, 0x0D, 0x01), max_pkts=config.get("nice_model.max_pkts"), max_burst=config.get("nice_model.max_burst")) cl2 = Replier(name="h2", mymac=(0x00, 0x01, 0x02, 0x03, 0x04, 0x05)) sw1.initTopology({0: (cl1, 0), 1: (sw2, 0)}) sw2.initTopology({0: (sw1, 1), 1: (cl2, 0)}) cl1.initTopology({0: (sw1, 0)}) cl2.initTopology({0: (sw2, 1)}) self.clients.append(cl1) self.clients.append(cl2) self.switches.append(sw1) self.switches.append(sw2) self.switches_idx[sw1.getOpenflowID()] = sw1 self.switches_idx[sw2.getOpenflowID()] = sw2 # start callbacks self.controller.start_callbacks.append(lambda: self.controller.install()) self.controller.start_callbacks.append(lambda: self.controller.addSwitch(sw1)) self.controller.start_callbacks.append(lambda: self.controller.addSwitch(sw2))
def process_command(self): pp = self.command_queue[0]; self.packetsSent = [] self.queriesSent = [] ret = OpenflowSwitch.process_command(self) resultingPackets, resultingQueries = self.packetTranslator.processCommand(self, pp, len(self.packetsSent) + len(self.queriesSent)) result, errors = Comparator.compareResults(self, resultingPackets, resultingQueries, self.packetsSent, self.queriesSent) if not result: self.state.testPoint("no_matching_packets") print errors print self.queriesSent print self.packetsSent print resultingPackets print resultingQueries assert not self.stop_when_no_match return ret
def initTopology(self, topo): self.controller = EateController( version=config.get("eate_model.app_version")) s_b = OpenflowSwitch( name="s_b", port_count=3 + 1, of_id=1, expire_entries=config.get("model.flow_entry_expiration")) s_c = OpenflowSwitch( name="s_c", port_count=4 + 1, of_id=2, expire_entries=config.get("model.flow_entry_expiration")) s_i = OpenflowSwitch( name="s_i", port_count=2 + 1, of_id=3, expire_entries=config.get("model.flow_entry_expiration")) h_b1_ip = (10, 0, 0, 11) h_x1_ip = (10, 0, 0, 13) h_y1_ip = (10, 0, 0, 14) h_b1_mac = (10, 0, 0, 0, 0, 0x0B) h_x1_mac = (10, 0, 0, 0, 0, 0x0C) h_y1_mac = (10, 0, 0, 0, 0, 0x0D) h_b1 = TcpClient( name="h_b1", mymac=h_b1_mac, myip=h_b1_ip, destip=[h_x1_ip, h_y1_ip], pkts=config.get( "eate_model.connections")) #, h1ip = h_x1_ip, h2ip=h_y1_ip) h_x1 = TcpServer(name="h_x1", mymac=h_x1_mac, myip=h_x1_ip) h_y1 = TcpServer(name="h_y1", mymac=h_y1_mac, myip=h_y1_ip) h_b1.initTopology({0: (s_b, 3)}) h_x1.initTopology({0: (s_c, 3)}) h_y1.initTopology({0: (s_c, 4)}) s_b.initTopology({1: (s_i, 1), 2: (s_c, 1), 3: (h_b1, 0)}) s_c.initTopology({ 1: (s_b, 2), 2: (s_i, 2), 3: (h_x1, 0), 4: (h_y1, 0) }) s_i.initTopology({1: (s_b, 1), 2: (s_c, 2)}) self.clients.append(h_b1) self.clients.append(h_x1) self.clients.append(h_y1) self.switches.append(s_b) self.switches.append(s_c) self.switches.append(s_i) self.switches_idx[s_b.getOpenflowID()] = s_b self.switches_idx[s_c.getOpenflowID()] = s_c self.switches_idx[s_i.getOpenflowID()] = s_i h_x1.controller = self.controller #start callbacks self.controller.start_callbacks.append( lambda: self.controller.install()) self.controller.start_callbacks.append( lambda: self.controller.addSwitch(s_b)) self.controller.start_callbacks.append( lambda: self.controller.addSwitch(s_c)) self.controller.start_callbacks.append( lambda: self.controller.addSwitch(s_i))
def initTopology(self, topo): self.controller = EateController( version=config.get("eate_model.app_version")) s_1 = OpenflowSwitch( name="s_1", port_count=3 + 1, of_id=1, expire_entries=config.get("model.flow_entry_expiration")) s_2 = OpenflowSwitch( name="s_2", port_count=3 + 1, of_id=2, expire_entries=config.get("model.flow_entry_expiration")) s_3 = OpenflowSwitch( name="s_3", port_count=2 + 1, of_id=3, expire_entries=config.get("model.flow_entry_expiration")) s_4 = OpenflowSwitch( name="s_4", port_count=2 + 1, of_id=4, expire_entries=config.get("model.flow_entry_expiration")) s_5 = OpenflowSwitch( name="s_5", port_count=3 + 1, of_id=5, expire_entries=config.get("model.flow_entry_expiration")) s_6 = OpenflowSwitch( name="s_6", port_count=6 + 1, of_id=6, expire_entries=config.get("model.flow_entry_expiration")) s_7 = OpenflowSwitch( name="s_7", port_count=2 + 1, of_id=7, expire_entries=config.get("model.flow_entry_expiration")) s_8 = OpenflowSwitch( name="s_8", port_count=2 + 1, of_id=8, expire_entries=config.get("model.flow_entry_expiration")) s_9 = OpenflowSwitch( name="s_9", port_count=3 + 1, of_id=9, expire_entries=config.get("model.flow_entry_expiration")) s_10 = OpenflowSwitch( name="s_10", port_count=3 + 1, of_id=10, expire_entries=config.get("model.flow_entry_expiration")) hb_ip = (10, 0, 0, 11) hc_ip = (10, 0, 0, 12) hd_ip = (10, 0, 0, 13) he_ip = (10, 0, 0, 14) hb_mac = (10, 0, 0, 0, 0, 0x0B) hc_mac = (10, 0, 0, 0, 0, 0x0C) hd_mac = (10, 0, 0, 0, 0, 0x0D) he_mac = (10, 0, 0, 0, 0, 0x0E) hb = TcpClient( name="B", mymac=hb_mac, myip=hb_ip, destip=[he_ip], pkts=self.config.get( "eate_model.connections")) #, h1ip = h_x1_ip, h2ip=h_y1_ip) hc = TcpClient(name="C", mymac=hc_mac, myip=hc_ip, destip=[hd_ip], pkts=self.config.get("eate_model.connections")) hd = TcpServer(name="D", mymac=hd_mac, myip=hd_ip) he = TcpServer(name="E", mymac=he_mac, myip=he_ip) hb.initTopology({0: (s_1, 3)}) hc.initTopology({0: (s_2, 3)}) hd.initTopology({0: (s_9, 3)}) he.initTopology({0: (s_10, 3)}) s_1.initTopology({1: (s_5, 1), 2: (s_3, 1), 3: (hb, 0)}) s_2.initTopology({1: (s_5, 2), 2: (s_7, 1), 3: (hc, 0)}) s_3.initTopology({1: (s_1, 2), 2: (s_4, 1)}) s_4.initTopology({1: (s_3, 2), 2: (s_9, 2)}) s_5.initTopology({1: (s_1, 1), 2: (s_2, 1), 3: (s_6, 1)}) s_6.initTopology({1: (s_5, 3), 2: (s_10, 1), 3: (s_9, 1)}) s_7.initTopology({1: (s_2, 2), 2: (s_8, 1)}) s_8.initTopology({1: (s_7, 2), 2: (s_10, 2)}) s_9.initTopology({1: (s_6, 3), 2: (s_4, 2), 3: (hd, 0)}) s_10.initTopology({1: (s_6, 2), 2: (s_8, 2), 3: (he, 0)}) # s_1.setPortsCanFail([1,2]) # s_2.setPortsCanFail([1,2]) # s_3.setPortsCanFail([2]) # s_4.setPortsCanFail([2]) # s_5.setPortsCanFail([3]) # s_6.setPortsCanFail([2,3]) # s_7.setPortsCanFail([2]) # s_8.setPortsCanFail([2]) self.clients.append(hb) self.clients.append(hc) self.clients.append(hd) self.clients.append(he) self.switches.append(s_1) self.switches.append(s_2) self.switches.append(s_3) self.switches.append(s_4) self.switches.append(s_5) self.switches.append(s_6) self.switches.append(s_7) self.switches.append(s_8) self.switches.append(s_9) self.switches.append(s_10) self.switches_idx[s_1.getOpenflowID()] = s_1 self.switches_idx[s_2.getOpenflowID()] = s_2 self.switches_idx[s_3.getOpenflowID()] = s_3 self.switches_idx[s_4.getOpenflowID()] = s_4 self.switches_idx[s_5.getOpenflowID()] = s_5 self.switches_idx[s_6.getOpenflowID()] = s_6 self.switches_idx[s_7.getOpenflowID()] = s_7 self.switches_idx[s_8.getOpenflowID()] = s_8 self.switches_idx[s_9.getOpenflowID()] = s_9 self.switches_idx[s_10.getOpenflowID()] = s_10 # Switch failures self.setSwitchFailuresCount(2) hb.controller = self.controller hc.controller = self.controller hd.controller = self.controller he.controller = self.controller #start callbacks self.controller.start_callbacks.append( lambda: self.controller.install()) self.controller.start_callbacks.append( lambda: self.controller.addSwitch(s_1)) self.controller.start_callbacks.append( lambda: self.controller.addSwitch(s_2)) self.controller.start_callbacks.append( lambda: self.controller.addSwitch(s_3)) self.controller.start_callbacks.append( lambda: self.controller.addSwitch(s_4)) self.controller.start_callbacks.append( lambda: self.controller.addSwitch(s_5)) self.controller.start_callbacks.append( lambda: self.controller.addSwitch(s_6)) self.controller.start_callbacks.append( lambda: self.controller.addSwitch(s_7)) self.controller.start_callbacks.append( lambda: self.controller.addSwitch(s_8)) self.controller.start_callbacks.append( lambda: self.controller.addSwitch(s_9)) self.controller.start_callbacks.append( lambda: self.controller.addSwitch(s_10))
def initTopology(self, topo): """ 3 switch triangle topology """ self.controller = PySwitchController(version="pyswitch") sw1 = OpenflowSwitch(name="s1", port_count=3, of_id=1) sw2 = OpenflowSwitch(name="s2", port_count=3, of_id=2) sw3 = OpenflowSwitch(name="s3", port_count=2, of_id=3) cl1 = Arrival(name="h1", pkts=config.get("pyswitch_model.pkts"), sequential=config.get("pyswitch_model.sequential")) cl2 = Replier(name="h2", mymac=(0x00, 0x01, 0x02, 0x03, 0x04, 0x05)) sw1.initTopology({0: (cl1, 0), 1: (sw2, 0), 2: (sw3, 0)}) sw2.initTopology({0: (sw1, 1), 1: (cl2, 0), 2: (sw3, 1)}) sw3.initTopology({0: (sw1, 2), 1: (sw2, 2)}) cl1.initTopology({0: (sw1, 0)}) cl2.initTopology({0: (sw2, 1)}) self.clients.append(cl1) self.clients.append(cl2) self.switches.append(sw1) self.switches.append(sw2) self.switches.append(sw3) self.switches_idx[sw1.getOpenflowID()] = sw1 self.switches_idx[sw2.getOpenflowID()] = sw2 self.switches_idx[sw3.getOpenflowID()] = sw3 # start callbacks self.controller.start_callbacks.append( lambda: self.controller.install()) self.controller.start_callbacks.append( lambda: self.controller.addSwitch(sw1)) self.controller.start_callbacks.append( lambda: self.controller.addSwitch(sw2)) self.controller.start_callbacks.append( lambda: self.controller.addSwitch(sw3))
def start(self, model_checker): OpenflowSwitch.start(self, model_checker) self.packetTranslator = model_checker.packetTranslator
def acquireBuffer(self): ret = OpenflowSwitch.acquireBuffer(self) self.newBuffers.append(ret) return ret
def enqueuePacketToNode(self, node, packet, inport): self.packetsSent.append((node, inport, packet)) OpenflowSwitch.enqueuePacketToNode(self, node, packet, inport)
def enqueueQueryToController(self, dp_id, buffer_id, packet, inport, reason, max_length): self.queriesSent.append((buffer_id, packet, inport, reason, max_length)) OpenflowSwitch.enqueueQueryToController(self, dp_id, buffer_id, packet, inport, reason, max_length)
def initTopology(self, topo): """ 3 switch triangle topology """ self.controller = PySwitchController(version="pyswitch") sw1 = OpenflowSwitch(name="s1", port_count=3, of_id=1) sw2 = OpenflowSwitch(name="s2", port_count=3, of_id=2) sw3 = OpenflowSwitch(name="s3", port_count=2, of_id=3) cl1 = Arrival(name="h1", pkts=config.get("pyswitch_model.pkts"), sequential=config.get("pyswitch_model.sequential")) cl2 = Replier(name="h2", mymac=(0x00, 0x01, 0x02, 0x03, 0x04, 0x05)) sw1.initTopology({0: (cl1, 0), 1: (sw2, 0), 2: (sw3, 0)}) sw2.initTopology({0: (sw1, 1), 1: (cl2, 0), 2: (sw3, 1)}) sw3.initTopology({0: (sw1, 2), 1: (sw2, 2)}) cl1.initTopology({0: (sw1, 0)}) cl2.initTopology({0: (sw2, 1)}) self.clients.append(cl1) self.clients.append(cl2) self.switches.append(sw1) self.switches.append(sw2) self.switches.append(sw3) self.switches_idx[sw1.getOpenflowID()] = sw1 self.switches_idx[sw2.getOpenflowID()] = sw2 self.switches_idx[sw3.getOpenflowID()] = sw3 # start callbacks self.controller.start_callbacks.append(lambda: self.controller.install()) self.controller.start_callbacks.append(lambda: self.controller.addSwitch(sw1)) self.controller.start_callbacks.append(lambda: self.controller.addSwitch(sw2)) self.controller.start_callbacks.append(lambda: self.controller.addSwitch(sw3))
def initTopology(self, topo): self.controller = EateController(version=config.get("eate_model.app_version")) s_1 = OpenflowSwitch(name="s_1", port_count=3+1, of_id=1, expire_entries=config.get("model.flow_entry_expiration")) s_2 = OpenflowSwitch(name="s_2", port_count=3+1, of_id=2, expire_entries=config.get("model.flow_entry_expiration")) s_3 = OpenflowSwitch(name="s_3", port_count=2+1, of_id=3, expire_entries=config.get("model.flow_entry_expiration")) s_4 = OpenflowSwitch(name="s_4", port_count=2+1, of_id=4, expire_entries=config.get("model.flow_entry_expiration")) s_5 = OpenflowSwitch(name="s_5", port_count=3+1, of_id=5, expire_entries=config.get("model.flow_entry_expiration")) s_6 = OpenflowSwitch(name="s_6", port_count=6+1, of_id=6, expire_entries=config.get("model.flow_entry_expiration")) s_7 = OpenflowSwitch(name="s_7", port_count=2+1, of_id=7, expire_entries=config.get("model.flow_entry_expiration")) s_8 = OpenflowSwitch(name="s_8", port_count=2+1, of_id=8, expire_entries=config.get("model.flow_entry_expiration")) s_9 = OpenflowSwitch(name="s_9", port_count=3+1, of_id=9, expire_entries=config.get("model.flow_entry_expiration")) s_10 = OpenflowSwitch(name="s_10", port_count=3+1, of_id=10, expire_entries=config.get("model.flow_entry_expiration")) hb_ip = (10, 0, 0, 11) hc_ip = (10, 0, 0, 12) hd_ip = (10, 0, 0, 13) he_ip = (10, 0, 0, 14) hb_mac = (10, 0, 0, 0, 0, 0x0B) hc_mac = (10, 0, 0, 0, 0, 0x0C) hd_mac = (10, 0, 0, 0, 0, 0x0D) he_mac = (10, 0, 0, 0, 0, 0x0E) hb = TcpClient(name="B", mymac=hb_mac, myip=hb_ip, destip=[he_ip], pkts=self.config.get("eate_model.connections")) #, h1ip = h_x1_ip, h2ip=h_y1_ip) hc = TcpClient(name="C", mymac=hc_mac, myip=hc_ip, destip=[hd_ip], pkts=self.config.get("eate_model.connections")) hd = TcpServer(name="D", mymac=hd_mac, myip=hd_ip) he = TcpServer(name="E", mymac=he_mac, myip=he_ip) hb.initTopology({0: (s_1, 3)}) hc.initTopology({0: (s_2, 3)}) hd.initTopology({0: (s_9, 3)}) he.initTopology({0: (s_10, 3)}) s_1.initTopology({1: (s_5, 1), 2: (s_3, 1), 3: (hb, 0)}) s_2.initTopology({1: (s_5, 2), 2: (s_7, 1), 3: (hc, 0)}) s_3.initTopology({1: (s_1, 2), 2: (s_4, 1)}) s_4.initTopology({1: (s_3, 2), 2: (s_9, 2)}) s_5.initTopology({1: (s_1, 1), 2: (s_2, 1), 3: (s_6, 1)}) s_6.initTopology({1: (s_5, 3), 2: (s_10, 1), 3: (s_9, 1)}) s_7.initTopology({1: (s_2, 2), 2: (s_8, 1)}) s_8.initTopology({1: (s_7, 2), 2: (s_10, 2)}) s_9.initTopology({1: (s_6, 3), 2: (s_4, 2), 3: (hd, 0)}) s_10.initTopology({1: (s_6, 2), 2: (s_8, 2), 3: (he, 0)}) # s_1.setPortsCanFail([1,2]) # s_2.setPortsCanFail([1,2]) # s_3.setPortsCanFail([2]) # s_4.setPortsCanFail([2]) # s_5.setPortsCanFail([3]) # s_6.setPortsCanFail([2,3]) # s_7.setPortsCanFail([2]) # s_8.setPortsCanFail([2]) self.clients.append(hb) self.clients.append(hc) self.clients.append(hd) self.clients.append(he) self.switches.append(s_1) self.switches.append(s_2) self.switches.append(s_3) self.switches.append(s_4) self.switches.append(s_5) self.switches.append(s_6) self.switches.append(s_7) self.switches.append(s_8) self.switches.append(s_9) self.switches.append(s_10) self.switches_idx[s_1.getOpenflowID()] = s_1 self.switches_idx[s_2.getOpenflowID()] = s_2 self.switches_idx[s_3.getOpenflowID()] = s_3 self.switches_idx[s_4.getOpenflowID()] = s_4 self.switches_idx[s_5.getOpenflowID()] = s_5 self.switches_idx[s_6.getOpenflowID()] = s_6 self.switches_idx[s_7.getOpenflowID()] = s_7 self.switches_idx[s_8.getOpenflowID()] = s_8 self.switches_idx[s_9.getOpenflowID()] = s_9 self.switches_idx[s_10.getOpenflowID()] = s_10 # Switch failures self.setSwitchFailuresCount(2) hb.controller = self.controller hc.controller = self.controller hd.controller = self.controller he.controller = self.controller #start callbacks self.controller.start_callbacks.append(lambda: self.controller.install()) self.controller.start_callbacks.append(lambda: self.controller.addSwitch(s_1)) self.controller.start_callbacks.append(lambda: self.controller.addSwitch(s_2)) self.controller.start_callbacks.append(lambda: self.controller.addSwitch(s_3)) self.controller.start_callbacks.append(lambda: self.controller.addSwitch(s_4)) self.controller.start_callbacks.append(lambda: self.controller.addSwitch(s_5)) self.controller.start_callbacks.append(lambda: self.controller.addSwitch(s_6)) self.controller.start_callbacks.append(lambda: self.controller.addSwitch(s_7)) self.controller.start_callbacks.append(lambda: self.controller.addSwitch(s_8)) self.controller.start_callbacks.append(lambda: self.controller.addSwitch(s_9)) self.controller.start_callbacks.append(lambda: self.controller.addSwitch(s_10))
def initTopology(self, topo): self.controller = EateController(version=config.get("eate_model.app_version")) s_b = OpenflowSwitch(name="s_b", port_count=3+1, of_id=1, expire_entries=config.get("model.flow_entry_expiration")) s_c = OpenflowSwitch(name="s_c", port_count=4+1, of_id=2, expire_entries=config.get("model.flow_entry_expiration")) s_i = OpenflowSwitch(name="s_i", port_count=2+1, of_id=3, expire_entries=config.get("model.flow_entry_expiration")) h_b1_ip = (10, 0, 0, 11) h_x1_ip = (10, 0, 0, 13) h_y1_ip = (10, 0, 0, 14) h_b1_mac = (10, 0, 0, 0, 0, 0x0B) h_x1_mac = (10, 0, 0, 0, 0, 0x0C) h_y1_mac = (10, 0, 0, 0, 0, 0x0D) h_b1 = TcpClient(name="h_b1", mymac=h_b1_mac, myip=h_b1_ip, destip=[h_x1_ip, h_y1_ip], pkts=config.get("eate_model.connections")) #, h1ip = h_x1_ip, h2ip=h_y1_ip) h_x1 = TcpServer(name="h_x1", mymac=h_x1_mac, myip=h_x1_ip) h_y1 = TcpServer(name="h_y1", mymac=h_y1_mac, myip=h_y1_ip) h_b1.initTopology({0: (s_b, 3)}) h_x1.initTopology({0: (s_c, 3)}) h_y1.initTopology({0: (s_c, 4)}) s_b.initTopology({1: (s_i, 1), 2: (s_c, 1), 3: (h_b1, 0)}) s_c.initTopology({1: (s_b, 2), 2: (s_i, 2), 3: (h_x1, 0), 4: (h_y1, 0)}) s_i.initTopology({1: (s_b, 1), 2: (s_c, 2)}) self.clients.append(h_b1) self.clients.append(h_x1) self.clients.append(h_y1) self.switches.append(s_b) self.switches.append(s_c) self.switches.append(s_i) self.switches_idx[s_b.getOpenflowID()] = s_b self.switches_idx[s_c.getOpenflowID()] = s_c self.switches_idx[s_i.getOpenflowID()] = s_i h_x1.controller = self.controller #start callbacks self.controller.start_callbacks.append(lambda: self.controller.install()) self.controller.start_callbacks.append(lambda: self.controller.addSwitch(s_b)) self.controller.start_callbacks.append(lambda: self.controller.addSwitch(s_c)) self.controller.start_callbacks.append(lambda: self.controller.addSwitch(s_i))