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
f248dcc1
Commit
f248dcc1
authored
1 month ago
by
NGUYEN Do Duc Anh
Browse files
Options
Downloads
Patches
Plain Diff
log
parent
c0dbae9e
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
topohub_to_gns3.py
+14
-5
14 additions, 5 deletions
topohub_to_gns3.py
ubuntu_base/if_utils.py
+11
-11
11 additions, 11 deletions
ubuntu_base/if_utils.py
ubuntu_base/opportunistic_node.py
+1
-1
1 addition, 1 deletion
ubuntu_base/opportunistic_node.py
with
26 additions
and
17 deletions
topohub_to_gns3.py
+
14
−
5
View file @
f248dcc1
...
...
@@ -12,6 +12,7 @@ import numpy as np
import
topohub
import
struct
import
math
import
signal
import
gns3manager
# import matplotlib.pyplot as plt
...
...
@@ -25,6 +26,8 @@ NUM_UBUNTU_BASE = 0
NUM_UBUNTU_INTERMEDIATE
=
0
NUM_UBUNTU_UNCTRL
=
0
is_stop_vc_server
=
False
#
# def process_packet(pkt):
...
...
@@ -78,17 +81,22 @@ def send_para_server(A_raw, f, num_host, p_NAT, P_values, max_total_traffic, pro
def
run_vc_server
(
map_connection_ubuntu_base
,
is_reaction
):
global
NUM_UBUNTU_BASE
global
NUM_UBUNTU_BASE
,
is_stop_vc_server
map_json
=
json
.
dumps
({
"
map_ip
"
:
map_connection_ubuntu_base
,
"
is_reaction
"
:
is_reaction
,
"
total_router
"
:
NUM_UBUNTU_BASE
})
command_str
=
f
"
python3
{
DIR
}
/ubuntu_base/vc_server.py
'
{
map_json
}
'"
subprocess
.
Popen
(
[
'
xterm
'
,
'
-
hold
'
,
'
-e
'
,
command_str
],
p
=
subprocess
.
Popen
(
[
'
xterm
'
,
'
-
iconic
'
,
'
-e
'
,
command_str
],
stdout
=
subprocess
.
DEVNULL
,
stderr
=
subprocess
.
DEVNULL
,
stdin
=
subprocess
.
DEVNULL
,
start_new_session
=
True
)
while
not
is_stop_vc_server
:
pass
os
.
kill
(
p
.
pid
,
signal
.
SIGTERM
)
def
run_unctrl_server
(
map_connection_ubuntu_unctrl
):
global
NUM_UBUNTU_UNCTRL
...
...
@@ -205,7 +213,7 @@ def listen_for_measurement(base_filename):
def
generate_topohub_GNS3_topology
():
global
NUM_SWITCH
,
NUM_HOST
,
NUM_UBUNTU_BASE
,
NUM_UBUNTU_INTERMEDIATE
,
NUM_UBUNTU_UNCTRL
global
NUM_SWITCH
,
NUM_HOST
,
NUM_UBUNTU_BASE
,
NUM_UBUNTU_INTERMEDIATE
,
NUM_UBUNTU_UNCTRL
,
is_stop_vc_server
gns3manager
.
PROJECT_ID
,
project_name
=
GNS3Manager
.
get_projectId
()
user_input
=
input
(
"
Press enter if correct project to generate topology?
"
)
...
...
@@ -436,6 +444,7 @@ def generate_topohub_GNS3_topology():
GNS3Manager
.
stop_nodes
(
array_ubuntu_intermediate
,
"
uinter_r
"
)
GNS3Manager
.
stop_node
(
ubuntu_server
.
id
,
"
u_server
"
)
GNS3Manager
.
stop_nodes
(
array_window_hosts
,
"
win
"
)
is_stop_vc_server
=
True
# Delete project
GNS3Manager
.
del_project
()
...
...
This diff is collapsed.
Click to expand it.
ubuntu_base/if_utils.py
+
11
−
11
View file @
f248dcc1
...
...
@@ -251,7 +251,7 @@ def run_firewall_solo5_hvt(private, public):
command_str
=
"
"
.
join
(
command
)
# print(f"{command_str}")
subprocess
.
Popen
(
[
'
xterm
'
,
'
-hold
'
,
'
-e
'
,
command_str
],
[
'
xterm
'
,
'
-e
'
,
command_str
],
stdout
=
subprocess
.
DEVNULL
,
stderr
=
subprocess
.
DEVNULL
,
stdin
=
subprocess
.
DEVNULL
,
...
...
@@ -292,7 +292,7 @@ def run_ids_solo5_hvt(map_tap_inf_for_ids):
command_str
=
"
"
.
join
(
command
)
# process = subprocess.Popen(['gnome-terminal', '--', 'bash', '-c', command_str])
process
=
subprocess
.
Popen
(
[
'
xterm
'
,
'
-hold
'
,
'
-e
'
,
command_str
],
[
'
xterm
'
,
'
-e
'
,
command_str
],
stdout
=
subprocess
.
DEVNULL
,
stderr
=
subprocess
.
DEVNULL
,
stdin
=
subprocess
.
DEVNULL
,
...
...
@@ -303,16 +303,16 @@ def run_ids_solo5_hvt(map_tap_inf_for_ids):
def
stop_ids_solo5_hvt
(
process
):
subproc_pid
=
None
with
os
.
popen
(
f
"
pgrep -f
{
DIR
}
/simple-IDS/dist/simple-ids.hvt
"
)
as
proc_list
:
for
pid
in
proc_list
.
readlines
():
subproc_pid
=
int
(
pid
.
strip
())
if
subproc_pid
!
=
process
.
pid
:
break
#
subproc_pid = None
#
with os.popen(f"pgrep -f {DIR}/simple-IDS/dist/simple-ids.hvt") as proc_list:
#
for pid in proc_list.readlines():
#
subproc_pid = int(pid.strip())
#
if subproc_pid
=
= process.pid:
#
break
# Kill the subprocess by its PID
if
subproc_pid
:
os
.
kill
(
sub
proc
_
pid
,
signal
.
SIGTERM
)
#
if subproc_pid:
os
.
kill
(
proc
ess
.
pid
,
signal
.
SIGTERM
)
# print(f"----------------- Stopped the IDS with PID {subproc_pid}. -----------------")
# else:
# print("----------------- No child process found to kill. -----------------")
...
...
This diff is collapsed.
Click to expand it.
ubuntu_base/opportunistic_node.py
+
1
−
1
View file @
f248dcc1
...
...
@@ -81,7 +81,7 @@ def check_local_packet(pkt):
print
(
"
Decision found, blocking:
"
,
socket
.
inet_ntoa
(
entry
[
'
addition_info
'
]))
FirewallOpportunistic
.
firewall_queue
.
put
((
entry
[
'
inter_num
'
],
socket
.
inet_ntoa
(
entry
[
'
addition_info
'
]),
entry
[
'
cmd
'
]))
else
:
print
(
"
D
ROP found but not me
:
"
,
entry
[
"
node_id
"
],
"
and
"
,
if_utils
.
my_id
)
print
(
"
D
ecision found for
:
"
,
entry
[
"
node_id
"
],
"
not for me:
"
,
if_utils
.
my_id
)
def
process_opportunistic_node
():
...
...
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