def receive(self): message, addr = self._sender_socket.recvfrom(self._buffer_size) packetHeader = STPHeader(extractHeader(message)) self.writeToLog("rcv", getTime() - self._startTime, packetHeader.getType(), packetHeader.seqNum(), len(extractContent(message)), packetHeader.ackNum()) return message, addr
def transmitACKPacket(self, ack_number, isSyn, clientAddress): ackHeader = STPHeader(Receiver.current_ack_num, ack_number, 1, isSyn, 0, 0, False) ackPacket = STPPacket(ackHeader, "") self._receiver_socket.sendto(str(ackPacket).encode(), clientAddress) self.writeToLog("snd", getTime() - self._startTime, ackHeader.getType(), ackHeader.seqNum(), 0, ackHeader.ackNum()) Receiver.current_ack_num += 1