def manage_association(self, switch, port, ue_hw_addr): """ Manage a UE association. Create a new association or update the existing one. """ # Check if UE is already in self.ues dictionary if ue_hw_addr in self.ues: # Update UE Association self.ues[ue_hw_addr].set_attachment(Association(switch, port)) self.logger.info("UE <%s> connected to <%s>, port %s", ue_hw_addr, str(hex(switch.switch.dp.id)), str(port.port_no)) else: self.last_ue_id += 1 # Add a new UE creating and a new Association self.ues[ue_hw_addr] = UE(self.last_ue_id, ue_hw_addr, ipv6_utils.ipv6_local_ucast_from_mac(ue_hw_addr)) self.ues[ue_hw_addr].set_attachment(Association(switch, port)) self.logger.info("UE <%s> connected to <%s>, port %s", ue_hw_addr, str(hex(switch.switch.dp.id)), str(port.port_no)) ev = EventUEConnected(self.ues[ue_hw_addr]) self.send_event_to_observers(ev)
def __init__(self, switch): """ ================ ========================================================= Attribute Description ================ ========================================================= switch Ryu Switch instance hw_addr Switch's Hardware address hw_addr_mcast Switch's Ethernet solicited node multicast address ipv6_local_ucast Switch's IPv6 local unicast address _addr ipv6_local_mcast Switch's IPv6 solicited node multicast address _addr links Switch's links available on the switch is_gw Mark the switch as Gateway, Boolean instance gw_conf Gateway configuration is_ap Mark the switch as Access Point, Boolean instance ap_conf Access Point configuration layer Layer of the switch in the newtork topology ================ ========================================================= """ self.switch = switch hw_addr = '{0:012x}'.format(self.switch.dp.id) self.hw_addr = ':'.join(a + b for a, b in zip(hw_addr[::2], hw_addr[1::2])) self.ipv6_local_ucast_addr = ipv6_utils.ipv6_local_ucast_from_mac( self.hw_addr) self.ipv6_local_mcast_addr = ipv6_utils.ipv6_local_mcast_from_mac( self.hw_addr) self.hw_addr_mcast = ipv6_utils.mac_mcast_from_ipv6_local_mcast( self.ipv6_local_mcast_addr) self.links = {} self.is_gw = False self.gw_conf = GatewayConf() self.is_ap = False self.ap_conf = AccessPointConf() self.layer = float('inf')
def _send_neighbor_advertisement(self, switch, port, eth_dst): """ Send a Neighbor Advertisement packet to eth_dst. The packet is sent through the the switch. The switch uses the installed OpenFlow rules to decide where to send the Neighbor Advertisement packet. """ eth_src = switch.hw_addr ipv6_src = switch.ipv6_local_ucast_addr eth_dst = eth_dst ipv6_dst = ipv6_utils.ipv6_local_ucast_from_mac(eth_dst) # Create a Neighbor Advertisment with the extracted info nd_neighbor_adv = NeighborAdvertisement(eth_src, eth_dst, ipv6_src, ipv6_dst, switch.is_gw) pkt = nd_neighbor_adv.pkt pkt.serialize() # Send the Neighbor Advertisment req = EventPushPacket(switch, port, pkt) self.send_event(req.dst, req)
def _send_neighbor_advertisement(self, switch, port, eth_dst): """ Send a Neighbor Advertisement packet to eth_dst. The packet is sent through the the switch. The switch uses the installed OpenFlow rules to decide where to send the Neighbor Advertisement packet. """ eth_src = switch.hw_addr ipv6_src = switch.ipv6_local_ucast_addr eth_dst = eth_dst ipv6_dst = ipv6_utils.ipv6_local_ucast_from_mac(eth_dst) # Create a Neighbor Advertisment with the extracted info nd_neighbor_adv = NeighborAdvertisement(eth_src, eth_dst, ipv6_src, ipv6_dst, switch.is_gw) pkt = nd_neighbor_adv.pkt pkt.serialize() # Send the Neighbor Advertisment req = EventPushPacket(switch, port, pkt) self.send_event(req.dst, req)
def __init__(self, switch): """ ================ ========================================================= Attribute Description ================ ========================================================= switch Ryu Switch instance hw_addr Switch's Hardware address hw_addr_mcast Switch's Ethernet solicited node multicast address ipv6_local_ucast Switch's IPv6 local unicast address _addr ipv6_local_mcast Switch's IPv6 solicited node multicast address _addr links Switch's links available on the switch is_gw Mark the switch as Gateway, Boolean instance gw_conf Gateway configuration is_ap Mark the switch as Access Point, Boolean instance ap_conf Access Point configuration layer Layer of the switch in the newtork topology ================ ========================================================= """ self.switch = switch hw_addr = '{0:012x}'.format(self.switch.dp.id) self.hw_addr = ':'.join(a+b for a, b in zip(hw_addr[::2], hw_addr[1::2])) self.ipv6_local_ucast_addr = ipv6_utils.ipv6_local_ucast_from_mac(self.hw_addr) self.ipv6_local_mcast_addr = ipv6_utils.ipv6_local_mcast_from_mac(self.hw_addr) self.hw_addr_mcast = ipv6_utils.mac_mcast_from_ipv6_local_mcast(self.ipv6_local_mcast_addr) self.links = {} self.is_gw = False self.gw_conf = GatewayConf() self.is_ap = False self.ap_conf = AccessPointConf() self.layer = float('inf')
def manage_association(self, switch, port, ue_hw_addr): """ Manage a UE association. Create a new association or update the existing one. """ # Check if UE is already in self.ues dictionary if ue_hw_addr in self.ues: # Update UE Association self.ues[ue_hw_addr].set_attachment(Association(switch, port)) self.logger.info("UE <%s> connected to <%s>, port %s", ue_hw_addr, str(hex(switch.switch.dp.id)), str(port.port_no)) else: self.last_ue_id += 1 # Add a new UE creating and a new Association self.ues[ue_hw_addr] = UE( self.last_ue_id, ue_hw_addr, ipv6_utils.ipv6_local_ucast_from_mac(ue_hw_addr)) self.ues[ue_hw_addr].set_attachment(Association(switch, port)) self.logger.info("UE <%s> connected to <%s>, port %s", ue_hw_addr, str(hex(switch.switch.dp.id)), str(port.port_no)) ev = EventUEConnected(self.ues[ue_hw_addr]) self.send_event_to_observers(ev)