- OpenDaylight Cookbook
- Mathieu Lemay Alexis de Talhou?t Jamie Goodyear Rashmi Pujar Mohamed El Serngawy Yrineu Rodrigues
- 599字
- 2021-07-02 21:38:40
How to do it...
Perform the following steps:
- Start your OpenDaylight distribution using the karaf script. Using this client will give you access to the Karaf CLI:
$ ./bin/karaf
- Install the user facing feature responsible for pulling in all dependencies needed to use the YANG UI:
opendaylight-user@root>feature:install odl-vpnservice-intent
It might take a minute or so to complete the installation.
- Create the topology in the Mininet-VM:
- Log in to Mininet-VM using these credentials:
- Username: mininet
- Password: mininet
- Create the custom topology.
The topology's script resides at the following location:
$ wget -O shortest_path.py https://gist.githubusercontent.com/adetalhouet/shortest_path.py
$ sudo mn --controller=remote,ip=${CONTROLLER_IP} --custom ~/shortest_path.py --topo shortest_path --switch ovsk,protocols=OpenFlow13
Here, ${CONTROLLER_IP} is the IP address of the host running OpenDaylight.
The topology looks like the following diagram, where openflow:1 and openflow:3 are the PE switches and openflow: 42/43/44 are the P switches. There are two disjoint routes between the PE switches:

- Create a VPN with the desired constraints (slow-reroute or fast-reroute). We will use slow-reroute in this example:
- Type: POST
- Headers:
Authorization: Basic YWRtaW46YWRtaW4=
- URL: http://localhost:8181/restconf/operations/vpnintent:vpns/
- Payload:
{
"vpn-intents": [
{
"vpn-name": "VPN #1"
"path-protection": "true",
"failover-type": "slow-reroute"
}
]
}
- Add the first member to our VPN:
- Type: POST
- Headers:
Authorization: Basic YWRtaW46YWRtaW4=
- URL: http://localhost:8181/restconf/operations/vpnintent:add-vpn-endpoint
- Payload:
{
"input": {
"vpn-name": "VPN #1",
"site-name": "site1",
"ip-prefix": "10.0.0.1/32",
"switch-port-id": "openflow:1:1"
}
}
- Add the second member to our VPN:
- Type: POST
- Headers:
Authorization: Basic YWRtaW46YWRtaW4=
- URL: http://localhost:8181/restconf/operations/vpnintent:add-vpn-endpoint
- Payload:
{
"input": {
"vpn-name": "VPN #1",
"site-name": "site2",
"ip-prefix": "10.0.0.3/32",
"switch-port-id": "openflow:3:1"
}
}
- Look at the current configuration in the OpenDaylight datastore:
- Type: GET
- Headers:
Authorization: Basic YWRtaW46YWRtaW4=
- URL: http://localhost:8181/restconf/config/vpnintent:vpns/
Result:
<vpns xmlns="urn:opendaylight:params:xml:ns:yang:vpnintent">
<vpn-intents>
<vpn-name>VPN #1</vpn-name>
<failover-type>fast-reroute</failover-type>
<path-protection>true</path-protection>
<endpoint>
<site-name>site1</site-name>
<ip-prefix>10.0.0.1/32</ip-prefix>
<switch-port-id>openflow:1:1</switch-port-id>
</endpoint>
<endpoint>
<site-name>site3</site-name>
<ip-prefix>10.0.0.3/32</ip-prefix>
<switch-port-id>openflow:3:1</switch-port-id>
</endpoint>
</vpn-intents>
</vpns>
- Look at the flows installed in the OvS instance:
mininet@mininet-vm:~$ sudo ovs-ofctl -O OpenFlow13 dump-flows s1
OFPST_FLOW reply (OF1.3) (xid=0x2):cookie=0x2, duration=96.839s, table=0, n_packets=0, n_bytes=0, priority=10000,arp actions=CONTROLLER:65535,NORMAL cookie=0x2, duration=96.827s, table=0, n_packets=20, n_bytes=1700, priority=9500,dl_type=0x88cc actions=CONTROLLER:65535 cookie=0x0, duration=7.739s, table=0, n_packets=0, n_bytes=0, priority=9000,ip,nw_src=10.0.0.1,nw_dst=10.0.0.3 actions=push_mpls:0x8847,set_field:494630->mpls_label,output:2 cookie=0x0, duration=7.724s, table=0, n_packets=0, n_bytes=0, priority=9000,mpls,mpls_label=337082,mpls_bos=1 actions=pop_mpls:0x0800,output:1
mininet@mininet-vm:~$ sudo ovs-ofctl -O OpenFlow13 dump-flows s2a
OFPST_FLOW reply (OF1.3) (xid=0x2):cookie=0x3, duration=95.968s, table=0, n_packets=0, n_bytes=0, priority=10000,arp actions=CONTROLLER:65535,NORMAL cookie=0x3, duration=89.545s, table=0, n_packets=37, n_bytes=3145, priority=9500,dl_type=0x88cc actions=CONTROLLER:65535 cookie=0x0, duration=7.747s, table=0, n_packets=0, n_bytes=0, priority=9000,mpls,mpls_label=494630,mpls_bos=1 actions=output:3 cookie=0x0, duration=7.736s, table=0, n_packets=0, n_bytes=0, priority=9000,mpls,mpls_label=337082,mpls_bos=1 actions=output:2
mininet@mininet-vm:~$ sudo ovs-ofctl -O OpenFlow13 dump-flows s3
OFPST_FLOW reply (OF1.3) (xid=0x2): cookie=0x1, duration=97.781s, table=0, n_packets=0, n_bytes=0, priority=10000,arp actions=CONTROLLER:65535,NORMAL cookie=0x1, duration=97.778s, table=0, n_packets=20, n_bytes=1700, priority=9500,dl_type=0x88cc actions=CONTROLLER:65535 cookie=0x0, duration=7.747s, table=0, n_packets=0, n_bytes=0, priority=9000,mpls,mpls_label=494630,mpls_bos=1 actions=pop_mpls:0x0800,output:1 cookie=0x0, duration=7.746s, table=0, n_packets=0, n_bytes=0, priority=9000,ip,nw_src=10.0.0.3,nw_dst=10.0.0.1 actions=push_mpls:0x8847,set_field:337082->mpls_label,output:2
The shortest path, s1-s2a-s3, is chosen.
- Let's test path failover by removing switch s2a:
mininet@mininet-vm:~$ sudo ovs-vsctl del-br s2a
mininet@mininet-vm:~$ sudo ovs-ofctl -O OpenFlow13 dump-flows s1
OFPST_FLOW reply (OF1.3) (xid=0x2):cookie=0x2, duration=96.839s, table=0, n_packets=0, n_bytes=0, priority=10000,arp actions=CONTROLLER:65535,NORMAL cookie=0x2, duration=96.827s, table=0, n_packets=20, n_bytes=1700, priority=9500,dl_type=0x88cc actions=CONTROLLER:65535 cookie=0x0, duration=7.739s, table=0, n_packets=0, n_bytes=0, priority=9000,ip,nw_src=10.0.0.1,nw_dst=10.0.0.3 actions=push_mpls:0x8847,set_field:494630->mpls_label,output:2 cookie=0x0, duration=7.724s, table=0, n_packets=0, n_bytes=0, priority=9000,mpls,mpls_label=337082,mpls_bos=1 actions=pop_mpls:0x0800,output:1
mininet@mininet-vm:~$ sudo ovs-ofctl -O OpenFlow13 dump-flows s2a
ovs-ofctl: s2a is not a bridge or a socket
mininet@mininet-vm:~$ sudo ovs-ofctl -O OpenFlow13 dump-flows s2b
OFPST_FLOW reply (OF1.3) (xid=0x2):cookie=0x3, duration=95.968s, table=0, n_packets=0, n_bytes=0, priority=10000,arp actions=CONTROLLER:65535,NORMAL cookie=0x3, duration=89.545s, table=0, n_packets=37, n_bytes=3145, priority=9500,dl_type=0x88cc actions=CONTROLLER:65535 cookie=0x0, duration=7.747s, table=0, n_packets=0, n_bytes=0, priority=9000,mpls,mpls_label=494630,mpls_bos=1 actions=output:3 cookie=0x0, duration=7.736s, table=0, n_packets=0, n_bytes=0, priority=9000,mpls,mpls_label=337082,mpls_bos=1 actions=output:2
mininet@mininet-vm:~$ sudo ovs-ofctl -O OpenFlow13 dump-flows s2c
OFPST_FLOW reply (OF1.3) (xid=0x2):cookie=0x3, duration=95.968s, table=0, n_packets=0, n_bytes=0, priority=10000,arp actions=CONTROLLER:65535,NORMAL cookie=0x3, duration=89.545s, table=0, n_packets=37, n_bytes=3145, priority=9500,dl_type=0x88cc actions=CONTROLLER:65535 cookie=0x0, duration=7.747s, table=0, n_packets=0, n_bytes=0, priority=9000,mpls,mpls_label=494630,mpls_bos=1 actions=output:3 cookie=0x0, duration=7.736s, table=0, n_packets=0, n_bytes=0, priority=9000,mpls,mpls_label=337082,mpls_bos=1 actions=output:2
mininet@mininet-vm:~$ sudo ovs-ofctl -O OpenFlow13 dump-flows s3
OFPST_FLOW reply (OF1.3) (xid=0x2): cookie=0x1, duration=97.781s, table=0, n_packets=0, n_bytes=0, priority=10000,arp actions=CONTROLLER:65535,NORMAL cookie=0x1, duration=97.778s, table=0, n_packets=20, n_bytes=1700, priority=9500,dl_type=0x88cc actions=CONTROLLER:65535 cookie=0x0, duration=7.747s, table=0, n_packets=0, n_bytes=0, priority=9000,mpls,mpls_label=494630,mpls_bos=1 actions=pop_mpls:0x0800,output:1 cookie=0x0, duration=7.746s, table=0, n_packets=0, n_bytes=0, priority=9000,ip,nw_src=10.0.0.3,nw_dst=10.0.0.1 actions=push_mpls:0x8847,set_field:337082->mpls_label,output:2
The forward flows are now pushed to switches s2b and s2c.
推薦閱讀
- Oracle Exadata性能優化
- C語言程序設計實訓教程
- Mastering Ext JS
- C程序設計實踐教程
- App Inventor創意趣味編程進階
- 大話Java:程序設計從入門到精通
- Illustrator CS6設計與應用任務教程
- Getting Started with Electronic Projects
- Mastering Leap Motion
- 金融商業數據分析:基于Python和SAS
- 城市信息模型平臺頂層設計與實踐
- Improving your Penetration Testing Skills
- Isomorphic JavaScript Web Development
- Implementing NetScaler VPX?(Second Edition)
- JavaScript重難點實例精講