示例#1
0
文件: demo8.py 项目: Elbrys/pydevodl
        ctrlPortNum = d['ctrlPortNum']
        ctrlUname = d['ctrlUname']
        ctrlPswd = d['ctrlPswd']
        nodeName = d['nodeName']
    except:
        print ("Failed to get Controller device attributes")
        exit(0)

    print ("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<")
    print ("<<< Demo Start")
    print ("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<")

    rundelay = 5

    ctrl = Controller(ctrlIpAddr, ctrlPortNum, ctrlUname, ctrlPswd)
    ofswitch = OFSwitch(ctrl, nodeName)

    # --- Flow Match: Ethernet Source Address
    #                 Ethernet Destination Address
    #                 IPv4 Source Address
    #                 IPv4 Destination Address
    #                 IP Protocol Number
    #                 IP DSCP
    #                 Input Port
    #     NOTE: Ethernet type MUST be 2048 (0x800) -> IPv4 protocol
    eth_type = ETH_TYPE_IPv4
    eth_src = "00:1c:01:00:23:aa"
    eth_dst = "00:02:02:60:ff:fe"
    ipv4_src = "10.0.245.1/24"
    ipv4_dst = "192.168.1.123/16"
    ip_proto = IP_PROTO_TLSP
示例#2
0
        ctrlPortNum = d['ctrlPortNum']
        ctrlUname = d['ctrlUname']
        ctrlPswd = d['ctrlPswd']
        nodeName = d['nodeName']
    except:
        print("Failed to get Controller device attributes")
        exit(0)

    print("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<")
    print("<<< Demo Start")
    print("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<")

    rundelay = 5

    ctrl = Controller(ctrlIpAddr, ctrlPortNum, ctrlUname, ctrlPswd)
    ofswitch = OFSwitch(ctrl, nodeName)

    # --- Flow Match: Ethernet Type
    #                 Input Port
    #                 IPv4 Destination Address
    eth_type = ETH_TYPE_MPLS_UCAST
    in_port = 13
    mpls_label = 27

    # --- Flow Actions: Set Field
    #                   Output
    new_mpls_label = 44
    output_port = 14

    print("<<< 'Controller': %s, 'OpenFlow' switch: '%s'" %
          (ctrlIpAddr, nodeName))
示例#3
0
文件: demo31.py 项目: Elbrys/pydevodl
        ctrlPswd = d['ctrlPswd']
        nodeName = d['nodeName']
    except:
        print ("Failed to get Controller device attributes")
        exit(0)

    rundelay = 5

    print ("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<")
    print ("<<< Demo Start")
    print ("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<")

    rundelay = 5

    ctrl = Controller(ctrlIpAddr, ctrlPortNum, ctrlUname, ctrlPswd)
    ofswitch = OFSwitch(ctrl, nodeName)

    print ("<<< 'Controller': %s, 'OpenFlow' switch: '%s'" %
           (ctrlIpAddr, nodeName))

    first_flow_id = 110
    # ---------------------------------------------------
    # First flow entry
    # ---------------------------------------------------
    table_id = 0
    flow_id = first_flow_id
    flow_name = "Set IPv4 ToS action"
    priority = 600
    cookie = 1000

    match_in_port = 109
示例#4
0
 except:
     print ("Failed to get Controller device attributes")
     exit(0)
 
 openflow_node_ids = []
 openflow_nodes = []
 
 print ("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<")
 print ("<<< Demo Start")
 print ("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<")
 
 rundelay = 3
 
 
 ctrl = Controller(ctrlIpAddr, ctrlPortNum, ctrlUname, ctrlPswd)
 ofswitch = OFSwitch(ctrl, nodeName)
 
 print "\n".strip()
 print ("<<< 'Controller': %s, 'OpenFlow' switch: '%s'" % (ctrlIpAddr,
                                                           nodeName))
 
 grp_ids_cfg = []
 grp_ids_oper = []
 
 print "\n".strip()
 print ("<<< Get OpenFlow Groups Information")
 time.sleep(rundelay)
 
 result = ofswitch.get_configured_group_ids()
 status = result.get_status()
 if(status.eq(STATUS.OK)):
示例#5
0
        ctrlPortNum = d['ctrlPortNum']
        ctrlUname = d['ctrlUname']
        ctrlPswd = d['ctrlPswd']
        nodeName = d['nodeName']
    except:
        print("Failed to get Controller device attributes")
        exit(0)

    print("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<")
    print("<<< Demo Start")
    print("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<")

    rundelay = 5

    ctrl = Controller(ctrlIpAddr, ctrlPortNum, ctrlUname, ctrlPswd)
    ofswitch = OFSwitch(ctrl, nodeName)

    print("<<< 'Controller': %s, 'OpenFlow' switch: '%s'" %
          (ctrlIpAddr, nodeName))

    flow_table_id = 0
    flow_id_base = 12
    flow_id = flow_id_base
    flowEntries = []

    # Sample flow entry
    flow_entry = FlowEntry()
    flow_entry.set_flow_cookie(6001)
    flow_entry.set_flow_table_id(flow_table_id)
    flow_entry.set_flow_id(flow_id)
    flow_id += 1
示例#6
0
    print ("<<< Demo Start")
    print ("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<")

    rundelay = 5

    print ("\n")
    print ("<<< Creating Controller instance")
    time.sleep(rundelay)
    ctrl = Controller(ctrlIpAddr, ctrlPortNum, ctrlUname, ctrlPswd, None)
    print ("'Controller':")
    print ctrl.brief_json()

    print ("\n")
    print ("<<< Get information about OpenFlow node '%s'" % nodeName)
    time.sleep(rundelay)
    ofswitch = OFSwitch(ctrl, nodeName)
    result = ofswitch.get_switch_info()
    status = result.get_status()
    if status.eq(STATUS.OK) == True:
        print ("Node '%s' generic info:" % nodeName)
        info = result.get_data()
        print json.dumps(info, indent=4)
    else:
        print ("\n")
        print ("!!!Demo terminated, reason: %s" % status.brief().lower())
        exit(0)

    print ("\n")
    result = ofswitch.get_features_info()
    status = result.get_status()
    if status.eq(STATUS.OK) == True:
示例#7
0
    result = ctrl.get_openflow_nodes_operational_list()
    status = result.get_status()
    if (status.eq(STATUS.OK) == True):
        print("OpenFlow node names (composed as \"openflow:datapathid\"):")
        nodenames = result.get_data()
        print json.dumps(nodenames, indent=4)
    else:
        print("\n")
        print("!!!Demo terminated, reason: %s" % status.brief().lower())
        exit(0)

    print "\n"
    print("<<< Get generic information about OpenFlow nodes")
    time.sleep(rundelay)
    for name in nodenames:
        ofswitch = OFSwitch(ctrl, name)
        result = ofswitch.get_switch_info()
        status = result.get_status()
        if (status.eq(STATUS.OK) == True):
            print("'%s' info:" % name)
            info = result.get_data()
            print json.dumps(info, indent=4)
        else:
            print("\n")
            print("!!!Demo terminated, reason: %s" % status.brief().lower())
            exit(0)

    print("\n")
    print(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>")
    print(">>> Demo End")
    print(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>")
示例#8
0
文件: demo36.py 项目: Elbrys/pydevodl
        ctrlPortNum = d['ctrlPortNum']
        ctrlUname = d['ctrlUname']
        ctrlPswd = d['ctrlPswd']
        nodeName = d['nodeName']
    except:
        print ("Failed to get Controller device attributes")
        exit(0)

    print ("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<")
    print ("<<< Demo Start")
    print ("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<")

    rundelay = 3

    ctrl = Controller(ctrlIpAddr, ctrlPortNum, ctrlUname, ctrlPswd)
    ofswitch = OFSwitch(ctrl, nodeName)

    print "\n".strip()
    print ("<<< 'Controller': %s, 'OpenFlow' switch: '%s'" %
           (ctrlIpAddr, nodeName))

    grp_ids_cfg = []
    grp_ids_oper = []

    print "\n".strip()
    print ("<<< Get OpenFlow Groups Information")
    time.sleep(rundelay)

    result = ofswitch.get_configured_group_ids()
    status = result.get_status()
    if(status.eq(STATUS.OK)):
示例#9
0
 print ("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<")
 
 rundelay = 5
 
 print ("\n")
 print ("<<< Creating Controller instance")
 time.sleep(rundelay)
 ctrl = Controller(ctrlIpAddr, ctrlPortNum, ctrlUname, ctrlPswd, None)
 print ("'Controller':")
 print ctrl.brief_json()
 
 
 print ("\n")
 print ("<<< Get detailed information about ports on OpenFlow node '%s'" % nodeName)
 time.sleep(rundelay)
 ofswitch = OFSwitch(ctrl, nodeName)
 
 result = ofswitch.get_ports_list()
 status = result.get_status()
 if(status.eq(STATUS.OK) == True):
     ports = result.get_data()
     for port in ports:
         result = ofswitch.get_port_detail_info(port)
         status = result.get_status()
         if(status.eq(STATUS.OK) == True):
             print ("Port '%s' info:" % port)
             info = result.get_data()
             print json.dumps(info, indent=4)
         else:
             print ("\n")
             print ("!!!Demo terminated, reason: %s" % status.brief().lower())
示例#10
0
        nodeName = d['nodeName']
    except:
        print("Failed to get Controller device attributes")
        exit(0)

    openflow_node_ids = []
    openflow_nodes = []

    print("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<")
    print("<<< Demo Start")
    print("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<")

    rundelay = 3

    ctrl = Controller(ctrlIpAddr, ctrlPortNum, ctrlUname, ctrlPswd)
    ofswitch = OFSwitch(ctrl, nodeName)

    print "\n".strip()
    print("<<< 'Controller': %s, 'OpenFlow' switch: '%s'" %
          (ctrlIpAddr, nodeName))

    grp_ids_cfg = []
    grp_ids_oper = []

    print "\n".strip()
    print("<<< Get OpenFlow Groups Information")
    time.sleep(rundelay)

    result = ofswitch.get_configured_group_ids()
    status = result.get_status()
    if (status.eq(STATUS.OK)):
示例#11
0
     ctrlPswd = d['ctrlPswd']
     nodeName = d['nodeName']
 except:
     print ("Failed to get Controller device attributes")
     exit(0)
 
 rundelay = 5
 
 print ("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<")
 print ("<<< Demo Start")
 print ("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<")
 
 rundelay = 5
 
 ctrl = Controller(ctrlIpAddr, ctrlPortNum, ctrlUname, ctrlPswd)
 ofswitch = OFSwitch(ctrl, nodeName)
 
 print ("<<< 'Controller': %s, 'OpenFlow' switch: '%s'" % (ctrlIpAddr, nodeName))
 
 first_flow_id = 110
 # ---------------------------------------------------
 # First flow entry
 # ---------------------------------------------------
 table_id = 0
 flow_id = first_flow_id
 flow_name = "Set IPv4 ToS action"
 priority = 600
 cookie = 1000
 
 match_in_port = 109
 match_ip_eth_type = ETH_TYPE_IPv4
示例#12
0
 status = result.get_status()
 if(status.eq(STATUS.OK) == True):
     print ("OpenFlow node names (composed as \"openflow:datapathid\"):")
     nodenames = result.get_data()
     print json.dumps(nodenames, indent=4)
 else:
     print ("\n")
     print ("!!!Demo terminated, reason: %s" % status.brief().lower())
     exit(0)
 
 
 print "\n"
 print ("<<< Get generic information about OpenFlow nodes")
 time.sleep(rundelay)
 for name in nodenames:
     ofswitch = OFSwitch(ctrl, name)
     result = ofswitch.get_switch_info()
     status = result.get_status()
     if(status.eq(STATUS.OK) == True):
         print ("'%s' info:" % name)
         info = result.get_data()
         print json.dumps(info, indent=4)
     else:
         print ("\n")
         print ("!!!Demo terminated, reason: %s" % status.brief().lower())
         exit(0)
 
 
 print ("\n")
 print (">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>")
 print (">>> Demo End")
示例#13
0
    print("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<")

    rundelay = 5

    print("\n")
    print("<<< Creating Controller instance")
    time.sleep(rundelay)
    ctrl = Controller(ctrlIpAddr, ctrlPortNum, ctrlUname, ctrlPswd, None)
    print("'Controller':")
    print ctrl.brief_json()

    print("\n")
    print("<<< Get detailed information about ports on OpenFlow node '%s'" %
          nodeName)
    time.sleep(rundelay)
    ofswitch = OFSwitch(ctrl, nodeName)

    result = ofswitch.get_ports_list()
    status = result.get_status()
    if (status.eq(STATUS.OK) == True):
        ports = result.get_data()
        for port in ports:
            result = ofswitch.get_port_detail_info(port)
            status = result.get_status()
            if (status.eq(STATUS.OK) == True):
                print("Port '%s' info:" % port)
                info = result.get_data()
                print json.dumps(info, indent=4)
            else:
                print("\n")
                print("!!!Demo terminated, reason: %s" %
示例#14
0
     ctrlUname = d['ctrlUname']
     ctrlPswd = d['ctrlPswd']
     nodeName = d['nodeName']
 except:
     print ("Failed to get Controller device attributes")
     exit(0)
 
 
 print ("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<")
 print ("<<< Demo Start")
 print ("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<")
 
 rundelay = 5
 
 ctrl = Controller(ctrlIpAddr, ctrlPortNum, ctrlUname, ctrlPswd)
 ofswitch = OFSwitch(ctrl, nodeName)
 
 print ("<<< 'Controller': %s, 'OpenFlow' switch: '%s'" % (ctrlIpAddr, nodeName))
 
 
 flow_table_id = 0
 flow_id_base = 12
 flow_id = flow_id_base
 flowEntries = []
 
 # Sample flow entry
 flow_entry = FlowEntry()
 flow_entry.set_flow_cookie(6001)
 flow_entry.set_flow_table_id(flow_table_id)
 flow_entry.set_flow_id(flow_id)
 flow_id += 1
示例#15
0
     ctrlPortNum = d['ctrlPortNum']
     ctrlUname = d['ctrlUname']
     ctrlPswd = d['ctrlPswd']
     nodeName = d['nodeName']
 except:
     print ("Failed to get Controller device attributes")
     exit(0)
 
 print ("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<")
 print ("<<< Demo Start")
 print ("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<")
 
 rundelay = 5
 
 ctrl = Controller(ctrlIpAddr, ctrlPortNum, ctrlUname, ctrlPswd)
 ofswitch = OFSwitch(ctrl, nodeName)
 
 table_id = 0
 priority = 500
 cookie = 1000
 cookie_mask = 255
 customer_port = 110
 provider_port = 111
 qinq_eth_type = ETH_TYPE_STAG  # 802.1ad (QinQ) VLAN tagged frame
 dot1q_eth_type = ETH_TYPE_CTAG # 802.1q VLAN tagged frame
 arp_eth_type = ETH_TYPE_ARP
 ip_eth_type = ETH_TYPE_IPv4
 provider_vlan_id = 100 # Provider VLAN
 customer_vlan_id = 998 # Customer VLAN   
 first_flow_id = 31