Unnecessary tests

edoardoColi
edoardocoli 1 year ago
parent 7d24a53db9
commit 9a4bc83c68

@ -1,63 +0,0 @@
from mininet.net import Mininet
from mininet.node import Controller, OVSSwitch
from mininet.cli import CLI
from mininet.log import setLogLevel
class CustomController( Controller ):
"Open vSwitch controller"
def __init__( self, name, **kwargs ):
kwargs.setdefault( 'command', self.isAvailable() or
'ovs-controller' )
Controller.__init__( self, name, **kwargs )
# class CustomController(Controller):
# def _handle_ConnectionUp(self, event):
# # Handle new connection
# dpid_str = dpid_to_str(event.dpid)
# log.info("Switch %s connected", dpid_str)
# self.connection = event.connection
# event.connection.addListeners(self)
# def _handle_PacketIn(self, event):
# # Handle incoming packet
# packet = event.parsed
# if packet.type == ethernet.IP_TYPE:
# ip_packet = packet.payload
# src_ip = ip_packet.srcip
# dst_ip = ip_packet.dstip
# log.info("Source IP: %s, Destination IP: %s", src_ip, dst_ip)
# # Call the parent handler to continue processing other events
# super(CustomController, self)._handle_PacketIn(event)
def create_topology():
net = Mininet(controller=Controller, switch=OVSSwitch)
# Create network nodes
h1 = net.addHost('h1')
h2 = net.addHost('h2')
s1 = net.addSwitch('s1', cls=OVSSwitch)
# Create links
net.addLink(h1, s1)
net.addLink(h2, s1)
# Start the network
net.start()
# Create a custom controller instance
controller = net.addController('c1', controller=CustomController)
# Connect the switch to the controller
s1.start([controller])
# Enter command line mode
CLI(net)
# Stop the network
net.stop()
if __name__ == '__main__':
setLogLevel('info')
create_topology()

@ -1,181 +0,0 @@
import mininet
import time, socket, random
import numpy as np
from mininet.cli import CLI
from mininet.log import setLogLevel
from mininet.net import Mininet
from mininet.topo import Topo
from mininet.link import TCLink
import matplotlib.pyplot as plt
# Define custom topology
class MyTopology(Topo):
def build(self):
# Create switches
s1 = self.addSwitch('s1')
s2 = self.addSwitch('s2')
# Create hosts
h1 = self.addHost('h1')
h2 = self.addHost('h2')
# Add links
self.addLink(h1, s1, cls=TCLink, delay='10ms', bw=1)
self.addLink(s1, s2, cls=TCLink, delay='50ms', bw=0.5)
self.addLink(s2, h2, cls=TCLink, delay='10ms', bw=1)
# Define TCP agent
class MyTCPAgent:
def __init__(self):
# Initialize TCP agent
self.transmission_rounds = []
self.congestion_window_sizes = []
def handle_connection(self):
print("TCP connection establishment")
# Implement TCP connection establishment
# Example TCP connection establishment using a socket
# self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
# self.sock.connect(('localhost', 19191))
# Example TCP connection establishment simulation
time.sleep(1) # Simulating connection establishment delay
def handle_data_transfer(self, tunnel, window_size):
print("Performing data transfer with tunnel:", tunnel, "and window size:", window_size)
# Implement TCP data transfer with the given tunnel and window size using socket programming
# Implement TCP data transfer simulation
# Placeholder logic: Simulating data transfer
# time.sleep(0.1) # Simulating data transfer delay
# Simulate congestion control by waiting for a fixed amount of time
time.sleep(0.1)
# Record transmission round and final congestion window size
self.transmission_rounds.append(len(self.transmission_rounds) + 1)
self.congestion_window_sizes.append(window_size)
# Define RL agent for tunnel selection
class TunnelSelectionAgent:
def __init__(self, tunnels):
# Initialize your RL agent for tunnel selection
self.rewards = []
self.selected_tunnels = []
self.tunnels = tunnels
self.current_tunnel = 0
def select_tunnel(self):
# Implement tunnel selection based on RL policy
# Placeholder logic: Select a tunnel randomly or based on some criteria
selected_tunnel = self.tunnels[self.current_tunnel]
self.current_tunnel = (self.current_tunnel + 1) % len(self.tunnels)
return selected_tunnel
def update_policy(self, reward):
# Implement RL policy update based on rewards
self.rewards.append(reward)
self.selected_tunnels.append(self.select_tunnel())
# Define RL agent for window prediction
class WindowPredictionAgent:
def __init__(self):
# Initialize the RL agent for window prediction
self.window_sizes = [1, 2, 4, 8, 16, 32, 64] # Possible window sizes
self.alpha = 0.1 # Learning rate
self.gamma = 0.9 # Discount factor
self.q_table = {} # Q-table to store state-action values
def predict_window_size(self):
# Get the current state (e.g., network conditions)
state = self.get_state()
# Check if the state is in the Q-table
if state not in self.q_table:
# Initialize Q-values for all possible actions in the current state
self.q_table[state] = {window_size: 0 for window_size in self.window_sizes}
# Choose the action (window size) based on epsilon-greedy policy
if random.random() < 0.2: # Exploration (20% of the time)
action = random.choice(self.window_sizes)
else: # Exploitation (80% of the time)
action = self.get_best_action(state)
return action
def get_state(self):
# Implement the logic to determine the current state based on network conditions
# For example, you can consider factors such as round-trip time, packet loss rate, or congestion signals
# Placeholder logic: Return a random state
return random.randint(1, 10)
def get_best_action(self, state):
# Find the action (window size) with the highest Q-value for the given state
best_action = max(self.q_table[state], key=self.q_table[state].get)
return best_action
def update_policy(self, reward):
# Update the Q-value based on the reward received after taking an action
# Get the previous state and action
prev_state = self.get_state() # Replace with the actual previous state
prev_action = self.predict_window_size() # Replace with the actual previous action
# Get the current state
curr_state = self.get_state()
# Check if the current state is in the Q-table
if curr_state not in self.q_table:
# Initialize Q-values for all possible actions in the current state
self.q_table[curr_state] = {window_size: 0 for window_size in self.window_sizes}
# Update the Q-value using the Q-learning update rule
max_q_value = max(self.q_table[curr_state].values()) # Get the maximum Q-value for the current state
self.q_table[prev_state][prev_action] += self.alpha * (reward + self.gamma * max_q_value - self.q_table[prev_state][prev_action])
# Main function
if __name__ == '__main__':
setLogLevel('info')
# Create the Mininet network
topo = MyTopology()
net = Mininet(topo=topo)
net.start
# Instantiate TCP and RL agents
tcp_agent = MyTCPAgent()
tunnels = ['myPrivate1']
tunnel_agent = TunnelSelectionAgent(tunnels)
window_agent = WindowPredictionAgent()
# Perform TCP connection establishment
tcp_agent.handle_connection()
# Perform data transfer with RL-based tunnel selection and window prediction
start_time = time.time()
while True:
if time.time() - start_time > 10: # End packet exchange after <X> seconds
break
tunnel = tunnel_agent.select_tunnel()
window_size = window_agent.predict_window_size()
# Perform data transfer
tcp_agent.handle_data_transfer(tunnel, window_size)
# Update RL agents based on rewards
reward = -0.5 # Actual reward value
tunnel_agent.update_policy(reward)
# window_agent.update_policy(reward)
# Stop the Mininet network
net.stop()
# Plot Transmission Round and Congestion Window Size
plt.plot(tcp_agent.transmission_rounds, tcp_agent.congestion_window_sizes)
plt.xlabel('Transmission Round')
plt.ylabel('Congestion Window Size')
plt.title('TCP+RL Window Prediction')
plt.show()

@ -1,84 +0,0 @@
from mininet.net import Mininet
from mininet.node import Controller
from mininet.log import setLogLevel
from mininet.cli import CLI
from pox.lib import of
import time
import matplotlib.pyplot as plt
# Create empty lists to store the timestamp and latency values
timestamps = []
latencies = []
class PacketCopyController(Controller):
def __init__(self, name, target_host, **kwargs):
Controller.__init__(self, name, **kwargs)
self.target_host = target_host
def _handle_PacketIn(self, event):
packet = event.parsed
self.packet_out(event.port, packet)
self.packet_out_to_host(packet)
# Measure latency and store timestamp and latency values
latency = time.time() - event.created
timestamps.append(time.time())
latencies.append(latency)
def packet_out(self, out_port, packet):
msg = of.ofp_packet_out()
msg.data = packet.pack()
action = of.ofp_action_output(port=out_port)
msg.actions.append(action)
self.connection.send(msg)
def packet_out_to_host(self, packet):
host = self.net.get(self.target_host)
if host:
host.sendMsg(packet)
if __name__ == '__main__':
setLogLevel('info')
# Creazione della rete Mininet
net = Mininet(controller=PacketCopyController)
# Creazione degli host e degli switch
h1 = net.addHost('h1')
h2 = net.addHost('h2')
h3 = net.addHost('h3')
s1 = net.addSwitch('s1')
# Creazione dei collegamenti
net.addLink(h1, s1)
net.addLink(h2, s1)
net.addLink(h3, s1)
# Create the plot
plt.figure()
plt.xlabel('Time')
plt.ylabel('Latency (seconds)')
plt.title('Network Latency')
# Avvio della rete e assegnazione del controller
# Add the POX controller
controller = net.addController(name='controller', target_host='h3', controller=PacketCopyController, ip='127.0.0.1', port=6633)
net.start()
controller.start()
# controller = net.controllers[0]
# controller.net = net
# Start the plot animation
plt.ion()
plt.show()
try:
while True:
# Update the plot with new latency data
plt.plot(timestamps, latencies, 'b-')
plt.draw()
plt.pause(0.1)
except KeyboardInterrupt:
pass
CLI(net)
net.stop()

@ -1,71 +0,0 @@
import configparser
from colorama import Fore, Style
from mininet.net import Mininet
from mininet.topo import Topo
from mininet.node import Node
from mininet.cli import CLI
from mininet.link import TCLink
from mininet.log import setLogLevel
class MyRouter (Node):
def config(self, **params):
super(MyRouter, self).config(**params)
self.cmd('sysctl net.ipv4.ip_forward=1') #Enable forwarding on the router
def terminate(self):
self.cmd('sysctl net.ipv4.ip_forward=0') #Disable forwarding on the router
super(MyRouter, self).terminate
def build_topology(config_file):
topo = Topo()
elements = {} # Dictionary to store nodes
# h1 = topo.addHost('H1', ip='161.46.247.2/25', defaultRoute='via 161.46.247.1')
# h2 = topo.addHost('H2', ip='161.46.247.3/25', defaultRoute='via 161.46.247.1')
r0 = topo.addNode('R0', cls=MyRouter, ip='163.172.250.12/16')
r1 = topo.addNode('R1', cls=MyRouter, ip='163.172.250.12/28')
r2 = topo.addNode('R2', cls=MyRouter, ip='161.46.247.253/30')
topo.addLink(r0, r1, intfName2='R12', intfName1='R01', params2={'ip' : '163.172.250.12/28'}, params1={'ip' : '163.172.250.12/16'})
topo.addLink(r2, r1, intfName2='R13', intfName1='R21', params2={'ip' : '161.46.247.254/30'}, params1={'ip' : '161.46.247.253/30'})
# s1 = topo.addSwitch('S1')
# h4 = topo.addHost('H4', ip='161.46.247.131/26', defaultRoute='via 161.46.247.129')
# h3 = topo.addHost('H3', ip='161.46.247.196/27', defaultRoute='via 161.46.247.195')
### Ordine importante ###
# topo.addLink(r1, s1, intfName1='R11', params1={'ip' : '161.46.247.1/25'})
# topo.addLink(r2, h3, intfName2='H31', intfName1='R22', params1={'ip' : '161.46.247.195/27'})
# topo.addLink(r2, h4, intfName2='H41', intfName1='R23', params1={'ip' : '161.46.247.129/26'})
# topo.addLink(s1, h1, intfName2='H11')
# topo.addLink(s1, h2 ,intfName2='H21')
return topo
def run_topology(config_file):
setLogLevel('info') #Different logging levels are 'info' 'warning' 'error' 'debug'
topo = build_topology(config_file)
net = Mininet(topo=topo, link=TCLink)
net.start() #Starting the network
(net.getNodeByName('R1')).cmd('ip route add default via 161.172.250.1/26')
(net.getNodeByName('R1')).cmd('ip route add 161.46.247.128/27 via 161.46.247.253')
# (net.getNodeByName('R1')).cmd('ip route add 161.46.247.192/27 via 161.46.247.254 dev R13')
# (net.getNodeByName('R1')).cmd('ip route add 161.46.247.128/26 via 161.46.247.254 dev R13')
if net.pingAll():
print(Fore.RED + "Network has issues" + Style.RESET_ALL)
else:
print(Fore.GREEN + "Network working properly" + Style.RESET_ALL)
CLI(net)
net.stop() #Stopping the network
if __name__ == '__main__':
run_topology('MininetTopo.conf')

@ -7,7 +7,8 @@
4. [Traffic MAC Analyzer (MACshuffle.sh)](#traffic-mac-analyzer-MACshufflesh) 4. [Traffic MAC Analyzer (MACshuffle.sh)](#traffic-mac-analyzer-MACshufflesh)
- [Execution](#execution) - [Execution](#execution)
- [Security in WPA3](#security-in-wpa3) - [Security in WPA3](#security-in-wpa3)
5. []()
- []()
## Overview of 5G ## Overview of 5G
5G is the fifth generation of wireless technology that promises to deliver faster data transfer speeds, lower latency, and increased network capacity. It is designed to enable a wide range of new applications and use cases that were previously not possible with 4G technology. 5G technology is based on a new radio access technology which uses higher frequency bands (millimeter waves) than previous generations of wireless technology. This allows 5G networks to deliver much faster data transfer speed. In addition offer greater network capacity, which means they can support more devices for the growth of the Internet of Things (IoT) and also promises to reduce latency to under 1 millisecond, which is critical for real-time applications such as gaming, remote surgery, autonomous machines. 5G is the fifth generation of wireless technology that promises to deliver faster data transfer speeds, lower latency, and increased network capacity. It is designed to enable a wide range of new applications and use cases that were previously not possible with 4G technology. 5G technology is based on a new radio access technology which uses higher frequency bands (millimeter waves) than previous generations of wireless technology. This allows 5G networks to deliver much faster data transfer speed. In addition offer greater network capacity, which means they can support more devices for the growth of the Internet of Things (IoT) and also promises to reduce latency to under 1 millisecond, which is critical for real-time applications such as gaming, remote surgery, autonomous machines.
Overall, 5G is expected to revolutionize the way we use wireless technology and enable new applications that were previously not possible. However, the rollout of 5G networks is still ongoing and faces challenges such as the need for more infrastructure and the use of higher frequency bands that have limited coverage compared to lower frequency bands. Overall, 5G is expected to revolutionize the way we use wireless technology and enable new applications that were previously not possible. However, the rollout of 5G networks is still ongoing and faces challenges such as the need for more infrastructure and the use of higher frequency bands that have limited coverage compared to lower frequency bands.
@ -63,11 +64,38 @@ sudo tcpdump -i <interface> -U -w .MACprobe.tmp | ./MACshuffle.sh -p
``` ```
### Security in WPA3 ### Security in WPA3
WPA3 is a security protocol for Wi-Fi networks introduced by the Wi-Fi Alliance. WPA3 is a security technology that is implemented on Wi-Fi networks based on the 802.11 standard. WPA3 is a security protocol for Wi-Fi networks introduced by the Wi-Fi Alliance. WPA3 is a security technology that is implemented on Wi-Fi networks based on the 802.11i standard.
WPA3 (Wi-Fi Protected Access 3) was introduced to improve the security of Wi-Fi networks over the previous version of WPA2 security. Among the main reasons why WPA3 was introduced are: WPA3 (Wi-Fi Protected Access 3) was introduced to improve the security of Wi-Fi networks over the previous version of WPA2 security. Among the main reasons why WPA3 was introduced are:
- Greater resistance to brute-force attacks: - Greater resistance to offline brute-force(dictionary) attacks:
WPA3 uses a more robust authentication system than WPA2, based on the Dragonfly authentication algorithm. This makes it harder for attackers to crack down Wi-Fi network passwords. WPA3 uses a more robust authentication system than WPA2, based on the Dragonfly authentication algorithm. This makes it harder for attackers to crack down Wi-Fi network passwords.
- Privacy improvements: - Privacy improvements:
WPA3 introduces a new forward secrecy encryption protocol that improves user privacy. This means that even if an attacker manages to decrypt the traffic of a Wi-Fi network session, they will not be able to decrypt the traffic of previous or subsequent sessions. WPA3 introduces a new forward secrecy (FS) encryption protocol that improves user privacy. This means that even if an attacker manages to decrypt the traffic of a Wi-Fi network session, they will not be able to decrypt the traffic of previous or subsequent sessions.
- Security key management vulnerabilities: - Security key management vulnerabilities:
WPA3 improves security key management over WPA2 by introducing the Simultaneous Authentication of Equals (SAE) key exchange protocol. SAE provides greater protection against dictionary attacks and allows you to set stronger passwords. WPA3 improves security key management over WPA2 by introducing the Simultaneous Authentication of Equals (SAE) key exchange protocol. SAE provides greater protection against dictionary attacks and allows you to set stronger passwords.
## qualcosa con Mininet
cosa serve, quali altri ci sono. come e' stata utilizzata e i file relativi
descrizione di quello che si vuole andare a fare
### Reinforcement Learning
In a Markov Decision Process(MDP) an AGENT is a decision maker that interact with the ENVIRONMENT that is placed in. These ACTIONS are sequential and every time an ACTION is taken, we get an observation of the STATE of the ENVIRONMENT. Based on the observation is chosen the ACTION to take; now the ENVIRONMENT goes into a new STATE and the AGENT gets a REWARD based on his ACTION. The AGENT not only wants to maximize the current REWARD but the cumulative REWARD over time.
S stati, R rewards, A azioni
sono legati da questa relazione f(St,At)=Rt+1
la traiettoria the rappresentail processo sequenziale pio essere rappresentata come S0,A0,R1,A1,R2,S2,A2,R3,...
foto del diagramma
Se Stati e Reword sono un insieme finito le variabili Rt e St avranno ben definita una distribuzione di probablita. Questa distribuzione dipende dallo stato precedente e dall'azione al passo t-1. possiamo definire cosi la probabilita, dato s e s' in S e r in R e a in A allora la prbabilita di transito di passare allo stato s' con una ricomoensa r intraprendendo l'azione a
p(s',r|s,a)=Pr{St=s',Rt=r|St-1=s,At-1=a}
(Q-Learning is a tecnique of Reinforcement Learning)
### Window Size
cos'e'?...
possiamo usare iperf per vedere l'impatto che ha cambiare la windows size.
con wireshark possiamo vedere i pacchetti e controllare la windows size(dentro TCP->flags->Window)
se fissiamo la windows size con 'iperf3 -c ip -t 10 -w 1000' ora i tcp datagram non possono essere piu grande di 1000, vedremo diminuire le prestazioni perche' prima di mandare altri dati dovremo aspettare di ricevere un acknowledgement dal ricevente. le performaces non sono determinate alle condizioni della reta ma da quello che stanno facento il client e server.
### Test TCP e RL in Mininet
test di valutzione e foto dei grafi
Loading…
Cancel
Save