Ejemplo n.º 1
0
    def fire_send_fv_packets(self):

        time_val = time.time() * 1000
        logger.info("Sending FV Packets rate: " + str(self.fv_pkt_rate) +
                    " with vlan: " + str(self.FV_VLAN_ID) + " packets: " +
                    str(len(self.packets)))

        for pkt in self.packets:
            logger.info("Packet:")
            packet = ethernet()
            packet.src = '\x00' + struct.pack('!Q', pkt[0])[3:8]
            packet.dst = NDP_MULTICAST

            payload = struct.pack('QHQHq', pkt[0], pkt[1], pkt[2], pkt[3],
                                  time_val)

            if (self.FV_VLAN_ID != None and self.FV_VLAN_ID != 65535):
                vlan_packet = vlan()
                vlan_packet.id = self.FV_VLAN_ID
                vlan_packet.c = 0
                vlan_packet.pcp = 0
                vlan_packet.eth_type = 0x88b6
                vlan_packet.set_payload(payload)

                packet.set_payload(vlan_packet)
                packet.type = ethernet.VLAN_TYPE

            else:
                packet.set_payload(payload)
                packet.type = 0x88b6

            Component.send_openflow_packet(pkt[0], packet.tostring(),
                                           int(pkt[1]))

        self.post_callback(fv_pkt_rate_interval, self.fire_send_fv_packets)
Ejemplo n.º 2
0
    def send_traceroute_packet(self, **kwargs):
        logger.debug("Sending pack to trigger process_trace_packet.")

        dpid = kwargs.get('dpid')
        my_vlan = kwargs.get('my_vlan')
        out_port = kwargs.get('out_port')
        data = kwargs.get('data')

        #build ethernet packet
        packet = ethernet()
        packet.src = '\x00' + struct.pack('!Q', dpid)[3:8]
        packet.dst = TRACEROUTE_MAC
        #pack circuit_id into payload
        payload = struct.pack('I', data)

        if (my_vlan != None and my_vlan != 65535):
            vlan_packet = vlan()
            vlan_packet.id = my_vlan
            vlan_packet.c = 0
            vlan_packet.pcp = 0
            vlan_packet.eth_type = 0x88b5
            vlan_packet.set_payload(payload)

            packet.set_payload(vlan_packet)
            packet.type = ethernet.VLAN_TYPE

        else:
            packet.set_payload(payload)
            packet.type = 0x88b5

        Component.send_openflow_packet(self, int(dpid), packet.tostring(),
                                       int(out_port))

        return
Ejemplo n.º 3
0
    def send_traceroute_packet(self, dpid, my_vlan, out_port, data):
        #build ethernet packet
        packet = ethernet()
        packet.src = '\x00' + struct.pack('!Q', dpid)[3:8]
        packet.dst = TRACEROUTE_MAC
        #pack circuit_id into payload
        payload = struct.pack('I', data)

        if (my_vlan != None and my_vlan != 65535):
            vlan_packet = vlan()
            vlan_packet.id = my_vlan
            vlan_packet.c = 0
            vlan_packet.pcp = 0
            vlan_packet.eth_type = 0x88b5
            vlan_packet.set_payload(payload)

            packet.set_payload(vlan_packet)
            packet.type = ethernet.VLAN_TYPE

        else:
            packet.set_payload(payload)
            packet.type = 0x88b5

        inst.send_openflow_packet(int(dpid), packet.tostring(), int(out_port))

        return
Ejemplo n.º 4
0
    def fire_send_fv_packets(self):

        time_val = time() * 1000
        logger.info("Sending FV Packets rate: " + str(self.sg.fv_pkt_rate) + " with vlan: " + str(self.sg.VLAN_ID) + " packets: " + str(len(self.sg.packets)))

        for pkt in self.sg.packets:
            logger.info("Packet:")
            packet = ethernet()
            packet.src = '\x00' + struct.pack('!Q',pkt[0])[3:8]
            packet.dst = NDP_MULTICAST

            payload = struct.pack('QHQHq',pkt[0],pkt[1],pkt[2],pkt[3],time_val)

            if(self.sg.VLAN_ID != None and self.sg.VLAN_ID != 65535):
                vlan_packet = vlan()
                vlan_packet.id = self.sg.VLAN_ID
                vlan_packet.c = 0
                vlan_packet.pcp = 0
                vlan_packet.eth_type = 0x88b6
                vlan_packet.set_payload(payload)

                packet.set_payload(vlan_packet)
                packet.type = ethernet.VLAN_TYPE

            else:
                packet.set_payload(payload)
                packet.type = 0x88b6

            inst.send_openflow_packet(pkt[0], packet.tostring(), int(pkt[1]))

        self.post_callback(fv_pkt_rate, self.fire_send_fv_packets)
Ejemplo n.º 5
0
    def send_traceroute_packet(self,dpid,my_vlan,out_port,data):
        #build ethernet packet
        packet = ethernet()
        packet.src = '\x00' + struct.pack('!Q',dpid)[3:8]
        packet.dst = TRACEROUTE_MAC
        #pack circuit_id into payload
        payload = struct.pack('I',data)
        
        if(my_vlan != None and my_vlan != 65535):
            vlan_packet = vlan()
            vlan_packet.id = my_vlan
            vlan_packet.c = 0
            vlan_packet.pcp = 0
            vlan_packet.eth_type = 0x88b5
            vlan_packet.set_payload(payload)

            packet.set_payload(vlan_packet)
            packet.type = ethernet.VLAN_TYPE
            
        else:
            packet.set_payload(payload)
            packet.type = 0x88b5
        
        inst.send_openflow_packet(int(dpid), packet.tostring(),int(out_port))

        return
Ejemplo n.º 6
0
    def send_traceroute_packet(self, **kwargs):
        logger.debug("Sending pack to trigger process_trace_packet.")

        dpid     = kwargs.get('dpid')
        my_vlan  = kwargs.get('my_vlan')
        out_port = kwargs.get('out_port')
        data     = kwargs.get('data')

        #build ethernet packet
        packet = ethernet()
        packet.src = '\x00' + struct.pack('!Q',dpid)[3:8]
        packet.dst = TRACEROUTE_MAC
        #pack circuit_id into payload
        payload = struct.pack('I',data)
        
        if(my_vlan != None and my_vlan != 65535):
            vlan_packet = vlan()
            vlan_packet.id = my_vlan
            vlan_packet.c = 0
            vlan_packet.pcp = 0
            vlan_packet.eth_type = 0x88b5
            vlan_packet.set_payload(payload)

            packet.set_payload(vlan_packet)
            packet.type = ethernet.VLAN_TYPE
            
        else:
            packet.set_payload(payload)
            packet.type = 0x88b5
        
        Component.send_openflow_packet(self, int(dpid), packet.tostring(),int(out_port))

        return
Ejemplo n.º 7
0
def create_discovery_packet(dpid, portno, vlan_id, ttl_):    

    # Create lldp packet
    discovery_packet = lldp()
    cid = chassis_id()

    # nbo 
    cid.fill(chassis_id.SUB_LOCAL, array.array('B', 'dpid:' + hex(long(dpid))[2:-1]))
    discovery_packet.add_tlv(cid)

    pid = port_id()
    pid.fill(2,array.array('B',struct.pack('!H', portno)))
    discovery_packet.add_tlv(pid)

    ttlv = ttl()
    ttlv.fill(ttl_)
    discovery_packet.add_tlv(ttlv)

    discovery_packet.add_tlv(end_tlv())

    eth = ethernet()
    eth.src = '\x00' + struct.pack('!Q',dpid)[3:8]
    eth.dst = NDP_MULTICAST
    
    if(vlan_id != None):
        
        vlan_packet = vlan()
        vlan_packet.id = vlan_id
        vlan_packet.pcp = 0
        vlan_packet.c = 0
        vlan_packet.eth_type = ethernet.LLDP_TYPE
        vlan_packet.set_payload(discovery_packet)

        eth.set_payload(vlan_packet)
        eth.type = ethernet.VLAN_TYPE
        eth.eth_type = ethernet.LLDP_TYPE
    
    else:
        eth.set_payload(discovery_packet)
        eth.type = ethernet.LLDP_TYPE
        

    return eth