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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
NGUYEN Do Duc Anh
GNS3_unikernel_testbed
Commits
9c1cac3c
Commit
9c1cac3c
authored
5 months ago
by
NGUYEN Do Duc Anh
Browse files
Options
Downloads
Patches
Plain Diff
update show time converge
parent
7f3a5080
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
ubuntu_base/vc_server.py
+19
-13
19 additions, 13 deletions
ubuntu_base/vc_server.py
with
19 additions
and
13 deletions
ubuntu_base/vc_server.py
+
19
−
13
View file @
9c1cac3c
import
socket
,
struct
import
socket
,
struct
import
time
import
threading
import
threading
import
time
# Configuration
# Configuration
LISTEN_PORT
=
12346
# Specify the port number to listen on
LISTEN_PORT
=
12346
# Specify the port number to listen on
node_index_id
=
0
node_index_id
=
0
map_security_node
=
{}
map_security_node
=
{}
time_converge
=
0
class
State
:
class
State
:
...
@@ -30,18 +31,17 @@ def listen_for_node(id_node, client_socket):
...
@@ -30,18 +31,17 @@ def listen_for_node(id_node, client_socket):
def
print_mapping_state
():
def
print_mapping_state
():
global
map_security_node
global
map_security_node
,
time_converge
old_map_security
=
{}
old_map_security
=
{}
convergence_count
=
0
change_count
=
0
change_count
=
0
is_converged
=
False
while
True
:
while
True
:
print
(
"
--- New record ---
"
)
contents
=
[
"
--- New record ---
"
]
convergence_count
+=
1
is_changed
=
False
is_changed
=
False
for
id_node
in
map_security_node
.
keys
():
for
id_node
in
map_security_node
.
keys
():
node
=
map_security_node
[
id_node
]
node
=
map_security_node
[
id_node
]
print
(
f
"
Node
{
id_node
:
<
5
}
"
contents
.
append
(
f
"
Node
{
id_node
:
<
5
}
"
f
"
| State:
{
'
IN VC
'
if
node
[
'
state
'
]
==
State
.
DECIDED_IN_VC
else
'
NOT in VC
'
if
node
[
'
state
'
]
==
State
.
DECIDED_NOT_VC
else
'
None
'
:
<
10
}
"
f
"
| State:
{
'
IN VC
'
if
node
[
'
state
'
]
==
State
.
DECIDED_IN_VC
else
'
NOT in VC
'
if
node
[
'
state
'
]
==
State
.
DECIDED_NOT_VC
else
'
None
'
:
<
10
}
"
f
"
| Pointer:
{
node
[
'
pointer
'
]
}
"
)
f
"
| Pointer:
{
node
[
'
pointer
'
]
}
"
)
if
id_node
not
in
old_map_security
:
if
id_node
not
in
old_map_security
:
...
@@ -49,14 +49,20 @@ def print_mapping_state():
...
@@ -49,14 +49,20 @@ def print_mapping_state():
elif
old_map_security
[
id_node
][
'
state
'
]
!=
map_security_node
[
id_node
][
'
state
'
]
or
old_map_security
[
id_node
][
'
pointer
'
]
!=
map_security_node
[
id_node
][
'
pointer
'
]:
elif
old_map_security
[
id_node
][
'
state
'
]
!=
map_security_node
[
id_node
][
'
state
'
]
or
old_map_security
[
id_node
][
'
pointer
'
]
!=
map_security_node
[
id_node
][
'
pointer
'
]:
old_map_security
[
id_node
][
'
state
'
]
=
node
[
'
state
'
]
old_map_security
[
id_node
][
'
state
'
]
=
node
[
'
state
'
]
old_map_security
[
id_node
][
'
pointer
'
]
=
node
[
'
pointer
'
]
old_map_security
[
id_node
][
'
pointer
'
]
=
node
[
'
pointer
'
]
convergence_count
=
0
is_changed
=
True
is_changed
=
True
if
is_changed
:
if
is_changed
:
old_time_converge
=
time_converge
time_converge
=
time
.
time
()
is_converged
=
False
for
cont
in
contents
:
print
(
cont
)
change_count
+=
1
change_count
+=
1
print
(
"
Convergence count:
"
,
convergence_count
)
print
(
"
Round (Num of change):
"
,
change_count
)
print
(
"
Round (Num of change):
"
,
change_count
)
time
.
sleep
(
2
)
if
old_time_converge
!=
0
:
print
(
"
Round time:
"
,
time_converge
-
old_time_converge
)
elif
time_converge
!=
0
and
not
is_converged
and
(
time
.
time
()
-
time_converge
)
>
10
:
is_converged
=
True
print
(
"
Converged
"
)
def
main
():
def
main
():
...
...
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