Skip to content
Snippets Groups Projects
Commit d3d5fd23 authored by NGUYEN Do Duc Anh's avatar NGUYEN Do Duc Anh
Browse files

update run opportunistic mechanism after VC algorithm

parent 8b287b3b
Branches
No related tags found
No related merge requests found
#!/bin/bash #!/bin/bash
sudo modprobe br_netfilter # To enable switch functions inside Ubuntu VM
sudo brctl addbr br0 sudo brctl addbr br0
sudo ip link set br0 up sudo ip link set br0 up
......
...@@ -45,6 +45,8 @@ def process_packet(new_packet): ...@@ -45,6 +45,8 @@ def process_packet(new_packet):
else: else:
pkt.options[index_custom_option].add_entry(node_id, inter_num, Cmd.DECISION_DROP) pkt.options[index_custom_option].add_entry(node_id, inter_num, Cmd.DECISION_DROP)
del pkt.len
del pkt.ihl
del pkt[IP].chksum # Invalidate the checksum del pkt[IP].chksum # Invalidate the checksum
new_packet.set_payload(bytes(pkt)) new_packet.set_payload(bytes(pkt))
......
import socket, struct, threading import socket, struct, threading
import math, queue import math, queue
import time import time
from scapy.all import Ether, sendp, sniff, Raw, get_if_hwaddr from scapy.all import sendp, sniff, Raw, get_if_hwaddr
import subprocess, netifaces import subprocess, netifaces, sys
from scapy.layers.l2 import Ether
# Configuration # Configuration
LISTEN_PORT = 12346 # Specify the port number to listen on LISTEN_PORT = 12346 # Specify the port number to listen on
...@@ -230,6 +231,17 @@ def proceed_simple_VC(): ...@@ -230,6 +231,17 @@ def proceed_simple_VC():
print("Error my round is", node.round_val, "but server round is", server_round) print("Error my round is", node.round_val, "but server round is", server_round)
print("I am", "IN VC" if node.state == State.DECIDED_IN_VC else "NOT in VC") print("I am", "IN VC" if node.state == State.DECIDED_IN_VC else "NOT in VC")
# Start a new Python process to run another script based on Node decision
if node.state == State.DECIDED_IN_VC:
subprocess.Popen([sys.executable, '~/Desktop/gns3_unikernel_testbed/ubuntu_base/opportunistic_monitor.py'])
elif node.state == State.DECIDED_NOT_VC:
subprocess.Popen([sys.executable, '~/Desktop/gns3_unikernel_testbed/ubuntu_base/opportunistic_node.py'])
else:
print("Error I cannot decide!!")
# Exit the current script
sys.exit()
def main(): def main():
global debug global debug
......
import socket, struct import socket, struct
import sys, queue, time import time
import threading import threading
# Configuration # Configuration
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment