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
91840f37
Commit
91840f37
authored
8 months ago
by
NGUYEN Do Duc Anh
Browse files
Options
Downloads
Patches
Plain Diff
add initiate configuration for monitor
parent
992aa0be
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
ubuntu_base/initiate_for_monitor
+21
-0
21 additions, 0 deletions
ubuntu_base/initiate_for_monitor
ubuntu_base/opportunistic_node.py
+2
-3
2 additions, 3 deletions
ubuntu_base/opportunistic_node.py
ubuntu_base/vc_node.py
+4
-7
4 additions, 7 deletions
ubuntu_base/vc_node.py
with
27 additions
and
10 deletions
ubuntu_base/initiate_for_monitor
0 → 100644
+
21
−
0
View file @
91840f37
#!/bin/bash
sudo
modprobe br_netfilter
# To enable switch functions inside Ubuntu VM
sudo
brctl addbr br0
sudo
ip
link set
br0 up
sudo
brctl stp br0 on
# Create private and public tap interface for monitor
for
i
in
{
4..13
}
;
do
sudo
ip tuntap add public
$i
mode tap
sudo
ip
link set
dev public
$i
up
sudo
ip tuntap add private
$i
mode tap
sudo
ip
link set
dev private
$i
up
sudo
brctl addbr br
$i
sudo
ip
link set
br
$i
up
sudo
brctl addif br
$i
ens
$i
sudo
brctl addif br
$i
public
$i
sudo
brctl addif br0 private
$i
done
\ No newline at end of file
This diff is collapsed.
Click to expand it.
ubuntu_base/opportunistic_node.py
+
2
−
3
View file @
91840f37
...
...
@@ -26,7 +26,6 @@ def setup_firewall(inter_num):
print
(
f
"
Command output:
{
e
.
output
}
"
)
# Any output (stdout/stderr)
def
process_packet
(
new_packet
):
global
my_id
,
name_interface
...
...
@@ -91,13 +90,13 @@ def process_packet(new_packet):
def
main
():
rule_check
=
"
sudo iptables -C FORWARD -p tcp -j NFQUEUE --queue-num 1
"
rule_check
=
"
sudo iptables -C FORWARD
-i br0
-p tcp -j NFQUEUE --queue-num 1
"
try
:
subprocess
.
run
(
rule_check
,
shell
=
True
,
check
=
True
)
print
(
"
Rule already exists, no need to add it.
"
)
except
subprocess
.
CalledProcessError
:
try
:
rule_1
=
"
sudo iptables -I FORWARD -p tcp -j NFQUEUE --queue-num 1
"
rule_1
=
"
sudo iptables -I FORWARD
-i br0
-p tcp -j NFQUEUE --queue-num 1
"
subprocess
.
run
(
rule_1
,
shell
=
True
,
check
=
True
)
for
i
in
range
(
MIN_INTER_NUMBER
,
MAX_INTER_NUMBER
):
...
...
This diff is collapsed.
Click to expand it.
ubuntu_base/vc_node.py
+
4
−
7
View file @
91840f37
...
...
@@ -126,10 +126,6 @@ def check_all_interfaces():
return
f
"
Error executing command:
{
e
}
"
# def initiate_me():
# message = struct.pack('!I', myid)
# broadcast_packet(message)
def
drop_me
():
message
=
struct
.
pack
(
'
!II
'
,
Cmd
.
DROP_ME
,
node
.
myid
)
broadcast_packet
(
message
)
...
...
@@ -234,12 +230,13 @@ def proceed_simple_VC():
# Start a new Python process to run another script based on Node decision
subprocess
.
run
(
f
"
sudo
{
DIR
}
/ubuntu_base/./initiate
"
,
shell
=
True
,
check
=
True
)
print
(
"
A bridge br0 created
"
)
if
node
.
state
==
State
.
DECIDED_IN_VC
:
subprocess
.
run
(
f
"
sudo
{
DIR
}
/ubuntu_base/./initiate_for_monitor
"
,
shell
=
True
,
check
=
True
)
print
(
"
./initiate_for_monitor is executed
"
)
subprocess
.
Popen
([
sys
.
executable
,
f
'
{
DIR
}
/ubuntu_base/opportunistic_monitor.py
'
])
elif
node
.
state
==
State
.
DECIDED_NOT_VC
:
subprocess
.
run
(
f
"
sudo
{
DIR
}
/ubuntu_base/./initiate
"
,
shell
=
True
,
check
=
True
)
print
(
"
./initiate is executed
"
)
subprocess
.
Popen
([
sys
.
executable
,
f
'
{
DIR
}
/ubuntu_base/opportunistic_node.py
'
,
str
(
node
.
myid
)])
else
:
print
(
"
Error I cannot decide!!
"
)
...
...
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