本次實驗是基於OVS的VLAN虛擬化簡易實踐方案的進一步的實驗,採用RYU restful api進行配置。本質上和上次實驗沒什麼差,究其緣由仍是由於上次不能較好使用RYU的restful api,如今學會了就實踐一把吧。html
工具api
以前的實驗步驟不在贅述,主要是用RYU的restful api下發push_vlanrestful
ACTIONcookie
Actions | Description | Example |
---|---|---|
OUTPUT | Output packet from "port" | {"type": "OUTPUT", "port": 3} |
COPY_TTL_OUT | Copy TTL outwards | {"type": "COPY_TTL_OUT"} |
COPY_TTL_IN | Copy TTL inwards | {"type": "COPY_TTL_IN"} |
SET_MPLS_TTL | Set MPLS TTL using "mpls_ttl" | {"type": "SET_MPLS_TTL", "mpls_ttl": 64} |
DEC_MPLS_TTL | Decrement MPLS TTL | {"type": "DEC_MPLS_TTL"} |
PUSH_VLAN | Push a new VLAN tag with "ethertype" | {"type": "PUSH_VLAN", "ethertype": 33024} |
POP_VLAN | Pop the outer VLAN tag | {"type": "POP_VLAN"} |
PUSH_MPLS | Push a new MPLS tag with "ethertype" | {"type": "PUSH_MPLS", "ethertype": 34887} |
POP_MPLS | Pop the outer MPLS tag with "ethertype" | {"type": "POP_MPLS", "ethertype": 2054} |
SET_QUEUE | Set queue id using "queue_id" when outputting to a port | {"type": "SET_QUEUE", "queue_id": 7} |
GROUP | Apply group identified by "group_id" | {"type": "GROUP", "group_id": 5} |
SET_NW_TTL | Set IP TTL using "nw_ttl" | {"type": "SET_NW_TTL", "nw_ttl": 64} |
DEC_NW_TTL | Decrement IP TTL | {"type": "DEC_NW_TTL"} |
SET_FIELD | Set a "field" using "value"(The set of keywords available for "field" is the same as match field) | See Example of set-field action |
PUSH_PBB | Push a new PBB service tag with "ethertype"(Openflow1.3+) | {"type": "PUSH_PBB", "ethertype": 35047} |
POP_PBB | Pop the outer PBB service tag(Openflow1.3+) | {"type": "POP_PBB"} |
COPY_FIELD | Copy value between header and register(Openflow1.5+) | {"type": "COPY_FIELD", "n_bits": 32, "src_offset": 1, "dst_offset": 2, "src_oxm_id": "eth_src", "dst_oxm_id": "eth_dst"} |
METER | Apply meter identified by "meter_id"(Openflow1.5+) | {"type": "METER", "meter_id": 3} |
EXPERIMENTER | Extensible action for the experimenter(Set "base64" or "ascii" to "data_type" field) | {"type": "EXPERIMENTER", "experimenter": 101, "data": "AAECAwQFBgc=", "data_type": "base64"} |
GOTO_TABLE | (Instruction) Setup the next table identified by "table_id" | {"type": "GOTO_TABLE", "table_id": 8} |
WRITE_METADATA | (Instruction) Setup the metadata field using "metadata" and "metadata_mask" | {"type": "WRITE_METADATA", "metadata": 0x3, "metadata_mask": 0x3} |
METER | (Instruction) Apply meter identified by "meter_id"(deprecated in Openflow1.5) | {"type": "METER", "meter_id": 3} |
WRITE_ACTIONS | (Instruction) Write the action(s) onto the datapath action set | {"type": "WRITE_ACTIONS", actions":[{"type":"POP_VLAN",},{ "type":"OUTPUT", "port": 2}]} |
CLEAR_ACTIONS | (Instruction) Clears all actions from the datapath action set |
Example of set-field actionapp
$ curl -X POST -d '{ "dpid": 1, "match":{ "dl_type": "0x8000" }, "actions":[ { "type": "PUSH_VLAN", # Push a new VLAN tag if a input frame is non-VLAN-tagged "ethertype": 33024 # Ethertype 0x8100(=33024): IEEE 802.1Q VLAN-tagged frame }, { "type": "SET_FIELD", "field": "vlan_vid", # Set VLAN ID "value": 4102 # Describe sum of vlan_id(e.g. 6) | OFPVID_PRESENT(0x1000=4096) }, { "type": "OUTPUT", "port": 2 } ] }' http://localhost:8080/stats/flowentry/add
postmancurl
ovside
sudo ovs-ofctl -O OpenFlow13 dump-flows s1
獲得結果工具
OFPST_FLOW reply (OF1.3) (xid=0x2): cookie=0x0, duration=2350.981s, table=0, n_packets=0, n_bytes=0, priority=1,in_port=1 actions=push_vlan:0x8100,set_field:4096->vlan_vid,output:2
能夠基於此寫自動化腳本,不過仍是有經過restful api層面,感受還不是太好。下面搞一個不經過restful api層面的下發過程。post