diff --git a/UDP-client-server.py b/UDP-client-server.py index 092c374b0de0c1b7c8739e699444bae2cf7e243b..8d1f6f667e8d138837b8657a2c6e2f644329a51c 100644 --- a/UDP-client-server.py +++ b/UDP-client-server.py @@ -8,13 +8,15 @@ from array import * #DEFINE INPUTS HERE #CLIENT - SENDER UDP_DEST_IP = '::1' # IP ADDRESS TO SEND DATAGRAMS TO (v4 or v6) +#UDP_DEST_IP = '0.0.0.0' # IP ADDRESS TO SEND DATAGRAMS TO (v4 or v6) UDP_DEST_PORT = 15005 # IP PORT TO SEND DATAGRAMS TO PACKET_SIZE = 200 # DATAGRAM SIZE IN BYTES -NR_OF_PACKETS = 10 # TOTAL NR. OF PACKETS TO SEND +NR_OF_PACKETS = 100 # TOTAL NR. OF PACKETS TO SEND PACKETS_PER_SEC = 100 # PACKETS PER SECOND # CLIENT - RECEIVER -UDP_RECEIVE_IP = '::1' # LISTENING IP ADDRESS (v4 or v6) +UDP_RECEIVE_IP = '::1' # LISTENING IP ADDRESS (v6) +#UDP_RECEIVE_IP = '0.0.0.0' # LISTENING IP ADDRESS (v4) UDP_RECEIVE_PORT = 55555 # IP PORT TO LISTEN FOR INCOMING PACKETS BUFFER = 4096 @@ -117,7 +119,7 @@ def udp_client_send(UDP_DEST_IP, UDP_DEST_PORT, packet_count_snd = packet_count_snd + 1 #WAIT 5SEC FOR ALL PACKETS TO ARRIVE - time.sleep(5) + time.sleep(3) # Perhaps create a custom object where we store the statistics? # Or from here save it directly into the database? @@ -127,16 +129,19 @@ def udp_client_send(UDP_DEST_IP, UDP_DEST_PORT, print packet_count_rcvd, 'packets received' print 'packet loss ratio = ', round(PLR, 3), '%' - print 'range =', (max_delay - min_delay) + if (max_delay - min_delay != -100): + print 'max_delay = ', max_delay + print 'min_delay = ', min_delay + print 'range = ', (max_delay - min_delay) #CALCULATE THE STANDARD DEVIATION - - print 'std. dev.: ', np.std(rt_delay_array) + if rt_delay_array: + print 'std.dev = ', np.std(rt_delay_array) if packet_count_rcvd == 0: pass else: - print 'average rtt = ', cumulative_delay / packet_count_rcvd + print 'avg.rtt = ', cumulative_delay / packet_count_rcvd #START THE THREADS FOR SENDER AND RECEIVER if __name__ == "__main__":