def send_acks(client_socket, seq_num): if seq_num == 1: new_packet = main.Packet("Ack", ack=1, seq=SEQ_NUMBER) toggle() else: new_packet = main.Packet("Ack", ack=1, seq=1) new_packet.deadline = time.time() + 100 print("sending ack with seq num = ", new_packet.seq_num) client_socket.sendto( json.dumps(new_packet, cls=main.MyEncoder).encode(), (Shared.SERVER_IP, Shared.SERVER_PORT))
def send_acks(client_socket): new_packet = main.Packet("Ack") new_packet.seq_num = SEQ_NUMBER new_packet.deadline = time.time() + 100 client_socket.sendto( json.dumps(new_packet, cls=main.MyEncoder).encode(), (Shared.SERVER_IP, Shared.SERVER_PORT))
def chunks_into_pkts(chunks): pkts = [] for i in range(len(chunks)): pkt = main.Packet() pkt.data = chunks[i] pkt.seq_num = i pkt.check_sum = main.calculate_checksum(pkt) pkts.append(pkt) main.drop_pkts(main.mapping(main.plp(1), len(pkts)), pkts) return pkts
def send_file_name(data, client_socket): new_packet = main.Packet(data, SEQ_NUMBER) new_packet.deadline = time.time() + 100 client_socket.sendto( json.dumps(new_packet, cls=main.MyEncoder).encode(), (Shared.SERVER_IP, Shared.SERVER_PORT))
#!/usr/bin/python import main import numpy for i in range(1, 11): cn, wlen, dn = main.DPCM_encode(i) main.Packet(cn, wlen, i) main.DPCM_decode(i) a = main.snr(i) print(a)