Security in CPS/Networking

[SDN] Ryu를 활용한 Southbound API

mjune.kim 2020. 6. 8. 14:02

우선 ryu-manager가 제공하는 sample 앱 중에서 ofctl_rest.py 이 있습니다. 이 앱에서는 rest API를 이용해 연결된 스위치들의 상태를 확인 할 수 있는데요. 스위치에 추가된 Flow entries 나 포트 상태등을 Remote로 확인이 가능합니다.

sudo ryu-manager --verbose ofctl_rest.py &
curl -X GET http://localhost:8080/stats/switches
curl -X GET http://localhost:8080/stats/port/{dpid}/{port}

우선 연결된 dpid 를 알아야 겠지요. Mininet과 같은 네트워크 에뮬레이터를 사용하고 있다면 dpid를 1, 2, 3 이렇게 쉽게 설정이 가능하지만 실제 하드웨어 스위치를 사용하다면 복잡한(?) id를 가지게 됩니다. 하지만 Southbound API 중 /switches를 호출해 dpid 를 쉽게 알수 있습니다. 

{"dpid": [{"tx_dropped": 0, "rx_packets": 0, "rx_crc_err": 0, "tx_bytes": 0, "rx_dropped": 0, "port_no": 23, "rx_over_err": 0, "rx_frame_err": 0, "rx_bytes": 0, "tx_errors": 0, "collisions": 0, "rx_errors": 0, "tx_packets": 0}]}

결과에 대한 자세한 설명은 아래 링크를 참고하면 됩니다.

buildmedia.readthedocs.org/media/pdf/ryu-docs/ofctl_rest/ryu-docs.pdf