Exemple #1
0
def install_match_port_entry(dpid, port_id, backup_port_list):

    # print"##############################################"
    table_id = core.PofManager.get_flow_table_id(dpid, 'CheckPortNumTable')
    match = pof.ofp_match20(field_id=-1, offset=56, length=8)
    matchx_port = core.PofManager.new_matchx(match, port_id, "FF")
    backup_port_len = len(backup_port_list)
    port_str = ''
    match_ttl = core.PofManager.get_field('TTL')[0]
    del_field_action = core.PofManager.new_action_delete_field(field_position=PORT_FIELD_OFFSET, \
                                                               length_value_type=0, \
                                                               length_value=PORT_FIELD_LEN, \
                                                               )
    ins_apply_action = core.PofManager.new_ins_apply_actions([del_field_action])
    ins_decrease_ttl = core.PofManager.new_ins_calculate_field(pof.OFPCT_SUBTRACT, 0, \
                                                               match_ttl, 1)


    ins0 = core.PofManager.new_ins_write_metadata_from_packet(64, 120, 0)
    for port in backup_port_list:
        if port < 16:
            port_str = port_str + '0' + hex(port)[2:]
        else:
            port_str = port_str + hex(port)[2:]

    ins1 = core.PofManager.new_ins_write_metadata(184, backup_port_len * 8, port_str)
    metadata_ttl = pof.ofp_match20(field_id=-1, offset=176, length=8)
    #ins2 = core.PofManager.new_ins_calculate_field(0, 0, metadata_ttl, backup_port_len - 1)
    ins2 = core.PofManager.new_ins_calculate_field(0, 0, metadata_ttl, backup_port_len)
    new_action1 = core.PofManager.new_action_group(string.atoi(port_id))
    ins3 = core.PofManager.new_ins_apply_actions([new_action1])
    core.PofManager.add_flow_entry(dpid, table_id, [matchx_port], [ins_apply_action,ins_decrease_ttl,ins0, ins1, ins2, ins3])
Exemple #2
0
def _group_mod(dpid, output_port, backup_output_port, backup_port_len):
    # del_field_action = core.PofManager.new_action_delete_field(field_position=PORT_FIELD_OFFSET, \
    #                                                            length_value_type=0, \
    #                                                            length_value=PORT_FIELD_LEN, \
    #                                                            )

    metadata_port = pof.ofp_match20(field_id=-1, offset=32, length=32)
    output_action1 = core.PofManager.new_action_output(port_id_value_type=1, \
                                                       metadata_offset=0, \
                                                       metadata_length=0, \
                                                       packet_offset=0, \
                                                       port_id=output_port, \
                                                       port_id_field=metadata_port)

    bucket1 = new_bucket([output_action1], watch_port=output_port)

    # ------
    output_action2 = core.PofManager.new_action_output(port_id_value_type=0, \
                                                       metadata_offset=64, \
                                                       metadata_length=120 + backup_port_len * 8, \
                                                       packet_offset=15, \
                                                       port_id=backup_output_port, \
                                                       )

    bucket2 = new_bucket([output_action2], watch_port=backup_output_port)

    add_ff_group_table(dpid=dpid, group_id=output_port, bucket_list=[bucket1,bucket2])
Exemple #3
0
 def new_metadata_field(self, field_name, field_offset, field_length):
     """
     if field_offset < 32:
         log.error("wrong offset")
         return None
     """
     if len(self.metadata_list) != 0 and field_offset < (
         self.metadata_list[-1].offset + self.metadata_list[-1].length
     ):
         log.error("wrong offset")
         return None
     match_field = of.ofp_match20()
     match_field.field_name = field_name
     match_field.field_id = -1
     match_field.offset = field_offset
     match_field.length = field_length
     log.info(
         "Add Metadata [offset] "
         + str(field_offset)
         + " [length] "
         + str(field_length)
         + " [field_name] "
         + field_name
     )
     self.metadata_list.append(match_field)
Exemple #4
0
def _install_output_entry(dpid):
    table_id = core.PofManager.get_flow_table_id(dpid, 'FirstEntryTable')
    match = core.PofManager.get_field('SIP')[0]
    temp_matchx = core.PofManager.new_matchx(match, '0a000001', 'FFFFFFFF')
    metadata_port = pof.ofp_match20(field_id=-1, offset=32, length=8)




    output_action = core.PofManager.new_action_output(port_id_value_type=0, \
                                                      metadata_offset=32, \
                                                      metadata_length=32, \
                                                      packet_offset=120, \
                                                      port_id=2, \
                                                      port_id_field=metadata_port)

    ins_apply_action = core.PofManager.new_ins_apply_actions([output_action])

    ins_write_port_to_metadata = core.PofManager.new_ins_write_metadata_from_packet( \
        metadata_offset=32 , \
        write_length=32, \
        packet_offset=120)

    core.PofManager.add_flow_entry(dpid, table_id, [temp_matchx],
                                   [ins_apply_action])
Exemple #5
0
    def _handle_ConnectionUp(self, event):
        # add_flow_table(self, switch_id, table_name, table_type, table_size, match_field_list = [])
        core.PofManager.add_flow_table(event.dpid, 'FirstEntryTable', pof.OF_MM_TABLE, 128, \
                                       [core.PofManager.get_field('DL_TYPE')[0]])
        core.PofManager.add_flow_table(event.dpid, 'WritePortToMetadataTable', pof.OF_LINEAR_TABLE, 1)
        core.PofManager.add_flow_table(event.dpid, 'CheckTTL_Fork', pof.OF_MM_TABLE, 4, \
                                       [core.PofManager.get_field('TTL')[0], core.PofManager.get_field('ForkFlag')[0]])
        core.PofManager.add_flow_table(event.dpid, 'OutputTable', pof.OF_LINEAR_TABLE, 1)
        core.PofManager.add_flow_table(event.dpid, 'SRHeaderEncapTable', pof.OF_EM_TABLE, 3000, \
                                       [core.PofManager.get_field('SIP')[0], core.PofManager.get_field('SPORT')[0]])
        core.PofManager.add_flow_table(event.dpid, 'ARPTargetIPTable', pof.OF_MM_TABLE, 128, \
                                       [core.PofManager.get_field('TPA')[0]])
        # multicast table
        # core.PofManager.add_flow_table(event.dpid, 'CheckFork', pof.OF_MM_TABLE, 2, \
        #                                [core.PofManager.get_field('ForkFlag')[0]])
        metadata_port = pof.ofp_match20(field_id=-1, offset=52, length=12)
        core.PofManager.add_flow_table(event.dpid, 'GroupMatchTable', pof.OF_EM_TABLE, 3000, [metadata_port])

        import time
        time.sleep(1)  # error if not sleep, maybe send flowmod too fast.

        _install_type_match_entry(event.dpid)
        _install_write_port_to_metadata_entry(event.dpid)
        # _install_ttl_match_entry(event.dpid, match_value='01', match_mask='FF', prior=0x0700)
        # _install_ttl_match_entry(event.dpid, match_value='01', match_mask='00')
        _install_output_entry(event.dpid)

        # ingress node table
        _install_srheader_encap_table(event.dpid)

        install_arp_type_match_entry(event.dpid)

        # fork node
        # install_checkfork_entry(event.dpid)
        install_check_ttl_fork_entry(event.dpid)
Exemple #6
0
    def _group_mod(self, dpid, output_port, backup_output_port,
                   backup_port_len):

        metadata_port = pof.ofp_match20(field_id=-1, offset=32, length=32)
        output_action1 = core.PofManager.new_action_output(port_id_value_type=1, \
                                                          metadata_offset=0, \
                                                          metadata_length=0, \
                                                          packet_offset=0, \
                                                          port_id=output_port, \
                                                          port_id_field=metadata_port)

        bucket1 = new_bucket([output_action1], watch_port=output_port)

        #------
        output_action2 = core.PofManager.new_action_output(port_id_value_type=0, \
                                                           metadata_offset=64, \
                                                           metadata_length=120+backup_port_len*8, \
                                                           packet_offset=15, \
                                                           port_id=backup_output_port, \
                                                           )

        bucket2 = new_bucket([output_action2], watch_port=backup_output_port)

        add_ff_group_table(dpid=dpid,
                           group_id=output_port,
                           bucket_list=[bucket1, bucket2])
Exemple #7
0
 def new_field(self, field_name, offset, length):  # FIXME:??
     field_id = self.field_id_no
     match_field = of.ofp_match20()
     match_field.field_name = field_name
     match_field.field_id = field_id
     match_field.offset = offset
     match_field.length = length
     self.field_database[field_id] = match_field
     self.field_id_no += 1
     return field_id
Exemple #8
0
 def new_field(self, field_name, offset, length):  # FIXME:??
     field_id = self.field_id_no
     match_field = of.ofp_match20()
     match_field.field_name = field_name
     match_field.field_id = field_id
     match_field.offset = offset
     match_field.length = length
     self.field_database[field_id] = match_field
     self.field_id_no += 1
     return field_id
Exemple #9
0
 def new_field(self, field_name, offset, length):  # FIXME:??
     field_id = self.field_id_no
     match_field = of.ofp_match20()
     match_field.field_name = field_name
     match_field.field_id = field_id
     match_field.offset = offset
     match_field.length = length
     self.field_database[field_id] = match_field
     self.field_id_no += 1
     log.info("Add Field [field_id] "+ str(field_id) + " [offset] " + str(offset) + " [length] " + str(length) + " [field_name] " + field_name)
     return field_id
def _install_output_entry(dpid):
    table_id = core.PofManager.get_flow_table_id(dpid, 'OutputTable')
    metadata_port = pof.ofp_match20(field_id=-1, offset=32, length=32)
    output_action = core.PofManager.new_action_output(port_id_value_type=1, \
                                                      metadata_offset=0, \
                                                      metadata_length=0, \
                                                      packet_offset=0, \
                                                      port_id=0, \
                                                      port_id_field=metadata_port)
    ins_apply_action = core.PofManager.new_ins_apply_actions([output_action])
    core.PofManager.add_flow_entry(dpid, table_id, [], [ins_apply_action])
Exemple #11
0
def install_match_port_entry(dpid, port_id, backup_port_list):
    #print"##############################################"
    table_id = core.PofManager.get_flow_table_id(dpid, 'CheckPortNumTable')
    match = pof.ofp_match20(field_id=-1, offset=56, length=8)
    matchx_port = core.PofManager.new_matchx(match, port_id, "FF")
    backup_port_len = len(backup_port_list)
    port_str = ''
    ins0 = core.PofManager.new_ins_write_metadata_from_packet(64, 120, 0)
    for port in backup_port_list:
        if port < 16:
            port_str = port_str + '0' + hex(port)[2:]
        else:
            port_str = port_str + hex(port)[2:]

    ins1 = core.PofManager.new_ins_write_metadata(184, backup_port_len * 8,
                                                  port_str)
    metadata_ttl = pof.ofp_match20(field_id=-1, offset=176, length=8)
    ins2 = core.PofManager.new_ins_calculate_field(0, 0, metadata_ttl,
                                                   backup_port_len)
    new_action1 = core.PofManager.new_action_group(string.atoi(port_id))
    ins3 = core.PofManager.new_ins_apply_actions([new_action1])
    core.PofManager.add_flow_entry(dpid, table_id, [matchx_port],
                                   [ins0, ins1, ins2, ins3])
Exemple #12
0
 def new_metadata_field(self, field_name, field_offset, field_length):
     """
     if field_offset < 32:
         log.error("wrong offset")
         return None
     """
     if len(self.metadata_list) != 0 and field_offset < (self.metadata_list[-1].offset + self.metadata_list[-1].length):
         log.error("wrong offset")
         return None
     match_field = of.ofp_match20()
     match_field.field_name = field_name
     match_field.field_id = -1
     match_field.offset = field_offset
     match_field.length = field_length
     self.metadata_list.append(match_field)
Exemple #13
0
 def new_metadata_field(self, field_name, field_offset, field_length):
     """
     if field_offset < 32:
         log.error("wrong offset")
         return None
     """
     if len(self.metadata_list) != 0 and field_offset < (self.metadata_list[-1].offset + self.metadata_list[-1].length):
         log.error("wrong offset")
         return None
     match_field = of.ofp_match20()
     match_field.field_name = field_name
     match_field.field_id = -1
     match_field.offset = field_offset
     match_field.length = field_length
     log.info("Add Metadata [offset] " + str(field_offset) + " [length] " + str(field_length) + " [field_name] " + field_name)
     self.metadata_list.append(match_field)
Exemple #14
0
    def _handle_ConnectionUp(self, event):
        msg = pof.ofp_table_mod()
        match = pof.ofp_match20(field_id=1, offset=0, length=48)
        #match.field_id = 1
        #match.offset = 0
        #match.length = 48
        msg.flow_table.match_field_list.append(match)
        msg.flow_table.match_field_num = 1
        msg.flow_table.table_size = 128
        msg.flow_table.key_length = 48
        msg.flow_table.table_name = 'FirstEntryTable'

        print 'send TABLE_MOD message:\n', msg

        event.connection.send(msg)
        """
Exemple #15
0
 def new_metadata_field(self, field_name, field_offset, field_length):
     """
     if field_offset < 32:
         log.error("wrong offset")
         return None
     """
     if len(self.metadata_list) != 0 and field_offset < (
             self.metadata_list[-1].offset + self.metadata_list[-1].length):
         log.error("wrong offset")
         return None
     match_field = of.ofp_match20()
     match_field.field_name = field_name
     match_field.field_id = -1
     match_field.offset = field_offset
     match_field.length = field_length
     self.metadata_list.append(match_field)
Exemple #16
0
 def _handle_ConnectionUp(self, event):
     msg = pof.ofp_table_mod()
     match = pof.ofp_match20(field_id = 1, offset  = 0, length = 48)
     #match.field_id = 1
     #match.offset = 0
     #match.length = 48
     msg.flow_table.match_field_list.append(match)
     msg.flow_table.match_field_num = 1
     msg.flow_table.table_size = 128
     msg.flow_table.key_length = 48
     msg.flow_table.table_name = 'FirstEntryTable'
     
     print 'send TABLE_MOD message:\n', msg
        
     event.connection.send(msg)
     """
Exemple #17
0
def install_grouplabel_entry(dpid, group_label, output_port, new_path_port_list, new_output_port_list, pkt_offset):
    table_id = core.PofManager.get_flow_table_id(dpid, 'GroupMatchTable')
    grouplabel_match = core.PofManager.get_field('GroupLabel')[0]
    grouplabel_match = pof.ofp_match20(field_id=-1, offset=52, length=12)
    grouplabel_matchx = core.PofManager.new_matchx(grouplabel_match, group_label, 'FF'*(PORT_FIELD_LEN/8))

    ins_list = []
    md_offset = 64
    md_offset_cur = md_offset
    # for primary path
    output_action_list = []
    output_action_pri = core.PofManager.new_action_output(port_id_value_type=0, \
                                                      metadata_offset=0, \
                                                      metadata_length=0, \
                                                      packet_offset=0, \
                                                      port_id=output_port, \
                                                      port_id_field=None)
    output_action_list.append(output_action_pri)

    md_len = 0
    #TODO: Delete
    # print "new_path_port_list", new_path_port_list
    # print 'new_outoput_port_list', new_output_port_list
    for path_port, output_port in zip(new_path_port_list, new_output_port_list):
        # print 'metadata offset b4:', md_offset
        each_ins_list, md_offset = _assemble_sr_header_in_metadata_on_forknode(path_port, metadata_offset=md_offset)
        ins_list = ins_list + each_ins_list
        # print 'metadata offset after:', md_offset

        md_len = md_offset - md_offset_cur
        output_action = core.PofManager.new_action_output(port_id_value_type=0, \
                                                          metadata_offset=md_offset_cur, \
                                                          metadata_length=md_len, \
                                                          packet_offset=pkt_offset, \
                                                          port_id=output_port, \
                                                          port_id_field=None)
        output_action_list.append(output_action)
        md_offset_cur += md_len
    # output_action_list.append(output_action_pri)

    apply_action_ins = core.PofManager.new_ins_apply_actions(output_action_list)
    ins_list.append(apply_action_ins)

    core.PofManager.add_flow_entry(dpid, table_id, [grouplabel_matchx], ins_list,0, False)
Exemple #18
0
 def new_field(self, field_name, offset, length):  # FIXME:??
     field_id = self.field_id_no
     match_field = of.ofp_match20()
     match_field.field_name = field_name
     match_field.field_id = field_id
     match_field.offset = offset
     match_field.length = length
     self.field_database[field_id] = match_field
     self.field_id_no += 1
     log.info(
         "Add Field [field_id] "
         + str(field_id)
         + " [offset] "
         + str(offset)
         + " [length] "
         + str(length)
         + " [field_name] "
         + field_name
     )
     return field_id
Exemple #19
0
 def _handle_ConnectionUp(self, event):
     msg = pof.ofp_table_mod()
     match = pof.ofp_match20()
     match.field_id = 1
     match.offset = 0
     match.length = 48
     msg.flow_table.match_field_list.append(match)
     msg.flow_table.match_field_num = 1
     msg.flow_table.table_size = 128
     msg.flow_table.key_length = 48
     msg.flow_table.table_name = 'FirstEntryTable'
     
     print 'send TABLE_MOD message:\n', msg
        
     event.connection.send(msg)
     
     
     msg = pof.ofp_flow_mod()
     msg.priority = 0
     msg.table_id=0
     matchx = pof.ofp_matchx()
     matchx.field_id = 1
     matchx.offset = 0
     matchx.length = 48
     matchx.value="010203040506"
     matchx.mask="000000000000"
     msg.match_list.append(matchx)
     msg.match_field_num = 1
     
     instruction = pof.ofp_instruction_goto_table()
     instruction.next_table_id=1
     #instruction.type = 6
     #instruction.length = 16
     msg.instruction_list.append(instruction)
     msg.instruction_num = 1
     
     print 'send FLOW_MOD message:\n', msg
                 
     event.connection.send(msg)
Exemple #20
0
    def _handle_ConnectionUp(self, event):
        msg = pof.ofp_table_mod()
        match = pof.ofp_match20()
        match.field_id = 1
        match.offset = 0
        match.length = 48
        msg.flow_table.match_field_list.append(match)
        msg.flow_table.match_field_num = 1
        msg.flow_table.table_size = 128
        msg.flow_table.key_length = 48
        msg.flow_table.table_name = 'FirstEntryTable'

        print 'send TABLE_MOD message:\n', msg

        event.connection.send(msg)

        msg = pof.ofp_flow_mod()
        msg.priority = 0
        msg.table_id = 0
        matchx = pof.ofp_matchx()
        matchx.field_id = 1
        matchx.offset = 0
        matchx.length = 48
        matchx.value = "010203040506"
        matchx.mask = "000000000000"
        msg.match_list.append(matchx)
        msg.match_field_num = 1

        instruction = pof.ofp_instruction_goto_table()
        instruction.next_table_id = 1
        #instruction.type = 6
        #instruction.length = 16
        msg.instruction_list.append(instruction)
        msg.instruction_num = 1

        print 'send FLOW_MOD message:\n', msg

        event.connection.send(msg)
Exemple #21
0
    def __init__(self, req):
        self.match_list = []
        self.matchx_list = []
        if req['type'] == 'path_setup_request':
            field_id = 0
            for each_field in req['matchList']:
                match_field = of.ofp_match20(field_name=each_field['name'],
                                             field_id=field_id,
                                             offset=each_field['offset'],
                                             length=each_field['length'])
                self.match_list.append(match_field)

                matchx_field = of.ofp_matchx(
                    field_name=match_field.field_name,
                    field_id=match_field.field_id,
                    offset=match_field.offset,
                    length=match_field.length,
                    value=ip2hex(each_field['value']))  #  value is hex string
                print matchx_field.value
                self.matchx_list.append(matchx_field)
                field_id += 1

        else:
            log.error('path setup req : type error')
Exemple #22
0
def install_check_ttl_fork_entry(dpid):
    '''
    +-------------------------------------------+
    |                  Table 3                  |
    +--------+----------------------------------+
    |ttl+Fork|           Instructions           |
    +--------+----------------------------------+
    |00000001| Apply-Action:                    |
    |1       | Del-Field (TTL + Port)           |
    |        +----------------------------------+
    |        | Go-To-Table: 4                   |
    +--------+----------------------------------+
    |00000001| Apply-Action:                    |
    |0       | Del-Field (TTL+Port)             |
    |        |                                  |
    |        | Output(Port Buffer)              |
    +--------+----------------------------------+
    |********| Apply-Action:                    |
    |1       | Del-Field (Port)                 |
    |        +----------------------------------+
    |        | Go-To-Table: 4                   |
    +--------+----------------------------------+
    |********| Apply-Action:                    |
    |0       | Del-Field (Port)                 |
    |        |                                  |
    |        | Output(Port Buffer)              |
    +--------+----------------------------------+
    '''
    table_id = core.PofManager.get_flow_table_id(dpid, 'CheckTTL_Fork')
    match_ttl = core.PofManager.get_field('TTL')[0]
    match_fork = core.PofManager.get_field('ForkFlag')[0]

    # 1.
    matchx_ttl1 = core.PofManager.new_matchx(match_ttl, '01', 'FF')
    match_fork1 = core.PofManager.new_matchx(match_fork, '8', '8')
    del_field_action = core.PofManager.new_action_delete_field(field_position=TTL_FIELD_OFFSET, \
                                                               length_value_type=0, \
                                                               length_value=TTL_FIELD_LEN + PORT_FIELD_LEN, \
                                                               )
    match_dl_type = core.PofManager.get_field('DL_TYPE')[0]
    dl_type_field = core.PofManager.new_matchx(match_dl_type, '0800', 'FFFF')
    set_field_action = core.PofManager.new_action_set_field(dl_type_field)
    ins_apply_action = core.PofManager.new_ins_apply_actions([del_field_action, set_field_action])
    next_table_id = core.PofManager.get_flow_table_id(dpid, 'GroupMatchTable')
    ins_go_to_table = core.PofManager.new_ins_goto_table(dpid, next_table_id)
    core.PofManager.add_flow_entry(dpid, table_id, [matchx_ttl1, match_fork1], [ins_apply_action, ins_go_to_table],0, False)

    # 2.
    matchx_ttl1 = core.PofManager.new_matchx(match_ttl, '01', 'FF')
    match_fork1 = core.PofManager.new_matchx(match_fork, '0', '8')
    del_field_action = core.PofManager.new_action_delete_field(field_position=TTL_FIELD_OFFSET, \
                                                               length_value_type=0, \
                                                               length_value=TTL_FIELD_LEN + PORT_FIELD_LEN, \
                                                               )
    match_dl_type = core.PofManager.get_field('DL_TYPE')[0]
    dl_type_field = core.PofManager.new_matchx(match_dl_type, '0800', 'FFFF')
    set_field_action = core.PofManager.new_action_set_field(dl_type_field)
    metadata_port = pof.ofp_match20(field_id=-1, offset=32, length=32)
    output_action = core.PofManager.new_action_output(port_id_value_type=1, \
                                                      metadata_offset=0, \
                                                      metadata_length=0, \
                                                      packet_offset=0, \
                                                      port_id=0, \
                                                      port_id_field=metadata_port)
    ins_apply_action = core.PofManager.new_ins_apply_actions([del_field_action, set_field_action, output_action])
    core.PofManager.add_flow_entry(dpid, table_id, [matchx_ttl1, match_fork1], [ins_apply_action], 0, False)

    #3.
    matchx_ttl1 = core.PofManager.new_matchx(match_ttl, '01', '00')
    match_fork1 = core.PofManager.new_matchx(match_fork, '8', '8')
    ins_decrease_ttl = core.PofManager.new_ins_calculate_field(pof.OFPCT_SUBTRACT, 0, \
                                                               match_ttl, 1)
    del_field_action = core.PofManager.new_action_delete_field(field_position=PORT_FIELD_OFFSET, \
                                                               length_value_type=0, \
                                                               length_value=PORT_FIELD_LEN, \
                                                               )

    ins_apply_action = core.PofManager.new_ins_apply_actions([del_field_action])
    next_table_id = core.PofManager.get_flow_table_id(dpid, 'GroupMatchTable')
    ins_go_to_table = core.PofManager.new_ins_goto_table(dpid, next_table_id)
    core.PofManager.add_flow_entry(dpid, table_id, [matchx_ttl1, match_fork1], [ins_decrease_ttl, ins_apply_action, ins_go_to_table],0, False)

    # 4.
    matchx_ttl1 = core.PofManager.new_matchx(match_ttl, '01', '00')
    match_fork1 = core.PofManager.new_matchx(match_fork, '0', '8')
    ins_decrease_ttl = core.PofManager.new_ins_calculate_field(pof.OFPCT_SUBTRACT, 0, \
                                                               match_ttl, 1)
    del_field_action = core.PofManager.new_action_delete_field(field_position=PORT_FIELD_OFFSET, \
                                                               length_value_type=0, \
                                                               length_value=PORT_FIELD_LEN, \
                                                               )
    metadata_port = pof.ofp_match20(field_id=-1, offset=32, length=32)
    output_action = core.PofManager.new_action_output(port_id_value_type=1, \
                                                      metadata_offset=0, \
                                                      metadata_length=0, \
                                                      packet_offset=0, \
                                                      port_id=0, \
                                                      port_id_field=metadata_port)
    ins_apply_action = core.PofManager.new_ins_apply_actions([del_field_action, output_action])
    core.PofManager.add_flow_entry(dpid, table_id, [matchx_ttl1, match_fork1], [ins_decrease_ttl, ins_apply_action], 0, False)
Exemple #23
0
    def _handle_ConnectionUp(self, event):
        # add_flow_table(self, switch_id, table_name, table_type, table_size, match_field_list = [])
        core.PofManager.add_flow_table(event.dpid, 'FirstEntryTable', pof.OF_MM_TABLE, 128, \
                                       [core.PofManager.get_field('DL_TYPE')[0]])
        core.PofManager.add_flow_table(event.dpid, 'WritePortToMetadataTable', pof.OF_LINEAR_TABLE, 1)
        core.PofManager.add_flow_table(event.dpid, 'CheckTTL', pof.OF_MM_TABLE, 2, \
                                       [core.PofManager.get_field('TTL')[0]])
        core.PofManager.add_flow_table(event.dpid, 'OutputTable', pof.OF_LINEAR_TABLE, 1)
        core.PofManager.add_flow_table(event.dpid, 'SRHeaderEncapTable', pof.OF_MM_TABLE, 3000, \
                                       [core.PofManager.get_field('DIP')[0]])
        core.PofManager.add_flow_table(event.dpid, 'ARPTargetIPTable', pof.OF_MM_TABLE, 128, \
                                       [core.PofManager.get_field('TPA')[0]])

        # check port for protection
        core.PofManager.add_flow_table(event.dpid, 'CheckPortNumTable', pof.OF_MM_TABLE, 20, \
                                       [pof.ofp_match20(field_id=-1, offset=56, length=8)])

        time.sleep(1)  # error if not sleep, maybe send flowmod too fast.

        _install_srheader_encap_table(event.dpid)
        time.sleep(1)  # error if not sleep, maybe send flowmod too fast.

        _install_type_match_entry(event.dpid)
        if event.dpid != 3 :
            _install_ttl_match_entry(event.dpid, match_value='01', match_mask='FF', prior=900)
            _install_ttl_match_entry(event.dpid, match_value='01', match_mask='00')
            _install_write_port_to_metadata_entry(event.dpid)

            _install_output_entry(event.dpid)
        else :
            # _install_ttl_match_entry_protect(event.dpid, match_value='01', match_mask='00'  )
            _install_write_port_to_metadata_entry_protect(event.dpid)

        # install the source_routing_rule to the s1
        # if event.dpid == 1:
        #     matchx = core.PofManager.new_matchx(field=core.PofManager.get_field('DIP')[0],value='0a000002',mask='FFFFFFFF')
        #     encap_sr_header(1,output_port=2,matchx=matchx,port_list=[2,2,2,2])

        #     matchx = core.PofManager.new_matchx(field=core.PofManager.get_field('DIP')[0], value='0a000003',
        #                                         mask='FFFFFFFF')
        #     encap_sr_header(1, output_port=2, matchx=matchx, port_list=[2, 2, 2, 3])

        #     matchx = core.PofManager.new_matchx(field=core.PofManager.get_field('DIP')[0], value='0a000004',
        #                                         mask='FFFFFFFF')
        #     encap_sr_header(1, output_port=2, matchx=matchx, port_list=[2, 2, 2, 4])

        #     matchx = core.PofManager.new_matchx(field=core.PofManager.get_field('DIP')[0], value='0a000005',
        #                                         mask='FFFFFFFF')
        #     encap_sr_header(1, output_port=2, matchx=matchx, port_list=[2, 2, 2, 5])

        #     matchx = core.PofManager.new_matchx(field=core.PofManager.get_field('DIP')[0], value='0a000006',
        #                                         mask='FFFFFFFF')
        #     encap_sr_header(1, output_port=2, matchx=matchx, port_list=[2, 2, 4])

        #     matchx = core.PofManager.new_matchx(field=core.PofManager.get_field('DIP')[0], value='0a000007',
        #                                         mask='FFFFFFFF')
        #     encap_sr_header(1, output_port=2, matchx=matchx, port_list=[2, 2, 5])

        #     matchx = core.PofManager.new_matchx(field=core.PofManager.get_field('DIP')[0], value='0a000008',
        #                                         mask='FFFFFFFF')
        #     encap_sr_header(1, output_port=2, matchx=matchx, port_list=[2, 2, 6])

        #     matchx = core.PofManager.new_matchx(field=core.PofManager.get_field('DIP')[0], value='0a000009',
        #                                         mask='FFFFFFFF')
        #     encap_sr_header(1, output_port=2, matchx=matchx, port_list=[2, 2, 3, 3])

        #     matchx = core.PofManager.new_matchx(field=core.PofManager.get_field('DIP')[0], value='0a00000a',
        #                                     mask='FFFFFFFF')
        #     encap_sr_header(1, output_port=2, matchx=matchx, port_list=[2, 2, 3, 4])

        #     matchx = core.PofManager.new_matchx(field=core.PofManager.get_field('DIP')[0], value='0a00000b',
        #                                         mask='FFFFFFFF')
        #     encap_sr_header(1, output_port=2, matchx=matchx, port_list=[2, 2, 3, 5])
        # if event.dpid == 5:
        #     matchx = core.PofManager.new_matchx(field=core.PofManager.get_field('DIP')[0],value='0a000001',mask='FFFFFFFF')
        #     encap_sr_header(5, output_port=1, matchx=matchx, port_list=[1,1,1,2])

        backup_port_list = [2, 1]

        if event.dpid == 3:
            install_match_port_entry(event.dpid, "02", backup_port_list)
            _group_mod(event.dpid, 0x2, 0x3, 2)