Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
I
ipaaca
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Container Registry
Model registry
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Ramin Yaghoubzadeh Torky
ipaaca
Commits
4579f9cd
Commit
4579f9cd
authored
13 years ago
by
Ramin Yaghoubzadeh
Browse files
Options
Downloads
Patches
Plain Diff
Committing ping test too
parent
149e90d8
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
python/test/src/ipaacaspam.py
+49
-5
49 additions, 5 deletions
python/test/src/ipaacaspam.py
with
49 additions
and
5 deletions
python/test/src/ipaacaspam.py
+
49
−
5
View file @
4579f9cd
...
...
@@ -6,6 +6,43 @@ import unittest
import
ipaaca
class
Ponger
(
object
):
def
__init__
(
self
):
self
.
count
=
0
self
.
last_time
=
0
self
.
ib
=
ipaaca
.
InputBuffer
(
'
PingIn
'
,
[
'
ping
'
])
self
.
ib
.
register_handler
(
self
.
handle_iu_event
)
def
handle_iu_event
(
self
,
iu
,
event_type
,
local
):
if
event_type
==
'
UPDATED
'
:
iu
.
payload
[
'
ack
'
]
=
'
ack
'
def
run
(
self
):
while
True
:
time
.
sleep
(
1
)
class
Pinger
(
object
):
def
__init__
(
self
):
self
.
ob
=
ipaaca
.
OutputBuffer
(
'
PingOut
'
)
self
.
iu
=
ipaaca
.
IU
(
'
ping
'
)
self
.
iu
.
payload
=
{
'
data
'
:
'
0
'
}
self
.
ob
.
add
(
self
.
iu
)
self
.
ob
.
register_handler
(
self
.
handle_iu_event
)
self
.
counter
=
0
self
.
last_time
=
time
.
time
()
def
handle_iu_event
(
self
,
iu
,
event_type
,
local
):
print
"
Round-trip time:
"
,
1000.0
*
(
time
.
time
()
-
self
.
last_time
),
"
msec
"
def
run
(
self
):
print
"
Sending a ping every second ...
"
while
True
:
time
.
sleep
(
1.0
)
self
.
counter
+=
1
self
.
last_time
=
time
.
time
()
self
.
iu
.
payload
[
'
data
'
]
=
str
(
self
.
counter
)
self
.
last_time
=
time
.
time
()
class
Receiver
(
object
):
def
__init__
(
self
):
self
.
count
=
0
...
...
@@ -51,11 +88,18 @@ class Sender(object):
if
__name__
==
'
__main__
'
:
if
len
(
sys
.
argv
)
<
2
:
print
"
specify either
'
sender
'
or
'
receiver
'
as an argument
"
print
"
for the sender, you can additionally specify a delay (in 1/s)
"
print
"
between 1 and 10000 please (=> 1 sec ... 0.0001 sec) [default: 1000 => 0.001 sec]
"
print
"
Stress test: specify either
'
sender
'
or
'
receiver
'
as an argument
"
print
"
for the sender, you can additionally specify a delay (in 1/s)
"
print
"
between 1 and 10000 please (=> 1 sec ... 0.0001 sec) [default: 1000 => 0.001 sec]
"
print
"
Ping test: specify either
'
ping
'
or
'
pong
'
as an argument
"
sys
.
exit
(
1
)
if
sys
.
argv
[
1
]
==
'
receiver
'
:
if
sys
.
argv
[
1
]
==
'
ping
'
:
r
=
Pinger
()
r
.
run
()
elif
sys
.
argv
[
1
]
==
'
pong
'
:
r
=
Ponger
()
r
.
run
()
elif
sys
.
argv
[
1
]
==
'
receiver
'
:
r
=
Receiver
()
r
.
run
()
elif
sys
.
argv
[
1
]
==
'
sender
'
:
...
...
@@ -70,7 +114,7 @@ if __name__ == '__main__':
s
=
Sender
(
send_frequency
=
freq
)
s
.
run
()
else
:
print
"
specify either
'
sender
'
or
'
receiver
'
as an argument
"
print
"
specify either
'
sender
'
,
'
receiver
'
,
'
ping
'
or
'
pong
'
as an argument
"
sys
.
exit
(
1
)
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