SlideShare a Scribd company logo
1 of 13
Download to read offline
[Ryu_OpenFlow 1.3]
트래픽 모니터
김지은
yeswldms@gmail.com
Traffic Monitor
•  Ryu, Traffic Monitor
OpenFlow를 활용한 스위치의 통계정보 얻기
•  simple_monitor.py
https://github.com/osrg/ryu-book/blob/master/en/source/sources/
> ryu-book GitHub
simple_monitor.py
•  Download Sample Code
# wget https://github.com/osrg/ryu-book/blob/master/en/source/sources/simple_monitor.py
•  View the Code
# vi ./simple_monitor,py
from operator import attrgetter
from ryu.app import simple_switch_13
from ryu.controller import ofp_event
from ryu.controller.handler import MAIN_DISPATCHER, DEAD_DISPATCHER
from ryu.controller.handler import set_ev_cls
from ryu.lib import hub # eventlet wrapper, 기본 클래스
class SimpleMonitor(simple_switch_13.SimpleSwitch13):
def __init__(self, *args, **kwargs):
super(SimpleMonitor, self).__init__(*args, **kwargs)
self.datapaths = {}
self.monitor_thread = hub.spawn(self._monitor) # hub.spawn(), Thread(Eventlet Green Thread) 생성
# ... # _monitor : thread 함수
simple_monitor.py
•  View the Code
# vi ./simple_monitor,py
@set_ev_cls(ofp_event.EventOFPStateChange, # 스위치의 접속 및 접속끊김에 대한 EventOFPStateChange 이벤트
[MAIN_DISPATCHER, DEAD_DISPATCHER]) # datapath 가 바뀌면 Ryu 프레임웍에서 발행
def _state_change_handler(self, ev):
datapath = ev.datapath
if ev.state == MAIN_DISPATCHER: # 모니터링 대상으로 등록
if not datapath.id in self.datapaths:
self.logger.debug('register datapath: %016x', datapath.id)
self.datapaths[datapath.id] = datapath
elif ev.state == DEAD_DISPATCHER: # 모니터링 대상에서 제외
if datapath.id in self.datapaths:
self.logger.debug('unregister datapath: %016x', datapath.id)
del self.datapaths[datapath.id]
def _monitor(self):
while True:
for dp in self.datapaths.values(): # self.datapaths.values
self._request_stats(dp) # 상태정보 요청
hub.sleep(10) # 10초마다
def _request_stats(self, datapath): # 통계를 스위치에게 요청
self.logger.debug('send stats request: %016x', datapath.id)
ofproto = datapath.ofproto
parser = datapath.ofproto_parser
req = parser.OFPFlowStatsRequest(datapath) # flow 항목관련, 세부항목 설정 가능
datapath.send_msg(req)
req = parser.OFPPortStatsRequest(datapath, 0, ofproto.OFPP_ANY) # 포트 항목관련
datapath.send_msg(req)
simple_monitor.py
•  View the Code
# vi ./simple_monitor,py
@set_ev_cls(ofp_event.EventOFPFlowStatsReply, MAIN_DISPATCHER)
def _flow_stats_reply_handler(self, ev): # 스위치의 응답받는 이벤트핸들러, flow_stats_reply 수신
body = ev.msg.body # body, OFPFlowStatsReply의 속성
# OFPFlowStats 리스트에서 FlowStatsRequest의 대상이 된 각 플로우 항목의 통계정보 포함
self.logger.info('datapath '
'in-port eth-dst '
'out-port packets bytes')
self.logger.info('---------------- '
'-------- ----------------- '
'-------- -------- --------')
for stat in sorted([flow for flow in body if flow.priority == 1], # 우선순위가 0인, Table_miss항목을 제외하고
key=lambda flow: (flow.match['in_port'], # 수신포트와 Dst MAC을 가지고 정렬하여
flow.match['eth_dst'])): # 플로우 항목과 매치가되는
self.logger.info('%016x %8x %17s %8x %8d %8d', # 패킷과 바이트 출력
ev.msg.datapath.id,
stat.match['in_port'], stat.match['eth_dst'],
stat.instructions[0].actions[0].port,
stat.packet_count, stat.byte_count)
simple_monitor.py
•  View the Code
# vi ./simple_monitor,py
> 외부 프로그램과의 연동을 위한 JSON형태의 데이터를 제공
# 위의 코드로 얻어지는 JSON 데이터
import json
# ...
self.logger.info('%s', json.dumps(ev.msg.to_jsondict(), ensure_ascii=True,
indent=3, sort_keys=True))
{
"OFPFlowStatsReply": {
"body": [
{
"OFPFlowStats": {
"byte_count": 0,
"cookie": 0,
"duration_nsec": 680000000,
"duration_sec": 4,
"flags": 0,
"hard_timeout": 0,
"idle_timeout": 0,
"instructions": [
{
"OFPInstructionActions": {
"actions": [
{
"OFPActionOutput": {
"len": 16,
"max_len": 65535,
"port": 4294967293,
"type": 0
}
}
],
"len": 24,
"type": 4
}
}
],
"length": 80,
"match": {
"OFPMatch": {
"length": 4,
"oxm_fields": [],
"type": 1
}
},
"packet_count": 0,
"priority": 0,
"table_id": 0
}
},
{
"OFPFlowStats": {
"byte_count": 42,
"cookie": 0,
……
simple_monitor.py
•  View the Code
# vi ./simple_monitor,py
@set_ev_cls(ofp_event.EventOFPPortStatsReply, MAIN_DISPATCHER)
def _port_stats_reply_handler(self, ev): # 스위치의 응답받는 이벤트핸들러, port_stats_reply 수신
body = ev.msg.body # body, OFPPortStatsReply의 속성
self.logger.info('datapath port '
'rx-pkts rx-bytes rx-error '
'tx-pkts tx-bytes tx-error')
self.logger.info('---------------- -------- '
'-------- -------- -------- '
'-------- -------- --------')
for stat in sorted(body, key=attrgetter('port_no')):
self.logger.info('%016x %8x %8d %8d %8d %8d %8d %8d',
ev.msg.datapath.id, stat.port_no, #포트 번호별로 정렬
stat.rx_packets, stat.rx_bytes, stat.rx_errors, # 수신 패킷 개수, 수신된 바이트 수신 오류 개수,
stat.tx_packets, stat.tx_bytes, stat.tx_errors) # 전송 패킷 수, 송신 바이트 수, 전송 오류 개수 출력
Port 관련 통계정보
: 포트 번호, 송수신 각각의 패킷 수, 바이트 수, 드롭 개수, 오류 개수, 프레임 오류 개수, 오버런 개수, CRC 오류 개수, 충돌 개수 등 통계 정보
Ryubook Practice
•  이번엔,
Ryu응용 프로그램에서 Thread생성 방법
DataPath의 상태변화 확인
FlowStats 및 PortStats 수집 및 방법
•  호스트에서 Midinet 실행
# mn --topo single,3 --mac --switch ovsk --controller remote –x
•  스위치에서 OpenFlow 프로토콜 설정
# ovs-vsctl set Bridge s1 protocols=OpenFlow13
확인
# ovs-ofctl -O OpenFlow13 dump-flows s1
OFPST_FLOW reply (OF1.3) (xid=0x2):
#
TEST
•  트래픽 모니터 실행
Controller, c0:
# ryu-manager –verbose /usr/local/lib/python2.7/disk-package/tyu/simple_monitor.py
……
TEST
•  트래픽 모니터 실행
Table-miss(0)은 표시되지 않음으로 아무
내용도 없음
: 플로우 및 포트 정보 모두 없음
TEST
•  트래픽 모니터 실행
Host1에서 Host2로 ping 테스트
TEST
•  트래픽 모니터 실행
Host1에서 Host2로 ping 테스트 - 결과
이벤트 발생
패킷 전송 및 플로우 항목 등록, 통계정보 변경
[flow 항목 테이블]
수신포트1 : 1 packet, 42bytes
수신포트2 : 2 packets, 140bytes
[packet 항목 테이블]
포트1 : 3 packets, 182 bytes (rx)
포트2 : 3 packets, 182 bytes (rx)
1.  Host1에서 Boardcast로 ARP
2.  Host2에서 Host1로 ARP 응답
3.  Host1에서 Host2로 ICMP
Flow 항목과 Packet 항목이 다른이유?
: Port 항목 테이블의 경우 port로 유입되는 패
킷들에 대한 단순 카운트값이므로 flow 항목 테
이블과는 의미가 다름
이상입니다.
2015.05.09

More Related Content

What's hot

20150509 unix v6로 배우는 커널의 원리와 구조 3 김지은
20150509 unix v6로 배우는 커널의 원리와 구조 3 김지은20150509 unix v6로 배우는 커널의 원리와 구조 3 김지은
20150509 unix v6로 배우는 커널의 원리와 구조 3 김지은jieun kim
 
Airflow를 이용한 데이터 Workflow 관리
Airflow를 이용한  데이터 Workflow 관리Airflow를 이용한  데이터 Workflow 관리
Airflow를 이용한 데이터 Workflow 관리YoungHeon (Roy) Kim
 
도커없이컨테이너 만들기 8편 - pid namespace
도커없이컨테이너 만들기 8편 - pid namespace도커없이컨테이너 만들기 8편 - pid namespace
도커없이컨테이너 만들기 8편 - pid namespaceSam Kim
 
Openstack Instance Resize
Openstack Instance ResizeOpenstack Instance Resize
Openstack Instance Resizeymtech
 
Hyperledger fabric practice(pdf)
Hyperledger fabric practice(pdf)Hyperledger fabric practice(pdf)
Hyperledger fabric practice(pdf)wonyong hwang
 
rpm package 를 이용한 MySQL 설치자동화
rpm package 를 이용한 MySQL 설치자동화rpm package 를 이용한 MySQL 설치자동화
rpm package 를 이용한 MySQL 설치자동화I Goo Lee
 
[164] pinpoint
[164] pinpoint[164] pinpoint
[164] pinpointNAVER D2
 
20141029 하둡2.5와 hive설치 및 예제
20141029 하둡2.5와 hive설치 및 예제20141029 하둡2.5와 hive설치 및 예제
20141029 하둡2.5와 hive설치 및 예제Tae Young Lee
 
[2013 CodeEngn Conference 09] wh1ant - various tricks for linux remote exploits
[2013 CodeEngn Conference 09] wh1ant - various tricks for linux remote exploits[2013 CodeEngn Conference 09] wh1ant - various tricks for linux remote exploits
[2013 CodeEngn Conference 09] wh1ant - various tricks for linux remote exploitsGangSeok Lee
 
Python socket programming
Python socket programmingPython socket programming
Python socket programmingTae Young Lee
 
Welcome to keystone the open stack identity service_v1.0.0-20141208-1212
Welcome to keystone the open stack identity service_v1.0.0-20141208-1212Welcome to keystone the open stack identity service_v1.0.0-20141208-1212
Welcome to keystone the open stack identity service_v1.0.0-20141208-1212ymtech
 
[113]how can realm_make_efficient_mobile_database
[113]how can realm_make_efficient_mobile_database[113]how can realm_make_efficient_mobile_database
[113]how can realm_make_efficient_mobile_databaseNAVER D2
 
[MeetUp][2nd] 오리뎅이의_쿠버네티스_네트워킹_v1.2
[MeetUp][2nd] 오리뎅이의_쿠버네티스_네트워킹_v1.2[MeetUp][2nd] 오리뎅이의_쿠버네티스_네트워킹_v1.2
[MeetUp][2nd] 오리뎅이의_쿠버네티스_네트워킹_v1.2InfraEngineer
 
Ssh tunneling (1)
Ssh tunneling (1)Ssh tunneling (1)
Ssh tunneling (1)권택 오
 
Nginx basic configurations
Nginx basic configurationsNginx basic configurations
Nginx basic configurationsJohn Kim
 

What's hot (20)

20150509 unix v6로 배우는 커널의 원리와 구조 3 김지은
20150509 unix v6로 배우는 커널의 원리와 구조 3 김지은20150509 unix v6로 배우는 커널의 원리와 구조 3 김지은
20150509 unix v6로 배우는 커널의 원리와 구조 3 김지은
 
네트워크 기본
네트워크 기본네트워크 기본
네트워크 기본
 
Airflow를 이용한 데이터 Workflow 관리
Airflow를 이용한  데이터 Workflow 관리Airflow를 이용한  데이터 Workflow 관리
Airflow를 이용한 데이터 Workflow 관리
 
NLog 소개
NLog 소개NLog 소개
NLog 소개
 
도커없이컨테이너 만들기 8편 - pid namespace
도커없이컨테이너 만들기 8편 - pid namespace도커없이컨테이너 만들기 8편 - pid namespace
도커없이컨테이너 만들기 8편 - pid namespace
 
Openstack Instance Resize
Openstack Instance ResizeOpenstack Instance Resize
Openstack Instance Resize
 
Hyperledger fabric practice(pdf)
Hyperledger fabric practice(pdf)Hyperledger fabric practice(pdf)
Hyperledger fabric practice(pdf)
 
rpm package 를 이용한 MySQL 설치자동화
rpm package 를 이용한 MySQL 설치자동화rpm package 를 이용한 MySQL 설치자동화
rpm package 를 이용한 MySQL 설치자동화
 
[164] pinpoint
[164] pinpoint[164] pinpoint
[164] pinpoint
 
20141029 하둡2.5와 hive설치 및 예제
20141029 하둡2.5와 hive설치 및 예제20141029 하둡2.5와 hive설치 및 예제
20141029 하둡2.5와 hive설치 및 예제
 
[2013 CodeEngn Conference 09] wh1ant - various tricks for linux remote exploits
[2013 CodeEngn Conference 09] wh1ant - various tricks for linux remote exploits[2013 CodeEngn Conference 09] wh1ant - various tricks for linux remote exploits
[2013 CodeEngn Conference 09] wh1ant - various tricks for linux remote exploits
 
Python socket programming
Python socket programmingPython socket programming
Python socket programming
 
Welcome to keystone the open stack identity service_v1.0.0-20141208-1212
Welcome to keystone the open stack identity service_v1.0.0-20141208-1212Welcome to keystone the open stack identity service_v1.0.0-20141208-1212
Welcome to keystone the open stack identity service_v1.0.0-20141208-1212
 
Tcp summary
Tcp summaryTcp summary
Tcp summary
 
[113]how can realm_make_efficient_mobile_database
[113]how can realm_make_efficient_mobile_database[113]how can realm_make_efficient_mobile_database
[113]how can realm_make_efficient_mobile_database
 
[MeetUp][2nd] 오리뎅이의_쿠버네티스_네트워킹_v1.2
[MeetUp][2nd] 오리뎅이의_쿠버네티스_네트워킹_v1.2[MeetUp][2nd] 오리뎅이의_쿠버네티스_네트워킹_v1.2
[MeetUp][2nd] 오리뎅이의_쿠버네티스_네트워킹_v1.2
 
Ssh tunneling (1)
Ssh tunneling (1)Ssh tunneling (1)
Ssh tunneling (1)
 
Nginx basic configurations
Nginx basic configurationsNginx basic configurations
Nginx basic configurations
 
Nodejs_chapter3
Nodejs_chapter3Nodejs_chapter3
Nodejs_chapter3
 
Lam pstack
Lam pstackLam pstack
Lam pstack
 

Viewers also liked

Pgcon2012 ori-20120224
Pgcon2012 ori-20120224Pgcon2012 ori-20120224
Pgcon2012 ori-20120224Manabu Ori
 
Introduction to Software Defined Networking and OpenStack Neutron
Introduction to Software Defined Networking and OpenStack NeutronIntroduction to Software Defined Networking and OpenStack Neutron
Introduction to Software Defined Networking and OpenStack NeutronSana Khan
 
Openstack Neutron and SDN
Openstack Neutron and SDNOpenstack Neutron and SDN
Openstack Neutron and SDNinakipascual
 
Debugging Ruby
Debugging RubyDebugging Ruby
Debugging RubyAman Gupta
 
Debugging Ruby (Aman Gupta)
Debugging Ruby (Aman Gupta)Debugging Ruby (Aman Gupta)
Debugging Ruby (Aman Gupta)MongoSF
 
Rubinius @ RubyAndRails2010
Rubinius @ RubyAndRails2010Rubinius @ RubyAndRails2010
Rubinius @ RubyAndRails2010Dirkjan Bussink
 
Debugging Ruby Systems
Debugging Ruby SystemsDebugging Ruby Systems
Debugging Ruby SystemsEngine Yard
 
OpenSource Hardware -Debian Way
OpenSource Hardware -Debian WayOpenSource Hardware -Debian Way
OpenSource Hardware -Debian WaySiji Sunny
 
Operating OPNFV
Operating OPNFVOperating OPNFV
Operating OPNFVOPNFV
 
OpenStack@Mini-Deb Conf'16 Mumbai
OpenStack@Mini-Deb Conf'16 MumbaiOpenStack@Mini-Deb Conf'16 Mumbai
OpenStack@Mini-Deb Conf'16 MumbaiAkanksha Agrawal
 
Copr HD OpenStack Day India
Copr HD OpenStack Day IndiaCopr HD OpenStack Day India
Copr HD OpenStack Day Indiaopenstackindia
 
Your first patch to OpenStack
Your first patch to OpenStackYour first patch to OpenStack
Your first patch to OpenStackopenstackindia
 
Deploying openstack using ansible
Deploying openstack using ansibleDeploying openstack using ansible
Deploying openstack using ansibleopenstackindia
 
The OpenStack Contribution Workflow
The OpenStack Contribution WorkflowThe OpenStack Contribution Workflow
The OpenStack Contribution Workflowopenstackindia
 
Your first patch to open stack
Your first patch to open stackYour first patch to open stack
Your first patch to open stackAkanksha Agrawal
 
Guts & OpenStack migration
Guts & OpenStack migrationGuts & OpenStack migration
Guts & OpenStack migrationopenstackindia
 
OpenStack Storage Buddy Ceph
OpenStack Storage Buddy CephOpenStack Storage Buddy Ceph
OpenStack Storage Buddy Cephopenstackindia
 
Introduction to tempest
Introduction to tempest Introduction to tempest
Introduction to tempest openstackindia
 

Viewers also liked (20)

Pgcon2012 ori-20120224
Pgcon2012 ori-20120224Pgcon2012 ori-20120224
Pgcon2012 ori-20120224
 
Introduction to Software Defined Networking and OpenStack Neutron
Introduction to Software Defined Networking and OpenStack NeutronIntroduction to Software Defined Networking and OpenStack Neutron
Introduction to Software Defined Networking and OpenStack Neutron
 
Openstack Neutron and SDN
Openstack Neutron and SDNOpenstack Neutron and SDN
Openstack Neutron and SDN
 
Debugging Ruby
Debugging RubyDebugging Ruby
Debugging Ruby
 
Debugging Ruby (Aman Gupta)
Debugging Ruby (Aman Gupta)Debugging Ruby (Aman Gupta)
Debugging Ruby (Aman Gupta)
 
Rubinius @ RubyAndRails2010
Rubinius @ RubyAndRails2010Rubinius @ RubyAndRails2010
Rubinius @ RubyAndRails2010
 
Debugging Ruby Systems
Debugging Ruby SystemsDebugging Ruby Systems
Debugging Ruby Systems
 
OpenSource Hardware -Debian Way
OpenSource Hardware -Debian WayOpenSource Hardware -Debian Way
OpenSource Hardware -Debian Way
 
Operating OPNFV
Operating OPNFVOperating OPNFV
Operating OPNFV
 
OpenStack@Mini-Deb Conf'16 Mumbai
OpenStack@Mini-Deb Conf'16 MumbaiOpenStack@Mini-Deb Conf'16 Mumbai
OpenStack@Mini-Deb Conf'16 Mumbai
 
Copr HD OpenStack Day India
Copr HD OpenStack Day IndiaCopr HD OpenStack Day India
Copr HD OpenStack Day India
 
Your first patch to OpenStack
Your first patch to OpenStackYour first patch to OpenStack
Your first patch to OpenStack
 
Deploying openstack using ansible
Deploying openstack using ansibleDeploying openstack using ansible
Deploying openstack using ansible
 
The OpenStack Contribution Workflow
The OpenStack Contribution WorkflowThe OpenStack Contribution Workflow
The OpenStack Contribution Workflow
 
Your first patch to open stack
Your first patch to open stackYour first patch to open stack
Your first patch to open stack
 
Open stack qa and tempest
Open stack qa and tempestOpen stack qa and tempest
Open stack qa and tempest
 
Guts & OpenStack migration
Guts & OpenStack migrationGuts & OpenStack migration
Guts & OpenStack migration
 
OpenStack Storage Buddy Ceph
OpenStack Storage Buddy CephOpenStack Storage Buddy Ceph
OpenStack Storage Buddy Ceph
 
Introduction to tempest
Introduction to tempest Introduction to tempest
Introduction to tempest
 
OPNFV & OpenStack
OPNFV & OpenStackOPNFV & OpenStack
OPNFV & OpenStack
 

Similar to Ryu with OpenFlow 1.3, Traffic Monitor

[오픈소스컨설팅] 스카우터 사용자 가이드 2020
[오픈소스컨설팅] 스카우터 사용자 가이드 2020[오픈소스컨설팅] 스카우터 사용자 가이드 2020
[오픈소스컨설팅] 스카우터 사용자 가이드 2020Ji-Woong Choi
 
Prometheus Project Journey
Prometheus Project JourneyPrometheus Project Journey
Prometheus Project JourneyJinwoong Kim
 
컵드론 멀티콥터 펌웨어 분석 2015. 3.28.
컵드론 멀티콥터 펌웨어 분석 2015. 3.28.컵드론 멀티콥터 펌웨어 분석 2015. 3.28.
컵드론 멀티콥터 펌웨어 분석 2015. 3.28.chcbaram
 
도커(Docker) 메트릭스 & 로그 수집
도커(Docker) 메트릭스 & 로그 수집도커(Docker) 메트릭스 & 로그 수집
도커(Docker) 메트릭스 & 로그 수집Daegwon Kim
 
KGC 2016 오픈소스 네트워크 엔진 Super socket 사용하기
KGC 2016 오픈소스 네트워크 엔진 Super socket 사용하기KGC 2016 오픈소스 네트워크 엔진 Super socket 사용하기
KGC 2016 오픈소스 네트워크 엔진 Super socket 사용하기흥배 최
 
[2015-07-10-윤석준] Oracle 성능 관리 & v$sysstat
[2015-07-10-윤석준] Oracle 성능 관리 & v$sysstat[2015-07-10-윤석준] Oracle 성능 관리 & v$sysstat
[2015-07-10-윤석준] Oracle 성능 관리 & v$sysstatSeok-joon Yun
 
ARTIK 710 IoT class 02
ARTIK 710 IoT class 02ARTIK 710 IoT class 02
ARTIK 710 IoT class 02정출 김
 
Wire shark 사용법 및 네트워크 개론 살짝 설명
Wire shark 사용법 및 네트워크 개론 살짝 설명Wire shark 사용법 및 네트워크 개론 살짝 설명
Wire shark 사용법 및 네트워크 개론 살짝 설명진우 이
 
Nodejs, PhantomJS, casperJs, YSlow, expressjs
Nodejs, PhantomJS, casperJs, YSlow, expressjsNodejs, PhantomJS, casperJs, YSlow, expressjs
Nodejs, PhantomJS, casperJs, YSlow, expressjs기동 이
 
Hyperledger Fabric practice (v2.0)
Hyperledger Fabric practice (v2.0) Hyperledger Fabric practice (v2.0)
Hyperledger Fabric practice (v2.0) wonyong hwang
 
하이퍼레저 패브릭 데이터 구조
하이퍼레저 패브릭 데이터 구조하이퍼레저 패브릭 데이터 구조
하이퍼레저 패브릭 데이터 구조Logpresso
 
1908 Hyperledger Fabric 소개 및 첫 네트워크 구축하기
1908 Hyperledger Fabric 소개 및 첫 네트워크 구축하기1908 Hyperledger Fabric 소개 및 첫 네트워크 구축하기
1908 Hyperledger Fabric 소개 및 첫 네트워크 구축하기Hyperledger Korea User Group
 
Blockchain 4th dapp programming
Blockchain 4th dapp programmingBlockchain 4th dapp programming
Blockchain 4th dapp programmingihpark92
 
파이썬 데이터과학 레벨1 - 초보자를 위한 데이터분석, 데이터시각화 (2020년 이태영)
파이썬 데이터과학 레벨1 - 초보자를 위한 데이터분석, 데이터시각화 (2020년 이태영) 파이썬 데이터과학 레벨1 - 초보자를 위한 데이터분석, 데이터시각화 (2020년 이태영)
파이썬 데이터과학 레벨1 - 초보자를 위한 데이터분석, 데이터시각화 (2020년 이태영) Tae Young Lee
 
[오픈소스컨설팅]Nginx jboss 연동가이드__v1
[오픈소스컨설팅]Nginx jboss 연동가이드__v1[오픈소스컨설팅]Nginx jboss 연동가이드__v1
[오픈소스컨설팅]Nginx jboss 연동가이드__v1Ji-Woong Choi
 
Open vSwitch의 Vendor Extension 구현
Open vSwitch의 Vendor Extension 구현Open vSwitch의 Vendor Extension 구현
Open vSwitch의 Vendor Extension 구현Seung-Hoon Baek
 
톰캣 #10-모니터링
톰캣 #10-모니터링톰캣 #10-모니터링
톰캣 #10-모니터링GyuSeok Lee
 

Similar to Ryu with OpenFlow 1.3, Traffic Monitor (20)

Spring boot actuator
Spring boot   actuatorSpring boot   actuator
Spring boot actuator
 
[오픈소스컨설팅] 스카우터 사용자 가이드 2020
[오픈소스컨설팅] 스카우터 사용자 가이드 2020[오픈소스컨설팅] 스카우터 사용자 가이드 2020
[오픈소스컨설팅] 스카우터 사용자 가이드 2020
 
Prometheus Project Journey
Prometheus Project JourneyPrometheus Project Journey
Prometheus Project Journey
 
컵드론 멀티콥터 펌웨어 분석 2015. 3.28.
컵드론 멀티콥터 펌웨어 분석 2015. 3.28.컵드론 멀티콥터 펌웨어 분석 2015. 3.28.
컵드론 멀티콥터 펌웨어 분석 2015. 3.28.
 
도커(Docker) 메트릭스 & 로그 수집
도커(Docker) 메트릭스 & 로그 수집도커(Docker) 메트릭스 & 로그 수집
도커(Docker) 메트릭스 & 로그 수집
 
KGC 2016 오픈소스 네트워크 엔진 Super socket 사용하기
KGC 2016 오픈소스 네트워크 엔진 Super socket 사용하기KGC 2016 오픈소스 네트워크 엔진 Super socket 사용하기
KGC 2016 오픈소스 네트워크 엔진 Super socket 사용하기
 
[2015-07-10-윤석준] Oracle 성능 관리 & v$sysstat
[2015-07-10-윤석준] Oracle 성능 관리 & v$sysstat[2015-07-10-윤석준] Oracle 성능 관리 & v$sysstat
[2015-07-10-윤석준] Oracle 성능 관리 & v$sysstat
 
Kafka slideshare
Kafka   slideshareKafka   slideshare
Kafka slideshare
 
ARTIK 710 IoT class 02
ARTIK 710 IoT class 02ARTIK 710 IoT class 02
ARTIK 710 IoT class 02
 
Wire shark 사용법 및 네트워크 개론 살짝 설명
Wire shark 사용법 및 네트워크 개론 살짝 설명Wire shark 사용법 및 네트워크 개론 살짝 설명
Wire shark 사용법 및 네트워크 개론 살짝 설명
 
Nodejs, PhantomJS, casperJs, YSlow, expressjs
Nodejs, PhantomJS, casperJs, YSlow, expressjsNodejs, PhantomJS, casperJs, YSlow, expressjs
Nodejs, PhantomJS, casperJs, YSlow, expressjs
 
Hyperledger Fabric practice (v2.0)
Hyperledger Fabric practice (v2.0) Hyperledger Fabric practice (v2.0)
Hyperledger Fabric practice (v2.0)
 
하이퍼레저 패브릭 데이터 구조
하이퍼레저 패브릭 데이터 구조하이퍼레저 패브릭 데이터 구조
하이퍼레저 패브릭 데이터 구조
 
1908 Hyperledger Fabric 소개 및 첫 네트워크 구축하기
1908 Hyperledger Fabric 소개 및 첫 네트워크 구축하기1908 Hyperledger Fabric 소개 및 첫 네트워크 구축하기
1908 Hyperledger Fabric 소개 및 첫 네트워크 구축하기
 
KAFKA 3.1.0.pdf
KAFKA 3.1.0.pdfKAFKA 3.1.0.pdf
KAFKA 3.1.0.pdf
 
Blockchain 4th dapp programming
Blockchain 4th dapp programmingBlockchain 4th dapp programming
Blockchain 4th dapp programming
 
파이썬 데이터과학 레벨1 - 초보자를 위한 데이터분석, 데이터시각화 (2020년 이태영)
파이썬 데이터과학 레벨1 - 초보자를 위한 데이터분석, 데이터시각화 (2020년 이태영) 파이썬 데이터과학 레벨1 - 초보자를 위한 데이터분석, 데이터시각화 (2020년 이태영)
파이썬 데이터과학 레벨1 - 초보자를 위한 데이터분석, 데이터시각화 (2020년 이태영)
 
[오픈소스컨설팅]Nginx jboss 연동가이드__v1
[오픈소스컨설팅]Nginx jboss 연동가이드__v1[오픈소스컨설팅]Nginx jboss 연동가이드__v1
[오픈소스컨설팅]Nginx jboss 연동가이드__v1
 
Open vSwitch의 Vendor Extension 구현
Open vSwitch의 Vendor Extension 구현Open vSwitch의 Vendor Extension 구현
Open vSwitch의 Vendor Extension 구현
 
톰캣 #10-모니터링
톰캣 #10-모니터링톰캣 #10-모니터링
톰캣 #10-모니터링
 

More from jieun kim

KrDAG 오픈소스를 활용하여 웹블로그 만들기_김지은_201603
KrDAG 오픈소스를 활용하여 웹블로그 만들기_김지은_201603 KrDAG 오픈소스를 활용하여 웹블로그 만들기_김지은_201603
KrDAG 오픈소스를 활용하여 웹블로그 만들기_김지은_201603 jieun kim
 
OpenStack Korea 2015 상반기스터디(devops) 스크립트로 오픈스택 설치하기 20150728
OpenStack Korea 2015 상반기스터디(devops) 스크립트로 오픈스택 설치하기 20150728OpenStack Korea 2015 상반기스터디(devops) 스크립트로 오픈스택 설치하기 20150728
OpenStack Korea 2015 상반기스터디(devops) 스크립트로 오픈스택 설치하기 20150728jieun kim
 
150625 마이크로커널 운영체제 김지은
150625 마이크로커널 운영체제 김지은150625 마이크로커널 운영체제 김지은
150625 마이크로커널 운영체제 김지은jieun kim
 
150326 openstack, glance 김지은
150326 openstack, glance 김지은150326 openstack, glance 김지은
150326 openstack, glance 김지은jieun kim
 
집단지성프로그래밍 05. 최적화(kayak.ipynb) 김지은_20150522
집단지성프로그래밍 05. 최적화(kayak.ipynb) 김지은_20150522집단지성프로그래밍 05. 최적화(kayak.ipynb) 김지은_20150522
집단지성프로그래밍 05. 최적화(kayak.ipynb) 김지은_20150522jieun kim
 
집단지성프로그래밍 05. 최적화(optimization.ipynb) 김지은_20150522
집단지성프로그래밍 05. 최적화(optimization.ipynb) 김지은_20150522집단지성프로그래밍 05. 최적화(optimization.ipynb) 김지은_20150522
집단지성프로그래밍 05. 최적화(optimization.ipynb) 김지은_20150522jieun kim
 
집단지성프로그래밍 05. 최적화(optimization) 김지은_20150522
집단지성프로그래밍 05. 최적화(optimization) 김지은_20150522집단지성프로그래밍 05. 최적화(optimization) 김지은_20150522
집단지성프로그래밍 05. 최적화(optimization) 김지은_20150522jieun kim
 
20150509 unix v6로 배우는 커널의 원리와 구조 4 김지은
20150509 unix v6로 배우는 커널의 원리와 구조 4 김지은20150509 unix v6로 배우는 커널의 원리와 구조 4 김지은
20150509 unix v6로 배우는 커널의 원리와 구조 4 김지은jieun kim
 
Build the OpenStack Cloud with Neutron Networing, IceHouse
Build the OpenStack Cloud with Neutron Networing, IceHouseBuild the OpenStack Cloud with Neutron Networing, IceHouse
Build the OpenStack Cloud with Neutron Networing, IceHousejieun kim
 
20150502 unix v6로 배우는 커널의 원리와 구조 1 김지은
20150502 unix v6로 배우는 커널의 원리와 구조 1 김지은20150502 unix v6로 배우는 커널의 원리와 구조 1 김지은
20150502 unix v6로 배우는 커널의 원리와 구조 1 김지은jieun kim
 
resource on openstack
 resource on openstack resource on openstack
resource on openstackjieun kim
 

More from jieun kim (11)

KrDAG 오픈소스를 활용하여 웹블로그 만들기_김지은_201603
KrDAG 오픈소스를 활용하여 웹블로그 만들기_김지은_201603 KrDAG 오픈소스를 활용하여 웹블로그 만들기_김지은_201603
KrDAG 오픈소스를 활용하여 웹블로그 만들기_김지은_201603
 
OpenStack Korea 2015 상반기스터디(devops) 스크립트로 오픈스택 설치하기 20150728
OpenStack Korea 2015 상반기스터디(devops) 스크립트로 오픈스택 설치하기 20150728OpenStack Korea 2015 상반기스터디(devops) 스크립트로 오픈스택 설치하기 20150728
OpenStack Korea 2015 상반기스터디(devops) 스크립트로 오픈스택 설치하기 20150728
 
150625 마이크로커널 운영체제 김지은
150625 마이크로커널 운영체제 김지은150625 마이크로커널 운영체제 김지은
150625 마이크로커널 운영체제 김지은
 
150326 openstack, glance 김지은
150326 openstack, glance 김지은150326 openstack, glance 김지은
150326 openstack, glance 김지은
 
집단지성프로그래밍 05. 최적화(kayak.ipynb) 김지은_20150522
집단지성프로그래밍 05. 최적화(kayak.ipynb) 김지은_20150522집단지성프로그래밍 05. 최적화(kayak.ipynb) 김지은_20150522
집단지성프로그래밍 05. 최적화(kayak.ipynb) 김지은_20150522
 
집단지성프로그래밍 05. 최적화(optimization.ipynb) 김지은_20150522
집단지성프로그래밍 05. 최적화(optimization.ipynb) 김지은_20150522집단지성프로그래밍 05. 최적화(optimization.ipynb) 김지은_20150522
집단지성프로그래밍 05. 최적화(optimization.ipynb) 김지은_20150522
 
집단지성프로그래밍 05. 최적화(optimization) 김지은_20150522
집단지성프로그래밍 05. 최적화(optimization) 김지은_20150522집단지성프로그래밍 05. 최적화(optimization) 김지은_20150522
집단지성프로그래밍 05. 최적화(optimization) 김지은_20150522
 
20150509 unix v6로 배우는 커널의 원리와 구조 4 김지은
20150509 unix v6로 배우는 커널의 원리와 구조 4 김지은20150509 unix v6로 배우는 커널의 원리와 구조 4 김지은
20150509 unix v6로 배우는 커널의 원리와 구조 4 김지은
 
Build the OpenStack Cloud with Neutron Networing, IceHouse
Build the OpenStack Cloud with Neutron Networing, IceHouseBuild the OpenStack Cloud with Neutron Networing, IceHouse
Build the OpenStack Cloud with Neutron Networing, IceHouse
 
20150502 unix v6로 배우는 커널의 원리와 구조 1 김지은
20150502 unix v6로 배우는 커널의 원리와 구조 1 김지은20150502 unix v6로 배우는 커널의 원리와 구조 1 김지은
20150502 unix v6로 배우는 커널의 원리와 구조 1 김지은
 
resource on openstack
 resource on openstack resource on openstack
resource on openstack
 

Ryu with OpenFlow 1.3, Traffic Monitor

  • 2. Traffic Monitor •  Ryu, Traffic Monitor OpenFlow를 활용한 스위치의 통계정보 얻기 •  simple_monitor.py https://github.com/osrg/ryu-book/blob/master/en/source/sources/ > ryu-book GitHub
  • 3. simple_monitor.py •  Download Sample Code # wget https://github.com/osrg/ryu-book/blob/master/en/source/sources/simple_monitor.py •  View the Code # vi ./simple_monitor,py from operator import attrgetter from ryu.app import simple_switch_13 from ryu.controller import ofp_event from ryu.controller.handler import MAIN_DISPATCHER, DEAD_DISPATCHER from ryu.controller.handler import set_ev_cls from ryu.lib import hub # eventlet wrapper, 기본 클래스 class SimpleMonitor(simple_switch_13.SimpleSwitch13): def __init__(self, *args, **kwargs): super(SimpleMonitor, self).__init__(*args, **kwargs) self.datapaths = {} self.monitor_thread = hub.spawn(self._monitor) # hub.spawn(), Thread(Eventlet Green Thread) 생성 # ... # _monitor : thread 함수
  • 4. simple_monitor.py •  View the Code # vi ./simple_monitor,py @set_ev_cls(ofp_event.EventOFPStateChange, # 스위치의 접속 및 접속끊김에 대한 EventOFPStateChange 이벤트 [MAIN_DISPATCHER, DEAD_DISPATCHER]) # datapath 가 바뀌면 Ryu 프레임웍에서 발행 def _state_change_handler(self, ev): datapath = ev.datapath if ev.state == MAIN_DISPATCHER: # 모니터링 대상으로 등록 if not datapath.id in self.datapaths: self.logger.debug('register datapath: %016x', datapath.id) self.datapaths[datapath.id] = datapath elif ev.state == DEAD_DISPATCHER: # 모니터링 대상에서 제외 if datapath.id in self.datapaths: self.logger.debug('unregister datapath: %016x', datapath.id) del self.datapaths[datapath.id] def _monitor(self): while True: for dp in self.datapaths.values(): # self.datapaths.values self._request_stats(dp) # 상태정보 요청 hub.sleep(10) # 10초마다 def _request_stats(self, datapath): # 통계를 스위치에게 요청 self.logger.debug('send stats request: %016x', datapath.id) ofproto = datapath.ofproto parser = datapath.ofproto_parser req = parser.OFPFlowStatsRequest(datapath) # flow 항목관련, 세부항목 설정 가능 datapath.send_msg(req) req = parser.OFPPortStatsRequest(datapath, 0, ofproto.OFPP_ANY) # 포트 항목관련 datapath.send_msg(req)
  • 5. simple_monitor.py •  View the Code # vi ./simple_monitor,py @set_ev_cls(ofp_event.EventOFPFlowStatsReply, MAIN_DISPATCHER) def _flow_stats_reply_handler(self, ev): # 스위치의 응답받는 이벤트핸들러, flow_stats_reply 수신 body = ev.msg.body # body, OFPFlowStatsReply의 속성 # OFPFlowStats 리스트에서 FlowStatsRequest의 대상이 된 각 플로우 항목의 통계정보 포함 self.logger.info('datapath ' 'in-port eth-dst ' 'out-port packets bytes') self.logger.info('---------------- ' '-------- ----------------- ' '-------- -------- --------') for stat in sorted([flow for flow in body if flow.priority == 1], # 우선순위가 0인, Table_miss항목을 제외하고 key=lambda flow: (flow.match['in_port'], # 수신포트와 Dst MAC을 가지고 정렬하여 flow.match['eth_dst'])): # 플로우 항목과 매치가되는 self.logger.info('%016x %8x %17s %8x %8d %8d', # 패킷과 바이트 출력 ev.msg.datapath.id, stat.match['in_port'], stat.match['eth_dst'], stat.instructions[0].actions[0].port, stat.packet_count, stat.byte_count)
  • 6. simple_monitor.py •  View the Code # vi ./simple_monitor,py > 외부 프로그램과의 연동을 위한 JSON형태의 데이터를 제공 # 위의 코드로 얻어지는 JSON 데이터 import json # ... self.logger.info('%s', json.dumps(ev.msg.to_jsondict(), ensure_ascii=True, indent=3, sort_keys=True)) { "OFPFlowStatsReply": { "body": [ { "OFPFlowStats": { "byte_count": 0, "cookie": 0, "duration_nsec": 680000000, "duration_sec": 4, "flags": 0, "hard_timeout": 0, "idle_timeout": 0, "instructions": [ { "OFPInstructionActions": { "actions": [ { "OFPActionOutput": { "len": 16, "max_len": 65535, "port": 4294967293, "type": 0 } } ], "len": 24, "type": 4 } } ], "length": 80, "match": { "OFPMatch": { "length": 4, "oxm_fields": [], "type": 1 } }, "packet_count": 0, "priority": 0, "table_id": 0 } }, { "OFPFlowStats": { "byte_count": 42, "cookie": 0, ……
  • 7. simple_monitor.py •  View the Code # vi ./simple_monitor,py @set_ev_cls(ofp_event.EventOFPPortStatsReply, MAIN_DISPATCHER) def _port_stats_reply_handler(self, ev): # 스위치의 응답받는 이벤트핸들러, port_stats_reply 수신 body = ev.msg.body # body, OFPPortStatsReply의 속성 self.logger.info('datapath port ' 'rx-pkts rx-bytes rx-error ' 'tx-pkts tx-bytes tx-error') self.logger.info('---------------- -------- ' '-------- -------- -------- ' '-------- -------- --------') for stat in sorted(body, key=attrgetter('port_no')): self.logger.info('%016x %8x %8d %8d %8d %8d %8d %8d', ev.msg.datapath.id, stat.port_no, #포트 번호별로 정렬 stat.rx_packets, stat.rx_bytes, stat.rx_errors, # 수신 패킷 개수, 수신된 바이트 수신 오류 개수, stat.tx_packets, stat.tx_bytes, stat.tx_errors) # 전송 패킷 수, 송신 바이트 수, 전송 오류 개수 출력 Port 관련 통계정보 : 포트 번호, 송수신 각각의 패킷 수, 바이트 수, 드롭 개수, 오류 개수, 프레임 오류 개수, 오버런 개수, CRC 오류 개수, 충돌 개수 등 통계 정보
  • 8. Ryubook Practice •  이번엔, Ryu응용 프로그램에서 Thread생성 방법 DataPath의 상태변화 확인 FlowStats 및 PortStats 수집 및 방법 •  호스트에서 Midinet 실행 # mn --topo single,3 --mac --switch ovsk --controller remote –x •  스위치에서 OpenFlow 프로토콜 설정 # ovs-vsctl set Bridge s1 protocols=OpenFlow13 확인 # ovs-ofctl -O OpenFlow13 dump-flows s1 OFPST_FLOW reply (OF1.3) (xid=0x2): #
  • 9. TEST •  트래픽 모니터 실행 Controller, c0: # ryu-manager –verbose /usr/local/lib/python2.7/disk-package/tyu/simple_monitor.py ……
  • 10. TEST •  트래픽 모니터 실행 Table-miss(0)은 표시되지 않음으로 아무 내용도 없음 : 플로우 및 포트 정보 모두 없음
  • 11. TEST •  트래픽 모니터 실행 Host1에서 Host2로 ping 테스트
  • 12. TEST •  트래픽 모니터 실행 Host1에서 Host2로 ping 테스트 - 결과 이벤트 발생 패킷 전송 및 플로우 항목 등록, 통계정보 변경 [flow 항목 테이블] 수신포트1 : 1 packet, 42bytes 수신포트2 : 2 packets, 140bytes [packet 항목 테이블] 포트1 : 3 packets, 182 bytes (rx) 포트2 : 3 packets, 182 bytes (rx) 1.  Host1에서 Boardcast로 ARP 2.  Host2에서 Host1로 ARP 응답 3.  Host1에서 Host2로 ICMP Flow 항목과 Packet 항목이 다른이유? : Port 항목 테이블의 경우 port로 유입되는 패 킷들에 대한 단순 카운트값이므로 flow 항목 테 이블과는 의미가 다름