def runTest(self): logging = get_logger() logging.info("Running Grp80No300 Test") of_ports = config["port_map"].keys() of_ports.sort() logging.info("Sending Get Config Request ") request = message.get_config_request() (reply, pkt) = self.controller.transact(request) self.assertTrue(reply is not None, "Failed to get any reply") self.assertEqual(reply.header.type, ofp.OFPT_GET_CONFIG_REPLY, 'Response is not Config Reply') old_flags = 0 old_flags = reply.flags logging.info("Sending Set Config Request...") req = message.set_config() if old_flags != 3: req.flags = 3 new_flags = req.flags rv = self.controller.message_send(req) self.assertTrue(rv is not None, "Unable to send the message") #Send get_config_request -- verify change came into effect logging.info("Sending Get Config Request...") request = message.get_config_request() (rep, pkt) = self.controller.transact(request) self.assertTrue(rep is not None, "Failed to get any reply") self.assertEqual(rep.header.type, ofp.OFPT_GET_CONFIG_REPLY, 'Response is not Config Reply') try: self.assertEqual( rep.flags, new_flags, "frag flags could not be set expected {0} got {1}".format( new_flags, rep.flags)) finally: logging.info("Reverting the changes") req = message.set_config() req.flags = old_flags rv = None rv = self.controller.message_send(req) self.assertTrue(rv is not None, " Unable to send the set_config message") request = message.get_config_request() rep1 = None (rep1, pkt) = self.controller.transact(request) self.assertTrue(rep1 is not None, "Failed to get a reply") self.assertTrue(rep1.header.type == ofp.OFPT_GET_CONFIG_REPLY, 'Response is not config Reply') self.assertTrue(rep1.flags == old_flags, "Changes could not be reverted") else: logging.info("The Flag already set to OFPC_FRAG_MASK")
def runTest(self): logging = get_logger() logging.info("Running Grp80No300 Test") of_ports = config["port_map"].keys() of_ports.sort() logging.info("Sending Get Config Request ") request = message.get_config_request() (reply, pkt) = self.controller.transact(request) self.assertTrue(reply is not None, "Failed to get any reply") self.assertEqual(reply.header.type, ofp.OFPT_GET_CONFIG_REPLY,'Response is not Config Reply') old_flags = 0 old_flags = reply.flags logging.info("Sending Set Config Request...") req = message.set_config() if old_flags != 3 : req.flags = 3 new_flags = req.flags rv=self.controller.message_send(req) self.assertTrue(rv is not None,"Unable to send the message") #Send get_config_request -- verify change came into effect logging.info("Sending Get Config Request...") request = message.get_config_request() (rep, pkt) = self.controller.transact(request) self.assertTrue(rep is not None, "Failed to get any reply") self.assertEqual(rep.header.type, ofp.OFPT_GET_CONFIG_REPLY,'Response is not Config Reply') try : self.assertEqual(rep.flags,new_flags, "frag flags could not be set expected {0} got {1}" .format(new_flags, rep.flags)) finally : logging.info("Reverting the changes") req=message.set_config() req.flags=old_flags rv=None rv=self.controller.message_send(req) self.assertTrue(rv is not None, " Unable to send the set_config message") request = message.get_config_request() rep1=None (rep1, pkt) = self.controller.transact(request) self.assertTrue(rep1 is not None, "Failed to get a reply") self.assertTrue(rep1.header.type==ofp.OFPT_GET_CONFIG_REPLY, 'Response is not config Reply') self.assertTrue(rep1.flags==old_flags, "Changes could not be reverted") else : logging.info("The Flag already set to OFPC_FRAG_MASK")
def runTest(self): logging.info("Running SetConfigRequest Test") of_ports = config["port_map"].keys() of_ports.sort() #Send get_config_request -- retrive miss_send_len field logging.info("Sending Get Config Request ") request = message.get_config_request() (reply, pkt) = self.controller.transact(request) self.assertTrue(reply is not None, "Failed to get any reply") self.assertEqual(reply.header.type, ofp.OFPT_GET_CONFIG_REPLY,'Response is not Config Reply') miss_send_len = 0 miss_send_len = reply.miss_send_len old_flags = 0 old_flags = reply.flags #Send set_config_request --- set a different miss_sen_len field and flag logging.info("Sending Set Config Request...") req = message.set_config() if miss_send_len < 65400 :# Max miss_send len is 65535 req.miss_send_len = miss_send_len + 100 new_miss_send_len = req.miss_send_len else : req.miss_send_len = miss_send_len - 100 new_miss_send_len = req.miss_send_len if old_flags > 0 : req.flags = old_flags-1 new_flags = req.flags else : req.flags = old_flags+1 new_flags = req.flags rv=self.controller.message_send(req) self.assertTrue(rv is not None,"Unable to send the message") #Send get_config_request -- verify change came into effect logging.info("Sending Get Config Request...") request = message.get_config_request() (rep, pkt) = self.controller.transact(request) self.assertTrue(rep is not None, "Failed to get any reply") self.assertEqual(rep.header.type, ofp.OFPT_GET_CONFIG_REPLY,'Response is not Config Reply') self.assertEqual(rep.miss_send_len,new_miss_send_len, "miss_send_len configuration parameter could not be set") self.assertEqual(rep.flags,new_flags, "frag flags could not be set")
def runTest(self): logging.info("Running GetConfigReply Test") #Send get_config_request logging.info("Sending Get Config Request...") request = message.get_config_request() (reply, pkt) = self.controller.transact(request) #Verify get_config_reply is recieved logging.info("Expecting GetConfigReply ") self.assertTrue(reply is not None, "Failed to get any reply") self.assertEqual(reply.header.type, ofp.OFPT_GET_CONFIG_REPLY,'Response is not Config Reply') self.assertEqual(reply.header.xid,request.header.xid,'Transaction id does not match') if reply.miss_send_len == 0 : logging.info ("the switch must send zero-size packet_in message") else : logging.info("miss_send_len: " + str(reply.miss_send_len)) if reply.flags == 0 : logging.info("OFPC_FRAG_NORMAL:No special handling for fragments.") elif reply.flags == 1 : logging.info("OFPC_FRAG_DROP:Drop fragments.") elif reply.flags == 2 : logging.info("OFPC_FRAG_REASM:ReasSsemble") elif reply.flags == 3: logging.info("OFPC_FRAG_MASK")
def runTest(self): logging = get_logger() logging.info("Running Grp20No20 Configuration_Request test ") of_ports = config["port_map"].keys() of_ports.sort() #Clear switch state rc = delete_all_flows(self.controller) self.assertEqual(rc, 0, "Failed to delete all flows") logging.info("Sending OFPT_GET_CONFIG_REQUEST ") request = message.get_config_request() rv = self.controller.message_send(request) self.assertTrue(rv != -1, " Not able to send get_config request.") logging.info("Expecting OFPT_GET_CONFIG_REPLY ") (response, pkt) = self.controller.poll(exp_msg=ofp.OFPT_GET_CONFIG_REPLY, timeout=2) self.assertTrue(response is not None, 'Did not receive OFPT_GET_CONFIG_REPLY') logging.info("Received OFPT_GET_CONFIG_REPLY ")
def runTest(self): logging = get_logger() logging.info("Running Grp80No200 GetConfigReply Test") #Send get_config_request logging.info("Sending Get Config Request...") request = message.get_config_request() (reply, pkt) = self.controller.transact(request) #Verify get_config_reply is recieved logging.info("Expecting GetConfigReply ") self.assertTrue(reply is not None, "Failed to get any reply") self.assertEqual(reply.header.type, ofp.OFPT_GET_CONFIG_REPLY, 'Response is not Config Reply') self.assertEqual(reply.header.xid, request.header.xid, 'Transaction id does not match') #Grp80No220 if reply.flags == 1: logging.info("OFPC_FRAG_DROP:Drop fragments.") #Grp80No230 elif reply.flags == 2: logging.info("OFPC_FRAG_REASM:ReasSsemble") #Grp80No240 elif reply.flags == 3: logging.info("OFPC_FRAG_MASK")
def runTest(self): logging = get_logger() logging.info("Running Grp80No260 SetConfigRequest Test") of_ports = config["port_map"].keys() of_ports.sort() #Send get_config_request -- retrive miss_send_len field logging.info("Sending Get Config Request ") request = message.get_config_request() (reply, pkt) = self.controller.transact(request) self.assertTrue(reply is not None, "Failed to get any reply") self.assertEqual(reply.header.type, ofp.OFPT_GET_CONFIG_REPLY, 'Response is not Config Reply') miss_send_len = 0 miss_send_len = reply.miss_send_len old_flags = 0 old_flags = reply.flags #Send set_config_request --- set a different miss_sen_len field and flag logging.info("Sending Set Config Request...") req = message.set_config() if miss_send_len < 65400: # Max miss_send len is 65535 req.miss_send_len = miss_send_len + 100 new_miss_send_len = req.miss_send_len else: req.miss_send_len = miss_send_len - 100 new_miss_send_len = req.miss_send_len rv = self.controller.message_send(req) self.assertTrue(rv is not None, "Unable to send the message") #Send get_config_request -- verify change came into effect logging.info("Sending Get Config Request...") request = message.get_config_request() (rep, pkt) = self.controller.transact(request) self.assertTrue(rep is not None, "Failed to get any reply") self.assertEqual(rep.header.type, ofp.OFPT_GET_CONFIG_REPLY, 'Response is not Config Reply') self.assertEqual( rep.miss_send_len, new_miss_send_len, "miss_send_len configuration parameter could not be set")
def runTest(self): logging = get_logger() logging.info( "Running Grp80No250 OFPT_GET_CONFIG_REPLY miss_send_len Test") rc = delete_all_flows(self.controller) self.assertTrue(rc != -1, "Error installing flow mod") self.assertEqual(do_barrier(self.controller), 0, "Barrier failed") #Send get_config_request logging.info("Sending Get Config Request...") request = message.get_config_request() (reply, pkt) = self.controller.transact(request) #Verify get_config_reply is recieved logging.info("Expecting GetConfigReply ") self.assertTrue(reply is not None, "Failed to get any reply") self.assertEqual(reply.header.type, ofp.OFPT_GET_CONFIG_REPLY, 'Response is not Config Reply') self.assertEqual(reply.header.xid, request.header.xid, 'Transaction id does not match') miss_send_len = reply.miss_send_len of_ports = config["port_map"].keys() of_ports.sort() logging.info("miss_send_len: " + str(miss_send_len)) # Send packet to trigger packet_in event # TODO: pkt size SHOULD >= miss_send_len, need a value based on miss_send_len? pkt = simple_tcp_packet(pktlen=1500) self.dataplane.send(of_ports[0], str(pkt)) #Verify packet_in generated (response, raw) = self.controller.poll(ofp.OFPT_PACKET_IN, timeout=3) self.assertTrue(response is not None, 'Packet In not received on control plane') self.assertEqual( response.reason, ofp.OFPR_NO_MATCH, 'PacketIn received for reason other than OFPR_NO_MATCH. Reason was {0}.' .format(response.reason)) #Verify buffer_id field and data field if response.buffer_id == 0xFFFFFFFF: logging.info("PacketIn message is unbuffered") self.assertTrue( len(response.data) == len(str(pkt)), "buffer_id of packet_in is -1, however data field of packet_in was the wrong size. Expected {0}, but received {1}" .format(len(str(pkt)), len(response.data))) elif (miss_send_len == 0): self.assertEqual(len(response.data), miss_send_len, "PacketIn Size is not equal to miss_send_len") else: self.assertTrue( len(response.data) >= miss_send_len, "PacketIn Size {0} is not atleast miss_send_len bytes {1}". format(len(response.data), miss_send_len))
def runTest(self): logging = get_logger() logging.info("Running Grp80No250 OFPT_GET_CONFIG_REPLY miss_send_len Test") rc = delete_all_flows(self.controller) self.assertTrue(rc != -1, "Error installing flow mod") self.assertEqual(do_barrier(self.controller), 0, "Barrier failed") #Send get_config_request logging.info("Sending Get Config Request...") request = message.get_config_request() (reply, pkt) = self.controller.transact(request) #Verify get_config_reply is recieved logging.info("Expecting GetConfigReply ") self.assertTrue(reply is not None, "Failed to get any reply") self.assertEqual(reply.header.type, ofp.OFPT_GET_CONFIG_REPLY,'Response is not Config Reply') self.assertEqual(reply.header.xid,request.header.xid,'Transaction id does not match') miss_send_len = reply.miss_send_len of_ports = config["port_map"].keys() of_ports.sort() logging.info("miss_send_len: " + str(miss_send_len)) # Send packet to trigger packet_in event # TODO: pkt size SHOULD >= miss_send_len, need a value based on miss_send_len? pkt = simple_tcp_packet(pktlen=1500) self.dataplane.send(of_ports[0],str(pkt)) #Verify packet_in generated (response, raw) = self.controller.poll(ofp.OFPT_PACKET_IN, timeout=3) self.assertTrue(response is not None, 'Packet In not received on control plane') self.assertEqual(response.reason, ofp.OFPR_NO_MATCH, 'PacketIn received for reason other than OFPR_NO_MATCH. Reason was {0}.'.format(response.reason)) #Verify buffer_id field and data field if response.buffer_id == 0xFFFFFFFF: logging.info("PacketIn message is unbuffered") self.assertTrue(len(response.data)==len(str(pkt)),"buffer_id of packet_in is -1, however data field of packet_in was the wrong size. Expected {0}, but received {1}".format(len(str(pkt)), len(response.data))) elif (miss_send_len==0): self.assertEqual(len(response.data),miss_send_len,"PacketIn Size is not equal to miss_send_len") else: self.assertTrue(len(response.data)>=miss_send_len,"PacketIn Size {0} is not atleast miss_send_len bytes {1}".format(len(response.data), miss_send_len))
def runTest(self): logging = get_logger() logging.info('Running Grp80No210 OFPC_FRAG_NORMAL') of_ports = config["port_map"].keys() of_ports.sort() self.assertTrue(len(of_ports) > 1, "Not enough ports for test") rc = delete_all_flows(self.controller) self.assertTrue(rc != -1, "Error installing flow mod") self.assertEqual(do_barrier(self.controller), 0, "Barrier failed") egress_port = of_ports[1] no_ports = set(of_ports).difference([egress_port]) yes_ports = of_ports[1] #Send get_config_request logging.info("Sending Get Config Request...") request = message.get_config_request() (reply, pkt) = self.controller.transact(request) #Verify get_config_reply is recieved logging.info("Expecting GetConfigReply ") self.assertTrue(reply is not None, "Failed to get any reply") self.assertEqual(reply.header.type, ofp.OFPT_GET_CONFIG_REPLY, 'Response is not Config Reply') self.assertEqual(reply.header.xid, request.header.xid, 'Transaction id does not match') if reply.flags == 0: logging.info("OFPC_FRAG_NORMAL:No special handling for fragments.") logging.info("Installing a flow with match on Ingress port") (pkt, match) = wildcard_all_except_ingress(self, of_ports, priority=0) frag_pkts = simple_frag_packets() for pkt in frag_pkts: self.dataplane.send(of_ports[0], str(pkt)) receive_pkt_check(self.dataplane, pkt, [yes_ports], no_ports, self)
def runTest(self): logging.info("Running Grp20No20 Configuration_Request test ") of_ports = config["port_map"].keys() of_ports.sort() # Clear switch state rc = delete_all_flows(self.controller) self.assertEqual(rc, 0, "Failed to delete all flows") logging.info("Sending OFPT_GET_CONFIG_REQUEST ") logging.info("Expecting OFPT_GET_CONFIG_REPLY ") request = message.get_config_request() rv = self.controller.message_send(request) self.assertTrue(rv != -1, " Not able to send get_config request.") (response, pkt) = self.controller.poll(exp_msg=ofp.OFPT_GET_CONFIG_REPLY, timeout=2) self.assertTrue(response is not None, "Did not receive OFPT_GET_CONFIG_REPLY")
def runTest(self): logging.info("Running Configuration_Request test ") of_ports = config["port_map"].keys() of_ports.sort() #Clear switch state delete_all_flows(self.controller) logging.info("Sending OFPT_GET_CONFIG_REQUEST ") logging.info("Expecting OFPT_GET_CONFIG_REPLY ") request = message.get_config_request() self.controller.message_send(request) (response, pkt) = self.controller.poll(exp_msg=ofp.OFPT_GET_CONFIG_REPLY, timeout=2) self.assertTrue(response is not None, 'Did not receive OFPT_GET_CONFIG_REPLY')
def runTest(self): logging = get_logger() logging.info('Running Grp80No210 OFPC_FRAG_NORMAL') of_ports = config["port_map"].keys() of_ports.sort() self.assertTrue(len(of_ports) > 1, "Not enough ports for test") rc = delete_all_flows(self.controller) self.assertTrue(rc != -1, "Error installing flow mod") self.assertEqual(do_barrier(self.controller), 0, "Barrier failed") egress_port=of_ports[1] no_ports=set(of_ports).difference([egress_port]) yes_ports = of_ports[1] #Send get_config_request logging.info("Sending Get Config Request...") request = message.get_config_request() (reply, pkt) = self.controller.transact(request) #Verify get_config_reply is recieved logging.info("Expecting GetConfigReply ") self.assertTrue(reply is not None, "Failed to get any reply") self.assertEqual(reply.header.type, ofp.OFPT_GET_CONFIG_REPLY,'Response is not Config Reply') self.assertEqual(reply.header.xid,request.header.xid,'Transaction id does not match') if reply.flags == 0 : logging.info("OFPC_FRAG_NORMAL:No special handling for fragments.") logging.info("Installing a flow with match on Ingress port") (pkt, match) = wildcard_all_except_ingress(self, of_ports, priority=0) frag_pkts = simple_frag_packets() for pkt in frag_pkts: self.dataplane.send(of_ports[0], str(pkt)) receive_pkt_check(self.dataplane, pkt,[yes_ports], no_ports, self)
def runTest(self): logging = get_logger() logging.info("Running Grp80No200 GetConfigReply Test") #Send get_config_request logging.info("Sending Get Config Request...") request = message.get_config_request() (reply, pkt) = self.controller.transact(request) #Verify get_config_reply is recieved logging.info("Expecting GetConfigReply ") self.assertTrue(reply is not None, "Failed to get any reply") self.assertEqual(reply.header.type, ofp.OFPT_GET_CONFIG_REPLY,'Response is not Config Reply') self.assertEqual(reply.header.xid,request.header.xid,'Transaction id does not match') #Grp80No220 if reply.flags == 1 : logging.info("OFPC_FRAG_DROP:Drop fragments.") #Grp80No230 elif reply.flags == 2 : logging.info("OFPC_FRAG_REASM:ReasSsemble") #Grp80No240 elif reply.flags == 3: logging.info("OFPC_FRAG_MASK")