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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Henrik Tjäder
D0020E-projekt
Commits
316cf940
Commit
316cf940
authored
10 years ago
by
Henrik Tjäder
Browse files
Options
Downloads
Patches
Plain Diff
Added placeholder CB, removed old stability function
parent
4f3dd3c4
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
+17
-9
17 additions, 9 deletions
UDP-client-server.py
with
17 additions
and
9 deletions
UDP-client-server.py
+
17
−
9
View file @
316cf940
...
@@ -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
()
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