Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
pydtnsim
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
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
discus
pydtnsim
Commits
95f9eabf
Commit
95f9eabf
authored
7 years ago
by
Jarrod Pas
Browse files
Options
Downloads
Patches
Plain Diff
Cleans up packet analytics
parent
7b0f70f5
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!3
Version 0.2
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
pydyton/network.py
+23
-59
23 additions, 59 deletions
pydyton/network.py
with
23 additions
and
59 deletions
pydyton/network.py
+
23
−
59
View file @
95f9eabf
...
@@ -242,37 +242,16 @@ class PacketGenerator(TickProcess):
...
@@ -242,37 +242,16 @@ class PacketGenerator(TickProcess):
source
.
recv
(
packet
)
source
.
recv
(
packet
)
yield
self
.
env
.
timeout
(
self
.
start_delay
)
yield
self
.
env
.
timeout
(
self
.
start_delay
)
print
(
'
starting packets
'
)
print
(
'
starting packets
'
)
#@DEBUG
if
False
:
for
i
in
range
(
217
):
for
i
in
range
(
84
):
pass
create
(
packet_id
)
#@DEBUG
packet_id
+=
1
return
while
True
:
while
True
:
create
(
packet_id
)
create
(
packet_id
)
yield
self
.
tick
()
yield
self
.
tick
()
packet_id
+=
1
packet_id
+=
1
@property
def
recieved
(
self
):
return
len
([
packet
for
packet
in
self
.
packets
if
packet
.
recieved
])
@property
def
recieved_count
(
self
):
return
sum
([
packet
.
recieved_count
for
packet
in
self
.
packets
])
@property
def
sent
(
self
):
return
sum
([
packet
.
sent
for
packet
in
self
.
packets
])
@property
@property
def
stats
(
self
):
def
stats
(
self
):
stats
=
{}
stats
=
{}
...
@@ -282,33 +261,21 @@ class PacketGenerator(TickProcess):
...
@@ -282,33 +261,21 @@ class PacketGenerator(TickProcess):
stats
[
stat
]
=
value
stats
[
stat
]
=
value
else
:
else
:
stats
[
stat
]
+=
value
stats
[
stat
]
+=
value
stats
[
'
packets
'
]
=
len
(
self
.
packets
)
stats
[
'
recieved
'
]
=
len
([
p
for
p
in
self
.
packets
if
p
.
recieved
])
stats
[
'
delivery_ratio
'
]
=
stats
[
'
recieved
'
]
/
stats
[
'
packets
'
]
stats
[
'
duplicates
'
]
=
sum
([
p
.
duplicates
for
p
in
self
.
packets
])
stats
[
'
transmissions
'
]
=
sum
([
p
.
sent
for
p
in
self
.
packets
])
stats
[
'
delivery_cost
'
]
=
stats
[
'
transmissions
'
]
/
stats
[
'
recieved
'
]
return
stats
return
stats
@property
def
paths
(
self
):
return
{
packet
:
packet
.
path
for
packet
in
self
.
packets
if
packet
.
recieved
}
@property
def
total
(
self
):
return
len
(
self
.
packets
)
def
__str__
(
self
):
def
__str__
(
self
):
ret
=
"
recieved: {}/{}, delivery ratio: {}, packets: {}, sent: {}, stats: {}, path: {}
"
.
format
(
ret
=
''
self
.
recieved
,
for
stat
,
value
in
sorted
(
self
.
stats
.
items
()):
self
.
recieved_count
,
ret
+=
f
'
{
stat
}
:
{
value
}
\n
'
self
.
recieved
/
len
(
self
.
packets
),
len
(
self
.
packets
),
self
.
sent
,
self
.
stats
,
sum
([
len
(
path
)
for
path
in
self
.
paths
.
values
()
])
/
self
.
recieved
)
'''
'''
for packet
, path
in self.pa
ths.items()
:
for packet in self.pa
ckets
:
ret +=
'
\n
{}: {}
'
.format(packet, path)
ret +=
'
\n
{}: {}
'
.format(packet,
packet.
path)
'''
'''
return
ret
return
ret
...
@@ -325,12 +292,9 @@ class Packet:
...
@@ -325,12 +292,9 @@ class Packet:
self
.
stats
=
dict
()
self
.
stats
=
dict
()
self
.
sent
=
0
self
.
sent
=
0
self
.
recieved
=
False
self
.
recieved
=
False
self
.
recieved_count
=
0
self
.
duplicates
=
0
self
.
dropped
=
0
self
.
dropped
=
False
self
.
dropped_count
=
0
def
send
(
self
,
a
,
b
,
reason
=
None
):
def
send
(
self
,
a
,
b
,
reason
=
None
):
if
reason
is
None
:
if
reason
is
None
:
...
@@ -339,13 +303,13 @@ class Packet:
...
@@ -339,13 +303,13 @@ class Packet:
self
.
path
.
append
((
a
.
id
,
b
.
id
,
reason
))
self
.
path
.
append
((
a
.
id
,
b
.
id
,
reason
))
self
.
sent
+=
1
self
.
sent
+=
1
def
drop
(
self
):
self
.
dropped
=
True
self
.
dropped_count
+=
1
def
recv
(
self
):
def
recv
(
self
):
if
self
.
recieved
:
self
.
duplicates
+=
1
self
.
recieved
=
True
self
.
recieved
=
True
self
.
recieved_count
+=
1
def
drop
(
self
):
self
.
dropped
+=
1
def
__str__
(
self
):
def
__str__
(
self
):
return
"
Packet(id={}, src={}, dst={})
"
.
format
(
return
"
Packet(id={}, src={}, dst={})
"
.
format
(
...
...
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