def controllerSetup(self, host, port): self.controller = controller.Controller(host=host,port=port) # clean_shutdown should be set to False to force quit app self.clean_shutdown = True self.controller.start() #@todo Add an option to wait for a pkt transaction to ensure version # compatibilty? self.controller.connect(timeout=10) self.assertTrue(self.controller.active, "Controller startup failed, not active") self.assertTrue(self.controller.switch_addr is not None, "Controller startup failed, no switch addr") request = message.features_request() reply, pkt = self.controller.transact(request, timeout=20) self.assertTrue(reply is not None, "Did not complete features_request for handshake") serial_failover_logger.info("Connected " + str(self.controller.switch_addr)) # send echo request and wait for reply request = message.echo_request() response, pkt = self.controller.transact(request) self.assertEqual(response.header.type, ofp.OFPT_ECHO_REPLY, 'response is not echo_reply') self.assertEqual(request.header.xid, response.header.xid, 'response xid != request xid') self.assertEqual(len(response.data), 0, 'response data non-empty')
def controllerSetup(self, host, port): self.controller = controller.Controller(host=host, port=port) # clean_shutdown should be set to False to force quit app self.clean_shutdown = True self.controller.start() #@todo Add an option to wait for a pkt transaction to ensure version # compatibilty? self.controller.connect(timeout=10) self.assertTrue(self.controller.active, "Controller startup failed, not active") self.assertTrue(self.controller.switch_addr is not None, "Controller startup failed, no switch addr") request = message.features_request() reply, pkt = self.controller.transact(request, timeout=20) self.assertTrue(reply is not None, "Did not complete features_request for handshake") serial_failover_logger.info("Connected " + str(self.controller.switch_addr)) # send echo request and wait for reply request = message.echo_request() response, pkt = self.controller.transact(request) self.assertEqual(response.header.type, ofp.OFPT_ECHO_REPLY, 'response is not echo_reply') self.assertEqual(request.header.xid, response.header.xid, 'response xid != request xid') self.assertEqual(len(response.data), 0, 'response data non-empty')
def runTest(self): request = message.echo_request() response, pkt = self.controller.transact(request) self.assertEqual(response.header.type, ofp.OFPT_ECHO_REPLY, 'response is not echo_reply') self.assertEqual(request.header.xid, response.header.xid, 'response xid != request xid') self.assertEqual(len(response.data), 0, 'response data non-empty')
def runTest(self): request = message.echo_request() response, pkt = self.controller.transact(request) self.assertTrue(response is not None, "Did not get echo reply") self.assertEqual(response.header.type, ofp.OFPT_ECHO_REPLY, 'response is not echo_reply') self.assertEqual(request.header.xid, response.header.xid, 'response xid != request xid') self.assertEqual(len(response.data), 0, 'response data non-empty')
def runTest(self): request = message.echo_request() request.data = 'OpenFlow Will Rule The World' response, _ = self.controller.transact(request) self.assertEqual(response.header.type, ofp.OFPT_ECHO_REPLY, 'response is not echo_reply') self.assertEqual(request.header.xid, response.header.xid, 'response xid != request xid') self.assertEqual(request.data, response.data, 'response data does not match request')
def runTest(self): # Send echo_request to verify connection logging.info("Running TestNo20 UserConfigPort test") request = message.echo_request() (response, pkt) = self.controller.transact(request) self.assertEqual(response.header.type, ofp.OFPT_ECHO_REPLY,'response is not echo_reply') self.assertEqual(request.header.xid, response.header.xid, 'response xid != request xid') self.assertTrue(response.header.version == 0x01, 'switch openflow-version field is not 1.0.1') self.assertEqual(len(response.data), 0, 'response data non-empty') logging.info("Configured host : " + str(config["controller_host"]) + "Configured port : " + str(config["controller_port"]))
def runTest(self): logging.info("Running Grp20No110 Echo_Without_Body test") logging.info("Sending Echo Request") logging.info("Expecting a Echo Reply with version--1.0.0 and same xid") # Send echo_request request = message.echo_request() (response, pkt) = self.controller.transact(request) self.assertEqual(response.header.type, ofp.OFPT_ECHO_REPLY, "response is not echo_reply") self.assertEqual(request.header.xid, response.header.xid, "response xid != request xid") self.assertTrue(response.header.version == 0x01, "switch openflow-version field is not 1.0.1") self.assertEqual(len(response.data), 0, "response data non-empty")
def runTest(self): logging = get_logger() logging.info("Running Grp80No40 EchoWithoutData test") #Send Echo Request logging.info("Sending Echo Without Data ...") request = message.echo_request() (response, pkt) = self.controller.transact(request) #Verify Echo Reply is recieved self.assertTrue(response is not None, "Did not get echo reply (without data)") self.assertEqual(response.header.type, ofp.OFPT_ECHO_REPLY, 'Response is not echo_reply') self.assertEqual(request.header.xid, response.header.xid, 'Response xid does not match the request Xid')
def runTest(self): logging.info("Running Echo_Without_Body test") logging.info("Sending Echo Request") logging.info("Expecting a Echo Reply with version--1.0.0 and same xid") # Send echo_request request = message.echo_request() (response, pkt) = self.controller.transact(request) self.assertEqual(response.header.type, ofp.OFPT_ECHO_REPLY, 'response is not echo_reply') self.assertEqual(request.header.xid, response.header.xid, 'response xid != request xid') self.assertTrue(response.header.version == 0x01, 'switch openflow-version field is not 1.0.1') self.assertEqual(len(response.data), 0, 'response data non-empty')
def runTest(self): # Send echo_request to verify connection logging = get_logger() logging.info("Running TestNo20 UserConfigPort test") request = message.echo_request() logging.info("Sending an Echo request message") (response, pkt) = self.controller.transact(request) self.assertEqual(response.header.type, ofp.OFPT_ECHO_REPLY, 'response is not echo_reply') logging.info("Received message type is echo_reply") self.assertEqual(request.header.xid, response.header.xid, 'response xid != request xid') self.assertTrue(response.header.version == 0x01, 'switch openflow-version field is not 1.0') logging.info("Configured host : " + str(config["controller_host"]) + "Configured port : " + str(config["controller_port"]))
def runTest(self): logging.info("Running Error Msg test") #Send Echo Request logging.info("Sending a Echo request with a version which is not supported by the switch") request=message.echo_request() request.header.version=0 self.controller.message_send(request) logging.info("Waiting for a OFPT_ERROR msg on the control plane...") (response, pkt) = self.controller.poll(exp_msg=ofp.OFPT_ERROR, timeout=5) self.assertTrue(response is not None, 'Switch did not reply with error message') self.assertTrue(response.type==ofp.OFPET_BAD_REQUEST, 'Message field type is not OFPET_BAD_REQUEST') self.assertTrue(response.type==ofp.OFPET_BAD_REQUEST, 'Message field code is not OFPBRC_BAD_VERSION')
def runTest(self): logging.info("Running EchoWithData test") #Send Echo Request logging.info("Sending Echo With Data ...") request = message.echo_request() request.data = 'OpenFlow Will Rule The World' self.controller.message_send(request) #Verify Echo Reply is recieved logging.info("Waiting for Echo Reply with data field copied from Echo Request") (response, pkt) = self.controller.poll(exp_msg=ofp.OFPT_ECHO_REPLY, timeout=1) self.assertTrue(response is not None, "Did not get echo reply (with data)") self.assertEqual(response.header.type, ofp.OFPT_ECHO_REPLY, 'Response is not echo_reply') self.assertEqual(request.header.xid, response.header.xid, 'Response xid does not match the request Xid') self.assertEqual(request.data, response.data, 'Response data does not match request data')
def runTest(self): logging = get_logger() logging.info("Running Grp80No30 Error Msg test") #Send Echo Request logging.info( "Sending a Echo request with a version which is not supported by the switch" ) request = message.echo_request() request.header.version = 0 rv = self.controller.message_send(request) self.assertTrue(rv is not None, "Unable to send the message") logging.info("Waiting for a OFPT_ERROR msg on the control plane...") (response, pkt) = self.controller.poll(exp_msg=ofp.OFPT_ERROR, timeout=5) self.assertTrue(response is not None, 'Switch did not reply with error message') self.assertTrue(response.type == ofp.OFPET_BAD_REQUEST, 'Message field type is not OFPET_BAD_REQUEST') self.assertTrue(response.code == ofp.OFPBRC_BAD_VERSION, 'Message field code is not OFPBRC_BAD_VERSION')
def runTest(self): logging = get_logger() logging.info("Running Grp80No40 EchoWithData test") #Send Echo Request logging.info("Sending Echo With Data ...") request = message.echo_request() request.data = 'OpenFlow Will Rule The World' rv = self.controller.message_send(request) self.assertTrue(rv is not None, "Unable to send the message") #Verify Echo Reply is recieved logging.info( "Waiting for Echo Reply with data field copied from Echo Request") (response, pkt) = self.controller.poll(exp_msg=ofp.OFPT_ECHO_REPLY, timeout=1) self.assertTrue(response is not None, "Did not get echo reply (with data)") self.assertEqual(response.header.type, ofp.OFPT_ECHO_REPLY, 'Response is not echo_reply') self.assertEqual(request.header.xid, response.header.xid, 'Response xid does not match the request Xid') self.assertEqual(request.data, response.data, 'Response data does not match request data')