safiaa02 commited on
Commit
c8e254a
·
verified ·
1 Parent(s): d41ff62

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +1 -36
app.py CHANGED
@@ -5,12 +5,7 @@ import plotly.express as px
5
  from datetime import datetime, timedelta
6
  from prophet import Prophet
7
  import networkx as nx
8
- from ryu.base import app_manager
9
- from ryu.controller import ofp_event
10
- from ryu.controller.handler import MAIN_DISPATCHER, set_ev_cls
11
- from ryu.ofproto import ofproto_v1_3
12
- from ryu.lib.packet import packet, ethernet
13
- from gevent import event
14
 
15
  # Generate synthetic data
16
  def generate_data():
@@ -60,36 +55,6 @@ def sdn_load_balancer(network_graph, demand_predictions):
60
  shortest_paths[school] = nx.shortest_path(network_graph, source='Central_Node', target=school)
61
  return shortest_paths
62
 
63
- # SDN Controller Class
64
- class SimpleSwitch13(app_manager.RyuApp):
65
- OFP_VERSIONS = [ofproto_v1_3.OFP_VERSION]
66
-
67
- def __init__(self, *args, **kwargs):
68
- super(SimpleSwitch13, self).__init__(*args, **kwargs)
69
- self.mac_to_port = {}
70
-
71
- @set_ev_cls(ofp_event.EventOFPPacketIn, MAIN_DISPATCHER)
72
- def packet_in_handler(self, ev):
73
- msg = ev.msg
74
- datapath = msg.datapath
75
- ofproto = datapath.ofproto
76
- parser = datapath.ofproto_parser
77
- in_port = msg.match['in_port']
78
-
79
- pkt = packet.Packet(msg.data)
80
- eth = pkt.get_protocol(ethernet.ethernet)
81
- dst = eth.dst
82
- src = eth.src
83
-
84
- if dst in self.mac_to_port:
85
- out_port = self.mac_to_port[dst]
86
- else:
87
- out_port = ofproto.OFPP_FLOOD
88
-
89
- actions = [parser.OFPActionOutput(out_port)]
90
- out = parser.OFPPacketOut(datapath=datapath, buffer_id=msg.buffer_id, in_port=in_port, actions=actions, data=msg.data)
91
- datapath.send_msg(out)
92
-
93
  # Create a simple network topology
94
  graph = nx.Graph()
95
 
 
5
  from datetime import datetime, timedelta
6
  from prophet import Prophet
7
  import networkx as nx
8
+ from eventlet import event
 
 
 
 
 
9
 
10
  # Generate synthetic data
11
  def generate_data():
 
55
  shortest_paths[school] = nx.shortest_path(network_graph, source='Central_Node', target=school)
56
  return shortest_paths
57
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
58
  # Create a simple network topology
59
  graph = nx.Graph()
60