Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
GNS3_unikernel_testbed
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
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
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
NGUYEN Do Duc Anh
GNS3_unikernel_testbed
Commits
651db87b
Commit
651db87b
authored
2 months ago
by
NGUYEN Do Duc Anh
Browse files
Options
Downloads
Patches
Plain Diff
optimize code, need to test
parent
44fbab4f
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
ubuntu_base/vc_node.py
+9
-21
9 additions, 21 deletions
ubuntu_base/vc_node.py
with
9 additions
and
21 deletions
ubuntu_base/vc_node.py
+
9
−
21
View file @
651db87b
...
@@ -283,8 +283,8 @@ def update_neighbor_info():
...
@@ -283,8 +283,8 @@ def update_neighbor_info():
while
True
:
while
True
:
try
:
try
:
is_notify_neighbor
=
False
if
not
update_neighbor_info_queue
.
empty
():
if
not
update_neighbor_info_queue
.
empty
():
is_notify_neighbor
=
False
while
not
update_neighbor_info_queue
.
empty
():
while
not
update_neighbor_info_queue
.
empty
():
neighbor
=
update_neighbor_info_queue
.
get
()
neighbor
=
update_neighbor_info_queue
.
get
()
...
@@ -297,28 +297,16 @@ def update_neighbor_info():
...
@@ -297,28 +297,16 @@ def update_neighbor_info():
map_neighbor
[
neighbor
.
id
]
=
neighbor
map_neighbor
[
neighbor
.
id
]
=
neighbor
old_degree
=
node
.
degree
old_degree
=
node
.
degree
node
.
degree
=
len
(
map_neighbor
)
node
.
degree
=
len
(
map_neighbor
)
if
old_degree
!=
node
.
degree
:
if
old_degree
!=
node
.
degree
:
print
(
"
I updated my degree, reset myself
"
)
print
(
"
I updated my degree, reset myself
"
)
reset_me
()
reset_me
()
is_notify_neighbor
=
True
is_notify_neighbor
=
True
is_apply_rule
=
apply_rule
()
if
apply_rule
()
or
is_notify_neighbor
:
if
is_apply_rule
or
is_notify_neighbor
:
send_node_info
()
for
neighbor
in
map_neighbor
.
values
():
message
=
struct
.
pack
(
'
!IIIIIII
'
,
magic_hdr
,
Cmd
.
SHARE_INFO
,
node
.
myid
,
node
.
degree
,
node
.
color
,
node
.
color_id
,
node
.
pointer
)
send_packet
(
neighbor
.
iface
,
neighbor
.
mac
,
message
)
node
.
converge_time
=
time
.
time
()
print_my_info
()
elif
apply_rule
():
send_node_info
()
send_node_info
()
print
(
"
My current state:
"
,
node
.
state
)
for
neighbor
in
map_neighbor
.
values
():
for
neighbor
in
map_neighbor
.
values
():
message
=
struct
.
pack
(
'
!IIIIIII
'
,
magic_hdr
,
Cmd
.
SHARE_INFO
,
node
.
myid
,
node
.
degree
,
node
.
color
,
node
.
color_id
,
node
.
pointer
)
message
=
struct
.
pack
(
'
!IIIIIII
'
,
magic_hdr
,
Cmd
.
SHARE_INFO
,
node
.
myid
,
node
.
degree
,
node
.
color
,
node
.
color_id
,
node
.
pointer
)
...
@@ -326,7 +314,7 @@ def update_neighbor_info():
...
@@ -326,7 +314,7 @@ def update_neighbor_info():
node
.
converge_time
=
time
.
time
()
node
.
converge_time
=
time
.
time
()
print_my_info
()
print_my_info
()
time
.
sleep
(
1
)
time
.
sleep
(
1
)
except
RuntimeError
as
e
:
except
RuntimeError
as
e
:
print
(
f
"
Caught an error:
{
e
}
"
)
print
(
f
"
Caught an error:
{
e
}
"
)
print
(
"
Maybe REPLY_REGISTER received after I send SHARE_INFO message
"
)
print
(
"
Maybe REPLY_REGISTER received after I send SHARE_INFO message
"
)
...
...
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