SDN
Software-Defined Networking
An architecture that separates the Control Plane and Data Plane to centrally control networks through software. OpenFlow protocol and VMware NSX are typical.
Software-Defined Networking
An architecture that separates the Control Plane and Data Plane to centrally control networks through software. OpenFlow protocol and VMware NSX are typical.
SDN (Software-Defined Networking) is an architecture that separates the Control Plane and Data Plane of network devices and controls the network centrally through software. In traditional networks, each switch and router decides its own packet forwarding paths, but in SDN a central SDN controller decides the routing for the entire network.
The core of SDN is a three-layer structure. It is divided into the Application Layer (network applications), the Control Layer (SDN controller), and the Infrastructure Layer (switches/routers). The OpenFlow protocol is the standard used for communication between the controller and network devices. OpenFlow was developed at Stanford University in 2008 and is the protocol that started SDN.
A representative SDN solution is VMware NSX. NSX provides virtualized networks for data centers and implements micro-segmentation, distributed firewalls, load balancing, and more in software. In cloud environments, AWS VPC, Google Cloud VPC, and Azure Virtual Network are built on SDN concepts.
The advantages of SDN are network automation, programmability, and centralized management. Network configuration can be managed as code through APIs, making it well suited to DevOps environments. In large data centers, it can automatically provision networks for thousands of servers and dynamically optimize paths according to traffic patterns.
# Ryu SDN 컨트롤러 - 간단한 L2 스위치 구현
# pip install ryu
from ryu.base import app_manager
from ryu.controller import ofp_event
from ryu.controller.handler import MAIN_DISPATCHER, set_ev_cls
from ryu.ofproto import ofproto_v1_3
from ryu.lib.packet import packet, ethernet
class SimpleSwitch(app_manager.RyuApp):
OFP_VERSIONS = [ofproto_v1_3.OFP_VERSION]
def __init__(self, *args, **kwargs):
super(SimpleSwitch, self).__init__(*args, **kwargs)
self.mac_to_port = {} # MAC 주소 학습 테이블
@set_ev_cls(ofp_event.EventOFPPacketIn, MAIN_DISPATCHER)
def packet_in_handler(self, ev):
msg = ev.msg
datapath = msg.datapath
ofproto = datapath.ofproto
parser = datapath.ofproto_parser
in_port = msg.match['in_port']
pkt = packet.Packet(msg.data)
eth = pkt.get_protocol(ethernet.ethernet)
dst = eth.dst
src = eth.src
dpid = datapath.id
# MAC 주소 학습
self.mac_to_port.setdefault(dpid, {})
self.mac_to_port[dpid][src] = in_port
# 목적지 MAC이 학습되어 있으면 해당 포트로, 아니면 Flood
if dst in self.mac_to_port[dpid]:
out_port = self.mac_to_port[dpid][dst]
else:
out_port = ofproto.OFPP_FLOOD
actions = [parser.OFPActionOutput(out_port)]
# Flow Entry 추가 (MAC 학습된 경우)
if out_port != ofproto.OFPP_FLOOD:
match = parser.OFPMatch(in_port=in_port, eth_dst=dst)
self.add_flow(datapath, 1, match, actions)
# 패킷 전달
out = parser.OFPPacketOut(
datapath=datapath, buffer_id=msg.buffer_id,
in_port=in_port, actions=actions, data=msg.data)
datapath.send_msg(out)
def add_flow(self, datapath, priority, match, actions):
ofproto = datapath.ofproto
parser = datapath.ofproto_parser
inst = [parser.OFPInstructionActions(
ofproto.OFPIT_APPLY_ACTIONS, actions)]
mod = parser.OFPFlowMod(
datapath=datapath, priority=priority,
match=match, instructions=inst)
datapath.send_msg(mod)
# 실행: ryu-manager simple_switch.py
# Kubernetes Calico CNI 설정 (SDN 기반 네트워크 정책)
# Network Policy - 특정 Pod 간 통신만 허용
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: allow-frontend-to-backend
namespace: production
spec:
podSelector:
matchLabels:
app: backend
policyTypes:
- Ingress
- Egress
ingress:
- from:
- podSelector:
matchLabels:
app: frontend
ports:
- protocol: TCP
port: 8080
egress:
- to:
- podSelector:
matchLabels:
app: database
ports:
- protocol: TCP
port: 5432
---
# Cilium eBPF 기반 L7 정책 (HTTP 경로별 제어)
apiVersion: cilium.io/v2
kind: CiliumNetworkPolicy
metadata:
name: api-policy
spec:
endpointSelector:
matchLabels:
app: api-server
ingress:
- fromEndpoints:
- matchLabels:
app: frontend
toPorts:
- ports:
- port: "80"
protocol: TCP
rules:
http:
- method: GET
path: "/api/v1/.*"
- method: POST
path: "/api/v1/users"
# Open vSwitch (OVS) CLI 명령어
# OVS는 대표적인 소프트웨어 스위치로 SDN 환경에서 널리 사용
# 브리지 생성
ovs-vsctl add-br br0
# 포트 추가
ovs-vsctl add-port br0 eth0
ovs-vsctl add-port br0 eth1
# OpenFlow 컨트롤러 연결
ovs-vsctl set-controller br0 tcp:192.168.1.100:6653
# Flow 테이블 확인
ovs-ofctl dump-flows br0
# 수동 Flow 추가 (특정 IP로 가는 트래픽을 포트 2로 전달)
ovs-ofctl add-flow br0 "priority=100,ip,nw_dst=10.0.0.50,actions=output:2"
# VLAN 태깅 Flow
ovs-ofctl add-flow br0 "priority=100,in_port=1,actions=mod_vlan_vid:100,output:2"
# Flow 통계 확인
ovs-ofctl dump-flows br0 --with-stats
# 포트 미러링 설정 (트래픽 모니터링용)
ovs-vsctl -- set Bridge br0 mirrors=@m \
-- --id=@eth0 get Port eth0 \
-- --id=@eth2 get Port eth2 \
-- --id=@m create Mirror name=mirror0 select-dst-port=@eth0 output-port=@eth2
# 브리지 상태 확인
ovs-vsctl show
# OpenFlow 버전 설정
ovs-vsctl set bridge br0 protocols=OpenFlow13
"If we move the data center to SDN, we can cut network provisioning time from days to minutes. With NSX, micro-segmentation is possible at the VM level, which also strengthens East-West traffic security."
"The core of SDN is separating the Control Plane and Data Plane. In traditional networks, each switch manages its own routing table, but in SDN a central controller controls the Flow Table of every switch over the OpenFlow protocol. This makes Network as Code, managing the network as code, possible."
"CNI plugins like Calico and Cilium apply SDN principles. Cilium is eBPF-based, so packet filtering happens at the kernel level and Network Policy performance is much better. I recommend Cilium for large clusters."
Take a mock interview on this topic → WIA SOOM AI Interview · Start for free
If the SDN controller goes down, the whole network can be paralyzed. Be sure to configure controller clustering (HA) and set the switches' fail-safe mode. Enterprise controllers such as OpenDaylight and ONOS support clustering.
The TCAM capacity of hardware switches is limited (typically thousands to tens of thousands of flows). Too many flow rules cause performance degradation or flow loss. Use wildcard matching and apply flow aggregation.
Existing network equipment may not support OpenFlow. Rather than a full replacement, gradual migration using SDN overlays (VXLAN, GRE) is more realistic.
Test thoroughly in a pilot environment, then expand in stages. Controller HA configuration is essential, and clearly define the boundary between the existing network and the SDN domain. Use monitoring tools to continuously check communication latency between controllers and switches.