def checkBarrier(self): msg, pkt = self.controller.transact(message.barrier_request(), timeout=60) self.assertNotEqual(msg, None, "Barrier failed") while self.controller.packets: msg = self.controller.packets.pop(0)[0] self.assertNotEqual(msg.header.type, message.OFPT_ERROR, "Error received")
def runTest(self): logging = get_logger() logging.info("Running Grp100No80 BadRequestBadLength test") #In Message module at pack time the length is computed #avoid this by using cstruct module logging.info("Sending barrier_request message..") stats_request = message.barrier_request() header=ofp.ofp_header() header.type = ofp.OFPT_BARRIER_REQUEST # normal the header length is 12bytes changed it to 18bytes header.length=5; packed=header.pack()+stats_request.pack() sleep(2) rv=self.controller.message_send(packed) sleep(2) self.assertTrue(rv != -1,"Unable to send the message") logging.info("Waiting for OFPT_ERROR message..") (response, pkt) = self.controller.poll(exp_msg=ofp.OFPT_ERROR, timeout=10) self.assertTrue(response is not None, 'Switch did not reply with an error message') self.assertTrue(response.type==ofp.OFPET_BAD_REQUEST, 'Error type is not OFPET_BAD_REQUEST') self.assertTrue(response.code==ofp.OFPBRC_BAD_LEN, 'Error code is not OFPBRC_BAD_LEN got {0}'.format(response.code))
def do_barrier(ctrl): """ Do a barrier command Return 0 on success, -1 on error """ b = message.barrier_request() (resp, pkt) = ctrl.transact(b) # We'll trust the transaction processing in the controller that xid matched if not resp: return -1 return 0
def runTest(self): logging.info("Running Grp20No80 Barrier_Request_Reply test") logging.info("Sending Barrier Request") logging.info("Expecting a Barrier Reply with same xid") # Send Barrier Request request = message.barrier_request() (response, pkt) = self.controller.transact(request) self.assertEqual(response.header.type, ofp.OFPT_BARRIER_REPLY, "response is not barrier_reply") self.assertEqual(request.header.xid, response.header.xid, "response xid != request xid")
def runTest(self): of_logger.info("Running Barrier_Request_Reply test") of_logger.info("Sending Barrier Request") of_logger.info("Expecting a Barrier Reply with same xid") #Send Barrier Request request = message.barrier_request() (response, pkt) = self.controller.transact(request) self.assertEqual(response.header.type, ofp.OFPT_BARRIER_REPLY, 'response is not barrier_reply') self.assertEqual(request.header.xid, response.header.xid, 'response xid != request xid')
def runTest(self): logging = get_logger() logging.info("Running Grp20No80 Barrier_Request_Reply test") logging.info("Sending OFPT_BARRIER_REQUEST") #Send Barrier Request request = message.barrier_request() (response,pkt) = self.controller.transact(request) logging.info("Expecting a OFPT_BARRIER_REPLY with same header and xid") self.assertEqual(response.header.type, ofp.OFPT_BARRIER_REPLY,'response is not barrier_reply') self.assertEqual(request.header.xid, response.header.xid, 'response xid != request xid') logging.info("received OFPT_BARRIER_REPLY with same header and xid")
def runTest(self): logging = get_logger() logging.info("Running Grp20No80 Barrier_Request_Reply test") logging.info("Sending OFPT_BARRIER_REQUEST") #Send Barrier Request request = message.barrier_request() (response, pkt) = self.controller.transact(request) logging.info("Expecting a OFPT_BARRIER_REPLY with same header and xid") self.assertEqual(response.header.type, ofp.OFPT_BARRIER_REPLY, 'response is not barrier_reply') self.assertEqual(request.header.xid, response.header.xid, 'response xid != request xid') logging.info("received OFPT_BARRIER_REPLY with same header and xid")