Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
D
D0020E-projekt
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Henrik Tjäder
D0020E-projekt
Commits
d700612d
Commit
d700612d
authored
10 years ago
by
Henrik Tjäder
Browse files
Options
Downloads
Patches
Plain Diff
Added jitter and MOS calculations
parent
ea220b28
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
UDP-client-server.py
+45
-0
45 additions, 0 deletions
UDP-client-server.py
with
45 additions
and
0 deletions
UDP-client-server.py
+
45
−
0
View file @
d700612d
...
...
@@ -37,11 +37,13 @@ def udp_client_receive(UDP_RECEIVE_IP, UDP_RECEIVE_PORT):
global
min_delay
global
max_delay
global
rt_delay_array
global
jitter
min_delay
=
100.
max_delay
=
0.
rt_delay_array
=
array
(
'
f
'
)
packet_count_rcvd
=
0
cumulative_delay
=
0.
jitter
=
0.
try
:
rcv_sock
.
bind
(
ADDR
)
...
...
@@ -144,6 +146,27 @@ def udp_client_send(UDP_DEST_IP, UDP_DEST_PORT,
if
rt_delay_array
:
print
(
'
std.dev =
'
,
np
.
std
(
rt_delay_array
))
#CALCULATE JITTER
# Clear for a clean slate
jitter
=
0
jitter_2
=
0
# Simple version, no weight
for
rt0
,
rt1
in
zip
(
rt_delay_array
[:
-
1
],
rt_delay_array
[
1
:]):
jitter_2
+=
np
.
fabs
(
rt0
-
rt1
)
jitter_2
=
jitter_2
/
(
len
(
rt_delay_array
)
-
1
)
# Version used in RFC 1889, also by iperf
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
:
...
...
@@ -156,6 +179,26 @@ def udp_client_send(UDP_DEST_IP, UDP_DEST_PORT,
print
(
'
avg.rtt =
'
,
avg_packet_delay
)
print
(
'
stability =
'
,
network_stability
)
# Calculating MOS
# http://en.wikipedia.org/wiki/Mean_opinion_score
#MOS Quality Impairment
#5 Excellent Imperceptible
#4 Good Perceptible but not annoying
#3 Fair Slightly annoying
#2 Poor Annoying
#1 Bad Very annoying
EffectiveLatency
=
avg_packet_delay
+
jitter
*
2
+
10
if
EffectiveLatency
<
160
:
R
=
93.2
-
(
EffectiveLatency
/
40
)
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
)
# 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__
"
:
...
...
@@ -178,3 +221,5 @@ if __name__ == "__main__":
sender_thread
.
start
()
while
sender_thread
.
is_alive
():
time
.
sleep
(
1
)
# While testing, end after one iteration
sys
.
exit
()
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment