Split View: [컴퓨터 네트워크] 11. 네트워크 계층 개요: 포워딩과 라우팅
[컴퓨터 네트워크] 11. 네트워크 계층 개요: 포워딩과 라우팅
네트워크 계층 개요: 포워딩과 라우팅
네트워크 계층(Network Layer)은 송신 호스트에서 수신 호스트까지 패킷을 전달하는 역할을 담당합니다. 트랜스포트 계층이 종단 간 논리적 통신을 제공한다면, 네트워크 계층은 호스트 간 실제 경로를 결정하고 패킷을 이동시키는 핵심 계층입니다.
이 글에서는 네트워크 계층의 두 가지 핵심 기능인 포워딩(Forwarding) 과 라우팅(Routing) 을 구분하고, 네트워크 서비스 모델, 가상 회선과 데이터그램 네트워크의 차이, 그리고 라우터의 내부 구조를 살펴봅니다.
1. 포워딩과 라우팅의 구분
1.1 포워딩 (Forwarding)
포워딩은 라우터의 입력 포트에 도착한 패킷을 적절한 출력 포트로 이동시키는 로컬 동작입니다. 하드웨어 수준에서 나노초 단위로 수행되며, 포워딩 테이블(Forwarding Table)을 참조하여 결정됩니다.
1.2 라우팅 (Routing)
라우팅은 패킷이 출발지에서 목적지까지 이동하는 전체 경로를 결정하는 네트워크 전역 동작입니다. 라우팅 알고리즘이 포워딩 테이블의 내용을 결정합니다.
1.3 비유로 이해하기
자동차 여행에 비유하면 다음과 같습니다.
- 라우팅: 서울에서 부산까지의 전체 경로를 네비게이션으로 계획하는 것
- 포워딩: 각 교차로에서 네비게이션 안내에 따라 좌회전 또는 우회전하는 것
포워딩과 라우팅의 관계
========================
[라우팅 알고리즘] -----> [포워딩 테이블]
(경로 결정) (테이블 참조)
|
v
패킷 도착 --> [입력 포트] --> [스위칭] --> [출력 포트] --> 패킷 전송
(포워딩: 로컬 동작)
2. 네트워크 서비스 모델
네트워크 계층이 트랜스포트 계층에 제공할 수 있는 서비스 모델은 크게 두 가지입니다.
2.1 연결형 서비스 (Connection-Oriented)
데이터 전송 전에 경로를 설정하고, 모든 패킷이 같은 경로를 따라 이동합니다. ATM, Frame Relay 네트워크가 대표적입니다.
2.2 비연결형 서비스 (Connectionless)
각 패킷이 독립적으로 라우팅됩니다. 인터넷의 IP 프로토콜이 이 방식을 사용합니다.
서비스 모델 비교
=================
항목 | 연결형 (VC) | 비연결형 (Datagram)
------------------+---------------------+---------------------
연결 설정 | 필요 | 불필요
패킷 경로 | 동일 경로 | 각각 독립적
상태 유지 | 라우터에 상태 저장 | 상태 없음
대역폭 보장 | 가능 | 불가
대표 기술 | ATM, MPLS | IP (인터넷)
3. 가상 회선 네트워크 (Virtual Circuit)
3.1 가상 회선의 개념
가상 회선(VC) 네트워크는 전화 네트워크와 유사한 방식으로, 데이터 전송 전에 경로를 설정합니다. 물리적으로 전용 회선을 할당하지는 않지만, 논리적으로 고정된 경로를 따릅니다.
3.2 VC의 3단계
- 연결 설정 (Setup): 경로상의 모든 라우터에 VC 번호를 할당하고 포워딩 테이블에 엔트리를 추가합니다.
- 데이터 전송 (Data Transfer): 패킷은 VC 번호를 헤더에 포함하여 설정된 경로를 따라 이동합니다.
- 연결 해제 (Teardown): 경로상의 모든 라우터에서 VC 관련 상태를 제거합니다.
가상 회선 동작 예시
====================
호스트 A --> [R1] --> [R2] --> [R3] --> 호스트 B
VC 번호 변환 테이블 (라우터 R1):
+----------+--------+----------+--------+
| 입력 인터페이스 | 입력 VC | 출력 인터페이스 | 출력 VC |
+----------+--------+----------+--------+
| 1 | 12 | 3 | 22 |
| 2 | 63 | 4 | 18 |
+----------+--------+----------+--------+
패킷이 인터페이스 1에 VC=12로 도착
--> 인터페이스 3으로 VC=22로 변환하여 전송
3.3 시그널링 프로토콜
VC 설정과 해제를 위해 시그널링 프로토콜(Signaling Protocol)이 사용됩니다. ATM에서는 Q.2931, Frame Relay에서는 LMI 프로토콜이 대표적입니다.
4. 데이터그램 네트워크 (Datagram Network)
4.1 데이터그램 방식의 특징
데이터그램 네트워크에서는 연결 설정 과정이 없습니다. 각 패킷은 목적지 주소를 헤더에 포함하고, 라우터는 해당 주소를 기반으로 독립적으로 포워딩 결정을 내립니다.
4.2 최장 프리픽스 매칭 (Longest Prefix Matching)
라우터의 포워딩 테이블은 목적지 주소의 프리픽스를 기준으로 매칭합니다. 여러 엔트리가 매칭되면 가장 긴 프리픽스를 가진 엔트리를 선택합니다.
최장 프리픽스 매칭 예시
========================
포워딩 테이블:
+----------------------------+----------+
| 목적지 주소 프리픽스 | 출력 링크 |
+----------------------------+----------+
| 11001000 00010111 00010 | 링크 0 |
| 11001000 00010111 00011000 | 링크 1 |
| 11001000 00010111 00011 | 링크 2 |
| 그 외 | 링크 3 |
+----------------------------+----------+
목적지 주소: 11001000 00010111 00011000 10101010
--> 링크 0: 프리픽스 21비트 매칭
--> 링크 1: 프리픽스 24비트 매칭 <-- 선택 (가장 긴 매칭)
--> 링크 2: 프리픽스 21비트 매칭
5. 라우터 내부 구조
라우터는 크게 4가지 구성 요소로 이루어져 있습니다.
라우터 내부 구조
=================
[라우팅 프로세서]
(제어 평면)
|
| 포워딩 테이블 배포
v
[입력 포트] --> [스위칭 패브릭] --> [출력 포트]
[입력 포트] --> [스위칭 패브릭] --> [출력 포트]
[입력 포트] --> [스위칭 패브릭] --> [출력 포트]
(데이터 평면)
5.1 입력 포트 (Input Port)
입력 포트는 세 가지 기능을 수행합니다.
- 물리 계층 기능: 들어오는 물리적 신호를 비트로 변환
- 링크 계층 기능: 프레임의 헤더를 처리하고 디캡슐레이션
- 포워딩 기능: 포워딩 테이블을 참조하여 출력 포트를 결정
입력 포트 처리 과정
====================
물리 신호 --> [회선 종단] --> [링크 계층 처리] --> [포워딩 테이블 조회]
|
v
[스위칭 패브릭으로]
5.2 스위칭 패브릭 (Switching Fabric)
스위칭 패브릭은 입력 포트에서 출력 포트로 패킷을 물리적으로 이동시킵니다. 세 가지 방식이 있습니다.
메모리 기반 스위칭: 초기 라우터에서 사용하던 방식으로, CPU가 패킷을 메모리에 복사한 후 출력 포트로 전송합니다. 메모리 대역폭에 의해 속도가 제한됩니다.
버스 기반 스위칭: 패킷이 공유 버스를 통해 입력 포트에서 출력 포트로 직접 이동합니다. 버스 대역폭에 의해 속도가 제한됩니다.
크로스바 스위칭: N개의 입력과 N개의 출력을 연결하는 격자 구조입니다. 서로 다른 포트 쌍 간에 동시 전송이 가능하여 가장 빠릅니다.
스위칭 패브릭 3가지 방식
=========================
1. 메모리 기반 2. 버스 기반 3. 크로스바
[입력] -> [메모리] [입력] --+ [입력]-+-+-+
| [입력] --+--> [버스] [입력]-+-+-+
v [입력] --+ [입력]-+-+-+
[출력] [출력] <-+ | | |
[출력] <-+ [출력] [출력] [출력]
[출력] <-+
5.3 출력 포트 (Output Port)
출력 포트는 스위칭 패브릭에서 전달받은 패킷을 버퍼에 저장하고, 링크 계층 및 물리 계층 처리를 거쳐 출력 링크로 전송합니다.
5.4 큐잉과 패킷 손실
입력 포트와 출력 포트 모두에서 큐잉이 발생할 수 있습니다.
출력 포트 큐잉: 여러 입력 포트에서 동시에 같은 출력 포트로 패킷이 도착하면 버퍼에 대기해야 합니다. 버퍼가 가득 차면 패킷이 드롭됩니다.
입력 포트 큐잉: 스위칭 패브릭이 모든 입력 패킷을 동시에 처리할 수 없을 때 발생합니다. HOL(Head-of-Line) 블로킹 문제가 발생할 수 있습니다.
HOL 블로킹 문제
================
입력 포트 1의 큐: [패킷A -> 출력1] [패킷B -> 출력2]
입력 포트 2의 큐: [패킷C -> 출력1] [패킷D -> 출력3]
패킷 A와 C 모두 출력 포트 1로 향함
--> 패킷 C는 대기해야 함
--> 패킷 D는 출력 포트 3이 비어있지만
패킷 C 뒤에 있으므로 함께 대기 (HOL 블로킹)
6. 제어 평면과 데이터 평면
6.1 전통적 접근 방식
전통적으로 라우팅 알고리즘은 각 라우터에서 독립적으로 실행되며, 이웃 라우터와 정보를 교환하여 포워딩 테이블을 구성합니다.
6.2 SDN (Software-Defined Networking)
SDN에서는 원격 컨트롤러가 포워딩 테이블을 계산하여 각 라우터에 배포합니다. 라우터는 포워딩만 수행하고, 라우팅 결정은 중앙에서 이루어집니다.
전통적 방식 vs SDN
====================
전통적 방식: SDN 방식:
[R1]---[R2]---[R3] [원격 컨트롤러]
| | | / | \
각 라우터가 독립적으로 [R1] [R2] [R3]
라우팅 알고리즘 실행 컨트롤러가 중앙에서
포워딩 테이블 계산/배포
7. 버퍼 크기 설정
라우터의 버퍼 크기는 네트워크 성능에 큰 영향을 미칩니다.
전통적인 경험 법칙에 따르면, 링크 용량이 C이고 RTT가 평균 RTT일 때, 버퍼 크기는 다음과 같이 설정합니다.
버퍼 크기 = RTT x C
예시:
RTT = 250ms, C = 10 Gbps
버퍼 크기 = 0.25 x 10 x 10^9 = 2.5 Gbit
최근 연구에 따른 수정된 공식:
버퍼 크기 = (RTT x C) / sqrt(N)
N = TCP 플로우 수
이 수정된 공식은 많은 수의 TCP 플로우가 통계적 다중화 효과를 통해 더 작은 버퍼로도 충분함을 보여줍니다.
8. 패킷 스케줄링
출력 포트에서 여러 패킷이 대기 중일 때, 어떤 패킷을 먼저 전송할지 결정하는 스케줄링 방식이 필요합니다.
8.1 FIFO (First-In First-Out)
가장 단순한 방식으로, 도착 순서대로 전송합니다.
8.2 우선순위 큐잉 (Priority Queuing)
패킷을 우선순위 클래스로 분류하고, 높은 우선순위 패킷을 먼저 전송합니다.
8.3 라운드 로빈과 WFQ
라운드 로빈(Round Robin): 각 클래스를 순환하며 하나씩 전송합니다.
WFQ(Weighted Fair Queuing): 라운드 로빈의 가중치 버전으로, 각 클래스에 가중치를 부여하여 대역폭을 공정하게 분배합니다.
패킷 스케줄링 비교
====================
FIFO: [1][2][3][4] --> 순서대로 전송
우선순위: 높음: [A][C] --> A, C 먼저 전송
낮음: [B][D] --> 그 다음 B, D
WFQ: 클래스1 (w=2): [A][C] --> 2배 대역폭
클래스2 (w=1): [B] --> 1배 대역폭
9. 정리
네트워크 계층의 핵심 개념을 정리하면 다음과 같습니다.
| 개념 | 핵심 내용 |
|---|---|
| 포워딩 | 로컬 동작, 입력에서 출력으로 패킷 이동 |
| 라우팅 | 전역 동작, 출발지에서 목적지까지 경로 결정 |
| 가상 회선 | 연결 설정 후 동일 경로 사용, 라우터에 상태 유지 |
| 데이터그램 | 연결 설정 없음, 각 패킷 독립 라우팅 |
| 최장 프리픽스 매칭 | 포워딩 테이블에서 가장 긴 프리픽스 선택 |
| HOL 블로킹 | 큐 앞의 패킷이 뒤의 패킷까지 지연시키는 문제 |
다음 글에서는 인터넷의 핵심 프로토콜인 IP(Internet Protocol)의 데이터그램 형식과 주소 체계를 자세히 알아보겠습니다.
참고 자료
- James F. Kurose, Keith W. Ross, "Computer Networking: A Top-Down Approach", 6th Edition, Chapter 4
- RFC 791 - Internet Protocol
- Andrew S. Tanenbaum, "Computer Networks", 5th Edition
[Computer Networking] 11. Network Layer Overview: Forwarding and Routing
Network Layer Overview: Forwarding and Routing
The Network Layer is responsible for delivering packets from the sending host to the receiving host. While the transport layer provides end-to-end logical communication, the network layer is the core layer that determines the actual path between hosts and moves packets along that path.
In this post, we distinguish between the two core functions of the network layer: Forwarding and Routing, and examine the network service model, the differences between virtual circuit and datagram networks, and the internal structure of routers.
1. Distinguishing Forwarding and Routing
1.1 Forwarding
Forwarding is a local action that moves a packet arriving at a router's input port to the appropriate output port. It is performed at the hardware level in nanoseconds and is determined by consulting the forwarding table.
1.2 Routing
Routing is a network-wide action that determines the entire path a packet takes from source to destination. Routing algorithms determine the contents of the forwarding table.
1.3 Understanding Through Analogy
An analogy with a car trip works as follows:
- Routing: Planning the entire route from Seoul to Busan using a navigation system
- Forwarding: Turning left or right at each intersection according to the navigation instructions
Relationship Between Forwarding and Routing
=============================================
[Routing Algorithm] -----> [Forwarding Table]
(Path Decision) (Table Lookup)
|
v
Packet Arrives --> [Input Port] --> [Switching] --> [Output Port] --> Packet Sent
(Forwarding: Local Action)
2. Network Service Models
The network layer can offer two main service models to the transport layer.
2.1 Connection-Oriented Service
A path is established before data transfer, and all packets follow the same path. ATM and Frame Relay networks are representative examples.
2.2 Connectionless Service
Each packet is routed independently. The Internet's IP protocol uses this approach.
Service Model Comparison
=========================
Item | Connection-Oriented (VC) | Connectionless (Datagram)
-------------------+--------------------------+---------------------------
Connection Setup | Required | Not required
Packet Path | Same path | Each independent
State Maintenance | State stored in routers | No state
Bandwidth Guarantee| Possible | Not possible
Representative Tech| ATM, MPLS | IP (Internet)
3. Virtual Circuit Network
3.1 Concept of Virtual Circuits
A Virtual Circuit (VC) network operates similarly to a telephone network, establishing a path before data transfer. While it does not physically allocate a dedicated circuit, packets logically follow a fixed path.
3.2 Three Phases of VC
- Setup: Assigns a VC number to all routers along the path and adds entries to forwarding tables.
- Data Transfer: Packets include the VC number in their header and travel along the established path.
- Teardown: Removes VC-related state from all routers along the path.
Virtual Circuit Operation Example
===================================
Host A --> [R1] --> [R2] --> [R3] --> Host B
VC Number Translation Table (Router R1):
+------------------+----------+-------------------+----------+
| Input Interface | Input VC | Output Interface | Output VC|
+------------------+----------+-------------------+----------+
| 1 | 12 | 3 | 22 |
| 2 | 63 | 4 | 18 |
+------------------+----------+-------------------+----------+
Packet arrives at interface 1 with VC=12
--> Translated to VC=22 and forwarded via interface 3
3.3 Signaling Protocols
Signaling protocols are used for VC setup and teardown. Q.2931 is used in ATM and LMI protocol in Frame Relay.
4. Datagram Network
4.1 Characteristics of the Datagram Approach
In a datagram network, there is no connection setup phase. Each packet includes the destination address in its header, and routers make independent forwarding decisions based on that address.
4.2 Longest Prefix Matching
The router's forwarding table matches based on the prefix of the destination address. When multiple entries match, the entry with the longest prefix is selected.
Longest Prefix Matching Example
=================================
Forwarding Table:
+-------------------------------+-----------+
| Destination Address Prefix | Output Link|
+-------------------------------+-----------+
| 11001000 00010111 00010 | Link 0 |
| 11001000 00010111 00011000 | Link 1 |
| 11001000 00010111 00011 | Link 2 |
| Otherwise | Link 3 |
+-------------------------------+-----------+
Destination address: 11001000 00010111 00011000 10101010
--> Link 0: 21-bit prefix match
--> Link 1: 24-bit prefix match <-- Selected (longest match)
--> Link 2: 21-bit prefix match
5. Router Internal Structure
A router consists of four major components.
Router Internal Structure
==========================
[Routing Processor]
(Control Plane)
|
| Forwarding table distribution
v
[Input Port] --> [Switching Fabric] --> [Output Port]
[Input Port] --> [Switching Fabric] --> [Output Port]
[Input Port] --> [Switching Fabric] --> [Output Port]
(Data Plane)
5.1 Input Port
The input port performs three functions:
- Physical Layer Function: Converts incoming physical signals to bits
- Link Layer Function: Processes frame headers and performs decapsulation
- Forwarding Function: Consults the forwarding table to determine the output port
Input Port Processing
======================
Physical Signal --> [Line Termination] --> [Link Layer Processing] --> [Forwarding Table Lookup]
|
v
[To Switching Fabric]
5.2 Switching Fabric
The switching fabric physically moves packets from input ports to output ports. There are three approaches:
Memory-based Switching: Used in early routers, the CPU copies packets to memory and then forwards them to the output port. Speed is limited by memory bandwidth.
Bus-based Switching: Packets move directly from input port to output port through a shared bus. Speed is limited by bus bandwidth.
Crossbar Switching: A grid structure connecting N inputs to N outputs. It allows simultaneous transmission between different port pairs, making it the fastest.
Three Types of Switching Fabric
=================================
1. Memory-based 2. Bus-based 3. Crossbar
[Input] -> [Memory] [Input] --+ [Input]-+-+-+
| [Input] --+--> [Bus] [Input]-+-+-+
v [Input] --+ [Input]-+-+-+
[Output] [Output] <-+ | | |
[Output] <-+ [Output][Output][Output]
[Output] <-+
5.3 Output Port
The output port stores packets received from the switching fabric in a buffer, performs link layer and physical layer processing, and transmits them on the output link.
5.4 Queuing and Packet Loss
Queuing can occur at both input and output ports.
Output Port Queuing: When packets from multiple input ports arrive at the same output port simultaneously, they must wait in the buffer. Packets are dropped when the buffer is full.
Input Port Queuing: Occurs when the switching fabric cannot process all input packets simultaneously. This can cause the HOL (Head-of-Line) blocking problem.
HOL Blocking Problem
=====================
Input Port 1 Queue: [Packet A -> Output 1] [Packet B -> Output 2]
Input Port 2 Queue: [Packet C -> Output 1] [Packet D -> Output 3]
Both Packet A and C are destined for Output Port 1
--> Packet C must wait
--> Packet D has Output Port 3 available but
is behind Packet C, so it also waits (HOL Blocking)
6. Control Plane and Data Plane
6.1 Traditional Approach
Traditionally, routing algorithms run independently on each router, exchanging information with neighboring routers to build forwarding tables.
6.2 SDN (Software-Defined Networking)
In SDN, a remote controller computes forwarding tables and distributes them to each router. Routers only perform forwarding, while routing decisions are made centrally.
Traditional Approach vs SDN
=============================
Traditional: SDN:
[R1]---[R2]---[R3] [Remote Controller]
| | | / | \
Each router independently [R1] [R2] [R3]
runs routing algorithms Controller centrally
computes/distributes
forwarding tables
7. Buffer Sizing
Router buffer size significantly impacts network performance.
According to the traditional rule of thumb, when the link capacity is C and the average round-trip time is RTT, the buffer size is set as follows:
Buffer Size = RTT x C
Example:
RTT = 250ms, C = 10 Gbps
Buffer Size = 0.25 x 10 x 10^9 = 2.5 Gbit
Revised formula from recent research:
Buffer Size = (RTT x C) / sqrt(N)
N = number of TCP flows
This revised formula shows that a large number of TCP flows provide statistical multiplexing effects, allowing smaller buffers to suffice.
8. Packet Scheduling
When multiple packets are waiting at an output port, a scheduling method is needed to decide which packet to transmit first.
8.1 FIFO (First-In First-Out)
The simplest approach, transmitting packets in arrival order.
8.2 Priority Queuing
Packets are classified into priority classes, and higher-priority packets are transmitted first.
8.3 Round Robin and WFQ
Round Robin: Cycles through each class, transmitting one packet at a time.
WFQ (Weighted Fair Queuing): A weighted version of round robin that assigns weights to each class to fairly distribute bandwidth.
Packet Scheduling Comparison
==============================
FIFO: [1][2][3][4] --> Transmitted in order
Priority: High: [A][C] --> A, C transmitted first
Low: [B][D] --> Then B, D
WFQ: Class 1 (w=2): [A][C] --> 2x bandwidth
Class 2 (w=1): [B] --> 1x bandwidth
9. Summary
A summary of the key concepts of the network layer:
| Concept | Key Points |
|---|---|
| Forwarding | Local action, moving packets from input to output |
| Routing | Global action, determining path from source to dest |
| Virtual Circuit | Same path after connection setup, state in routers |
| Datagram | No connection setup, each packet routed independently |
| Longest Prefix Matching | Selects the longest prefix in the forwarding table |
| HOL Blocking | Packet at head of queue delays packets behind it |
In the next post, we will examine the datagram format and addressing system of IP (Internet Protocol), the core protocol of the Internet.
References
- James F. Kurose, Keith W. Ross, "Computer Networking: A Top-Down Approach", 6th Edition, Chapter 4
- RFC 791 - Internet Protocol
- Andrew S. Tanenbaum, "Computer Networks", 5th Edition