ryu rest router

https://osrg.github.io/ryu-book/en/html/rest_router.html

 https://zoo.cs.yale.edu/classes/cs434/cs434-2017-spring/lectures/02-prognet-openflow.pdf

Go to file
方法一: 您可以在xterm窗口中运行shell命令和脚本。 enter image description here

方法二: 您可以直接在mininet控制台上运行。

mininet> h1 bash script.sh
Write sth on h1
mininet>
script.sh包含简单的echo命令。

 

 
 
 
 
[root@kunpeng82 devuser]#  curl -X POST -d '{"address": "172.16.10.1/24"}' http://localhost:8080/router/0000000000000001/2
{"result": "failure", "details": "Router SW is not connected. : switch_id=0000000000000001"}
[root@kunpeng82 devuser]# 

 

 

 

[root@kunpeng82 devuser]# curl http://localhost:8080/router/0000000000000001
curl: (7) Failed connect to localhost:8080; Connection refused
[root@kunpeng82 devuser]# ryu-manager ryu.app.rest_router
loading app ryu.app.rest_router
loading app ryu.controller.ofp_handler
instantiating app None of DPSet
creating context dpset
creating context wsgi
instantiating app ryu.app.rest_router of RestRouterAPI
instantiating app ryu.controller.ofp_handler of OFPHandler
(26654) wsgi starting up on http://0.0.0.0:8080
(26654) accepted ('127.0.0.1', 45350)
127.0.0.1 - - [11/Jul/2020 14:54:39] "POST /router/0000000000000001/2 HTTP/1.1" 404 215 0.004427
(26654) accepted ('127.0.0.1', 45354)
127.0.0.1 - - [11/Jul/2020 14:56:21] "POST /router/0000000000000001/2 HTTP/1.1" 404 215 0.000506

 

[root@kunpeng82 devuser]# mn --topo linear,3,2 --mac --switch ovsk --controller remote -x
*** Creating network
*** Adding controller
Unable to contact the remote controller at 127.0.0.1:6653
Unable to contact the remote controller at 127.0.0.1:6633
Setting remote controller to 127.0.0.1:6653
*** Adding hosts:
h1s1 h1s2 h1s3 h2s1 h2s2 h2s3 
*** Adding switches:
s1 s2 s3 
*** Adding links:
(h1s1, s1) (h1s2, s2) (h1s3, s3) (h2s1, s1) (h2s2, s2) (h2s3, s3) (s2, s1) (s3, s2) 
*** Configuring hosts
h1s1 h1s2 h1s3 h2s1 h2s2 h2s3 
Error starting terms: Cannot connect to display
*** Starting controller
c0 
*** Starting 3 switches
s1 s2 s3 ...
*** Starting CLI:
mininet> 

 

mininet> ip a show  h1s1-eth0
*** Unknown command: ip a show  h1s1-eth0
mininet> ip addr del 10.0.0.1/8 dev h1s1-eth0
*** Unknown command: ip addr del 10.0.0.1/8 dev h1s1-eth0
mininet> xterm c0
Error: Cannot connect to display
mininet> dump
<Host h1s1: h1s1-eth0:10.0.0.1 pid=63595> 
<Host h1s2: h1s2-eth0:10.0.0.2 pid=63598> 
<Host h1s3: h1s3-eth0:10.0.0.3 pid=63600> 
<Host h2s1: h2s1-eth0:10.0.0.4 pid=63602> 
<Host h2s2: h2s2-eth0:10.0.0.5 pid=63604> 
<Host h2s3: h2s3-eth0:10.0.0.6 pid=63606> 
<OVSSwitch s1: lo:127.0.0.1,s1-eth1:None,s1-eth2:None,s1-eth3:None pid=63611> 
<OVSSwitch s2: lo:127.0.0.1,s2-eth1:None,s2-eth2:None,s2-eth3:None,s2-eth4:None pid=63614> 
<OVSSwitch s3: lo:127.0.0.1,s3-eth1:None,s3-eth2:None,s3-eth3:None pid=63618> 
<RemoteController c0: 127.0.0.1:6653 pid=63587> 
mininet> 

 

mininet> h1s1 ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: h1s1-eth0@if294: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
    link/ether 00:00:00:00:00:01 brd ff:ff:ff:ff:ff:ff link-netnsid 0
    inet 10.0.0.1/8 brd 10.255.255.255 scope global h1s1-eth0
       valid_lft forever preferred_lft forever
    inet6 fe80::200:ff:fe00:1/64 scope link 
       valid_lft forever preferred_lft forever
mininet>
mininet> xterm h1s1
Error: Cannot connect to display
mininet> h1s1  ip addr del 10.0.0.1/8 dev h1s1-eth0
mininet> h1s1 ip link add link h1s1-eth0 name h1s1-eth0.2 type vlan id 2
mininet> h1s1 ip addr add 172.16.10.10/24 dev h1s1-eth0.2
mininet> h1s1 ip link set dev h1s1-eth0.2 up
mininet>

 

mininet> h2s1 bash ~/h2s1.sh
mininet> h2s1  ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: h2s1-eth0@if297: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
    link/ether 00:00:00:00:00:04 brd ff:ff:ff:ff:ff:ff link-netnsid 0
    inet6 fe80::200:ff:fe00:4/64 scope link 
       valid_lft forever preferred_lft forever
3: h2s1-eth0.110@h2s1-eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
    link/ether 00:00:00:00:00:04 brd ff:ff:ff:ff:ff:ff
    inet 172.16.10.11/24 scope global h2s1-eth0.110
       valid_lft forever preferred_lft forever
    inet6 fe80::200:ff:fe00:4/64 scope link 
       valid_lft forever preferred_lft forever
mininet> 
[root@kunpeng82 ~]# ls h*
h1s2.sh  h1s3.sh  h2s1.sh  h2s2.sh  h2s3.sh
[root@kunpeng82 ~]# 

  

mininet> h2s2 bash ~/h2s2.sh
mininet> h1s3 bash ~/h1s3.sh
mininet> h2s3 bash ~/h2s3.sh
mininet> dump
<Host h1s1: h1s1-eth0:10.0.0.1 pid=63595> 
<Host h1s2: h1s2-eth0:10.0.0.2 pid=63598> 
<Host h1s3: h1s3-eth0:10.0.0.3 pid=63600> 
<Host h2s1: h2s1-eth0:10.0.0.4 pid=63602> 
<Host h2s2: h2s2-eth0:10.0.0.5 pid=63604> 
<Host h2s3: h2s3-eth0:10.0.0.6 pid=63606> 
<OVSSwitch s1: lo:127.0.0.1,s1-eth1:None,s1-eth2:None,s1-eth3:None pid=63611> 
<OVSSwitch s2: lo:127.0.0.1,s2-eth1:None,s2-eth2:None,s2-eth3:None,s2-eth4:None pid=63614> 
<OVSSwitch s3: lo:127.0.0.1,s3-eth1:None,s3-eth2:None,s3-eth3:None pid=63618> 
<RemoteController c0: 127.0.0.1:6653 pid=63587> 
mininet> 

 

posted on 2020-07-11 22:58  tycoon3  阅读(413)  评论(0编辑  收藏  举报

导航