diff --git a/UDP-client-server.py b/UDP-client-server.py index 359df0b72739dfce4ad695ec44cd26f78dfd8ce9..2ac600b7e885a255f080d8102a261dbeae41f300 100755 --- a/UDP-client-server.py +++ b/UDP-client-server.py @@ -86,6 +86,17 @@ def udp_client_receive(UDP_RECEIVE_IP, UDP_RECEIVE_PORT): outfile.close() +#CALLBACK FUNCTION +def cb_event(recipient, threshold): + # TODO + + # Somebody call cb_event, identifying themselves with recipient + # defining their threshold value when they want to be notified + + # Create list with recipient, threshold + # Run as a separate thread and for example each 5 seconds check if + # any of the thresholds are exceeded. Notify recpient as needed. + print("TODO") #CLIENT SERVER SIDE def udp_client_send(UDP_DEST_IP, UDP_DEST_PORT, @@ -137,7 +148,8 @@ def udp_client_send(UDP_DEST_IP, UDP_DEST_PORT, print('\n') print(packet_count_snd, 'packets sent') print(packet_count_rcvd, 'packets received') - print('packet loss ratio = ', round(PLR, 3), '%') + print(lost, 'Lost packets') + print('packet loss ratio = ', round(PLR, 3), '%\n') if (max_delay - min_delay != -100): print('max_delay = ', max_delay) @@ -164,24 +176,18 @@ def udp_client_send(UDP_DEST_IP, UDP_DEST_PORT, for rt0, rt1 in zip(rt_delay_array[:-1], rt_delay_array[1:]): jitter += (np.fabs(rt0 - rt1) - jitter) / 16. - #jitter = jitter / (len(rt_delay_array) - 1) - print("jitter = ", jitter) print("jitter = ", jitter_2) #NETWORK STABILITY BASED ON PACKET LOSS AND DELAY, VALUE 0-100 - network_stability = 0 if packet_count_rcvd == 0: pass else: avg_packet_delay = cumulative_delay / packet_count_rcvd -#CALCULATE STABILITY - network_stability = int(((packet_count_rcvd / packet_count_snd)\ - * (avg_packet_delay / packet_wait_time) * 100) + 0.5) print('avg.rtt = ', avg_packet_delay) - print('stability = ', network_stability) - print('Lost packets = ', lost) + +#CALCULATE STABILITY # Calculating MOS # http://en.wikipedia.org/wiki/Mean_opinion_score #MOS Quality Impairment @@ -225,5 +231,7 @@ if __name__ == "__main__": sender_thread.start() while sender_thread.is_alive(): time.sleep(1) + + # While testing, end after one iteration sys.exit()