Skip to content
Snippets Groups Projects
Commit 316cf940 authored by Henrik Tjäder's avatar Henrik Tjäder
Browse files

Added placeholder CB, removed old stability function

parent 4f3dd3c4
No related branches found
No related tags found
No related merge requests found
...@@ -86,6 +86,17 @@ def udp_client_receive(UDP_RECEIVE_IP, UDP_RECEIVE_PORT): ...@@ -86,6 +86,17 @@ def udp_client_receive(UDP_RECEIVE_IP, UDP_RECEIVE_PORT):
outfile.close() 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 #CLIENT SERVER SIDE
def udp_client_send(UDP_DEST_IP, UDP_DEST_PORT, def udp_client_send(UDP_DEST_IP, UDP_DEST_PORT,
...@@ -137,7 +148,8 @@ 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('\n')
print(packet_count_snd, 'packets sent') print(packet_count_snd, 'packets sent')
print(packet_count_rcvd, 'packets received') 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): if (max_delay - min_delay != -100):
print('max_delay = ', max_delay) print('max_delay = ', max_delay)
...@@ -164,24 +176,18 @@ def udp_client_send(UDP_DEST_IP, UDP_DEST_PORT, ...@@ -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:]): for rt0, rt1 in zip(rt_delay_array[:-1], rt_delay_array[1:]):
jitter += (np.fabs(rt0 - rt1) - jitter) / 16. jitter += (np.fabs(rt0 - rt1) - jitter) / 16.
#jitter = jitter / (len(rt_delay_array) - 1)
print("jitter = ", jitter) print("jitter = ", jitter)
print("jitter = ", jitter_2) print("jitter = ", jitter_2)
#NETWORK STABILITY BASED ON PACKET LOSS AND DELAY, VALUE 0-100 #NETWORK STABILITY BASED ON PACKET LOSS AND DELAY, VALUE 0-100
network_stability = 0
if packet_count_rcvd == 0: if packet_count_rcvd == 0:
pass pass
else: else:
avg_packet_delay = cumulative_delay / packet_count_rcvd 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('avg.rtt = ', avg_packet_delay)
print('stability = ', network_stability)
print('Lost packets = ', lost)
#CALCULATE STABILITY
# Calculating MOS # Calculating MOS
# http://en.wikipedia.org/wiki/Mean_opinion_score # http://en.wikipedia.org/wiki/Mean_opinion_score
#MOS Quality Impairment #MOS Quality Impairment
...@@ -225,5 +231,7 @@ if __name__ == "__main__": ...@@ -225,5 +231,7 @@ if __name__ == "__main__":
sender_thread.start() sender_thread.start()
while sender_thread.is_alive(): while sender_thread.is_alive():
time.sleep(1) time.sleep(1)
# While testing, end after one iteration # While testing, end after one iteration
sys.exit() sys.exit()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment