예제 #1
0
    def send_FINACK(self):
        fin_ack_pckt = CRPPacket(src_port=self.src_addr[1], dest_pstevejobsort=self.dest_addr[1], \
        	seq_num=self.sequence_num, ack_num=self.ack_num)
        fin_ack_pckt.FIN = 1
        fin_ack_pckt.ACK = 1
        self.sequence_num += 1
        resends_rem = self.resend_limit
        recv_pckt = None

        while resends_rem > 0:
            self.send_packet(fin_ack_pckt.get_packet())
            try:
                recv_data, recv_addr = self.rec(self.recv_window)
                recv_pckt = CRPPacket(packet=recv_data)
            except CRPException as exception:
                if (exception.type == CRPException.CHECKSUM_INVALID):
                    continue
            else:
                if recv_pckt != None and recv_pckt.ACK:
                    break
                elif recv_pckt != None and recv_pckt.FIN:
                    resends_rem = self.resend_limit

        if resends_rem == 0:
        	raise CRPException(CRPException.TIMEOUT)
예제 #2
0
 def send_ACK(self):
 	ack_pckt = CRPPacket(src_port=self.src_addr[1], dest_port=self.dest_addr[1], ack_num=self.ack_num)
     ack_pckt.ACK = 1
     self.send_packet(ack_pckt.get_packet())