diff --git a/UDP-client-server.py b/UDP-client-server.py index efa15edcbb097b09a8236255a8e2e25e88c725df..359df0b72739dfce4ad695ec44cd26f78dfd8ce9 100755 --- a/UDP-client-server.py +++ b/UDP-client-server.py @@ -6,6 +6,7 @@ from threading import Thread, Timer import numpy as np from array import * + #DEFINE INPUTS HERE #CLIENT - SENDER #UDP_DEST_IP = '::1' # IP ADDRESS TO SEND DATAGRAMS TO (v4 or v6) @@ -131,6 +132,7 @@ def udp_client_send(UDP_DEST_IP, UDP_DEST_PORT, # Or from here save it directly into the database? PLR = 100 - ((packet_count_rcvd * 100.) / packet_count_snd) + lost = packet_count_snd - packet_count_rcvd print('\n') print(packet_count_snd, 'packets sent') @@ -178,6 +180,7 @@ def udp_client_send(UDP_DEST_IP, UDP_DEST_PORT, * (avg_packet_delay / packet_wait_time) * 100) + 0.5) print('avg.rtt = ', avg_packet_delay) print('stability = ', network_stability) + print('Lost packets = ', lost) # Calculating MOS # http://en.wikipedia.org/wiki/Mean_opinion_score @@ -194,12 +197,13 @@ def udp_client_send(UDP_DEST_IP, UDP_DEST_PORT, else: R = 93.2 - (EffectiveLatency - 120) / 10 # Now, let's deduct 2.5 R values per percentage of packet loss - R = R - ((packet_count_sent - packet_count_rcvd) * 2.5) + R = R - (lost * 2.5) # Convert the R into an MOS value.(this is a known formula) mos = 1 + (0.035) * R + (.000007) * R * (R-60) * (100-R) print("MOS: ", mos) + #START THE THREADS FOR SENDER AND RECEIVER if __name__ == "__main__": receiver_thread = Thread(target=udp_client_receive,