Skip to content

Split View: [컴퓨터 네트워크] 14. 인터넷 라우팅: OSPF와 BGP

|

[컴퓨터 네트워크] 14. 인터넷 라우팅: OSPF와 BGP

인터넷 라우팅: OSPF와 BGP

실제 인터넷은 수십억 개의 장비로 구성된 거대한 네트워크입니다. 단일 라우팅 알고리즘으로 전체 인터넷의 경로를 계산하는 것은 확장성과 관리 측면에서 불가능합니다.

이 글에서는 인터넷이 자율 시스템(AS) 단위로 계층적 라우팅을 수행하는 방식, AS 내부 라우팅 프로토콜인 RIPOSPF, 그리고 AS 간 라우팅 프로토콜인 BGP를 살펴봅니다.


1. 계층적 라우팅의 필요성

1.1 확장성 문제

모든 라우터가 전체 인터넷의 토폴로지를 저장하고 계산한다면:

  • 저장 공간: 수십억 개의 목적지에 대한 포워딩 테이블
  • 계산 비용: 전체 토폴로지에 대한 라우팅 알고리즘 실행
  • 메시지 오버헤드: 링크 상태 업데이트가 전 세계로 전파

1.2 관리 자율성

각 조직(ISP, 기업, 대학)은 자신의 네트워크 내부 라우팅을 독립적으로 관리하고자 합니다. 사용하는 라우팅 알고리즘, 정책, 장비를 자유롭게 선택할 수 있어야 합니다.

계층적 라우팅 구조
====================

[AS 1: KT]          [AS 2: SKT]         [AS 3: Google]
+-----------+       +-----------+       +-----------+
| R1---R2   |       | R5---R6   |       | R8---R9   |
| |    |    |<----->|  |   |    |<----->|  |   |    |
| R3---R4   |       | R7       |       | R10--R11  |
+-----------+       +-----------+       +-----------+

AS 내부: OSPF, RIP 등 (intra-AS routing)
AS 간:   BGP (inter-AS routing)

2. 자율 시스템 (Autonomous System)

2.1 AS의 정의

자율 시스템(AS)은 동일한 라우팅 정책 하에 관리되는 라우터들의 그룹입니다. 각 AS는 고유한 AS 번호(ASN)를 가집니다.

AS 유형
=========

1. Stub AS: 하나의 다른 AS와만 연결 (기업, 대학)
   [외부] <---> [Stub AS]

2. Multihomed AS: 여러 AS와 연결되지만 트래픽 통과 불가
   [AS A] <---> [Multihomed AS] <---> [AS B]

3. Transit AS: 트래픽이 통과할 수 있는 AS (ISP)
   [AS A] <---> [Transit AS] <---> [AS B]
                    통과 허용

2.2 게이트웨이 라우터

게이트웨이 라우터(Gateway Router)는 다른 AS에 속한 라우터와 직접 연결된 라우터입니다. AS 내부 라우팅과 AS 간 라우팅 모두를 수행합니다.


3. RIP (Routing Information Protocol)

3.1 기본 특성

RIP는 Distance-Vector 알고리즘을 기반으로 하는 AS 내부 라우팅 프로토콜입니다.

RIP 특성
=========

- 알고리즘: Distance-Vector (벨만-포드)
- 메트릭: 홉 수 (hop count), 최대 15홉
- 업데이트 주기: 30초마다 이웃에게 거리 벡터 전송
- 타임아웃: 180초 동안 업데이트 없으면 경로 무효화
- 전송 방식: UDP 포트 520
- 적합 범위: 소규모 네트워크 (15홉 제한)

3.2 RIP의 한계

  • 최대 15홉으로 대규모 네트워크에 부적합
  • 수렴이 느림 (count-to-infinity 가능)
  • 홉 수만 메트릭으로 사용하여 대역폭 차이를 반영 못함

4. OSPF (Open Shortest Path First)

4.1 기본 특성

OSPF는 Link-State 알고리즘을 기반으로 하는 AS 내부 라우팅 프로토콜입니다. RIP의 한계를 극복하기 위해 설계되었습니다.

OSPF 특성
==========

- 알고리즘: Link-State (다익스트라)
- 메트릭: 대역폭, 지연 등 관리자가 설정 가능
- 업데이트: 변경 시 즉시 (또는 30분 주기)
- 전송 방식: IP 직접 (프로토콜 번호 89)
- 인증: MD5 인증 지원
- 적합 범위: 대규모 네트워크

4.2 OSPF의 주요 장점

보안: OSPF 메시지는 인증될 수 있어서, 신뢰할 수 있는 라우터만 라우팅에 참여합니다.

다중 경로 (Equal-Cost Multipath): 같은 비용의 경로가 여러 개 있으면 트래픽을 분산시킬 수 있습니다.

계층적 구조: 하나의 AS를 여러 영역(Area)으로 나눌 수 있습니다.

OSPF 계층적 구조
==================

             [백본 영역 (Area 0)]
            /         |          \
     [영역 1]    [영역 2]    [영역 3]
     +------+   +------+    +------+
     |R1  R2|   |R4  R5|    |R7  R8|
     |  R3  |   |  R6  |    |  R9  |
     +------+   +------+    +------+

- 백본 영역 (Area 0): 모든 영역을 연결하는 중심 영역
- 영역 경계 라우터 (ABR): 두 영역에 걸쳐 있는 라우터
- AS 경계 라우터 (ASBR): 다른 AS와 연결된 라우터

4.3 OSPF 영역 라우팅

OSPF 영역 간 라우팅
=====================

영역 1의 R1에서 영역 3의 R9로 패킷 전송:

  R1 (영역 1)
    |
    | 영역 1 내부 OSPF 라우팅
    v
  ABR1 (영역 1 / 백본 경계)
    |
    | 백본(Area 0) OSPF 라우팅
    v
  ABR3 (백본 / 영역 3 경계)
    |
    | 영역 3 내부 OSPF 라우팅
    v
  R9 (영역 3)

각 영역 내부: 상세 토폴로지 정보 교환
영역 간: 요약된 거리 정보만 교환

5. BGP (Border Gateway Protocol)

5.1 BGP의 역할

BGP는 인터넷에서 AS 간 라우팅을 담당하는 유일한 프로토콜입니다. 인터넷의 모든 AS를 서로 연결하는 "인터넷의 접착제" 역할을 합니다.

BGP의 두 가지 형태
====================

1. eBGP (External BGP): 서로 다른 AS의 라우터 간
   AS1의 게이트웨이 <---eBGP---> AS2의 게이트웨이

2. iBGP (Internal BGP): 같은 AS 내부의 라우터 간
   AS1의 게이트웨이 <---iBGP---> AS1의 내부 라우터

eBGP: AS 간 경로 정보 교환
iBGP: 학습한 경로 정보를 AS 내부에 전파

5.2 BGP 경로와 속성

BGP에서 경로는 목적지 프리픽스와 경로 속성(Path Attributes)의 조합입니다.

BGP 경로 광고 예시
====================

AS2가 AS1에게 광고:
  프리픽스: 138.16.64.0/24
  AS-PATH: AS3 AS2
  NEXT-HOP: 201.44.13.1

주요 경로 속성:
  - AS-PATH: 경로가 통과하는 AS 목록
    예: AS3 AS2 --> AS2를 거쳐 AS3에 도달
  - NEXT-HOP: 다음 AS로 향하는 게이트웨이 라우터의 IP 주소
  - LOCAL-PREF: AS 내부에서 경로 선호도 (높을수록 선호)
  - MED: 다른 AS에게 선호 경로를 알리는 값 (낮을수록 선호)

5.3 BGP 경로 선택 알고리즘

여러 경로가 존재할 때 BGP는 다음 순서로 최선의 경로를 선택합니다.

BGP 경로 선택 우선순위
========================

1. LOCAL-PREF 가장 높은 경로 (정책 기반)
2. AS-PATH 가장 짧은 경로
3. NEXT-HOP에 가장 가까운 경로 (Hot-Potato 라우팅)
4. BGP 식별자가 가장 작은 경로

예시:
  경로 A: LOCAL-PREF=200, AS-PATH=[AS2, AS5], NEXT-HOP=R1
  경로 B: LOCAL-PREF=100, AS-PATH=[AS3], NEXT-HOP=R2

  --> 경로 A 선택 (LOCAL-PREF가 더 높음)

5.4 Hot-Potato 라우팅

Hot-Potato 라우팅은 패킷을 가능한 빨리 자신의 AS 밖으로 보내는 전략입니다. AS 내부 비용만 고려하여 가장 가까운 게이트웨이를 선택합니다.

Hot-Potato 라우팅
==================

AS1 내부:

        iBGP          iBGP
[R1] <-------> [R2] <-------> [R3]
 |              |               |
 | 내부비용 2   | 내부비용 5    | 내부비용 3
 |              |               |
[GW1]          [GW2]          [GW3]
 |eBGP          |eBGP          |eBGP
 v               v               v
[AS2]          [AS3]          [AS2]

R2가 AS2의 프리픽스에 도달하려면:
  - GW1 경유: 내부비용 2 (R2->R1->GW1)
  - GW3 경유: 내부비용 3 (R2->R3->GW3)
  --> GW1 선택 (Hot-Potato: 가장 가까운 출구)

6. BGP 라우팅 정책

6.1 고객-제공자-피어 관계

AS 간 관계
============

         [Tier-1 ISP A] <--피어링--> [Tier-1 ISP B]
          /          \                /          \
    제공자          제공자       제공자         제공자
      /                \          /                \
[고객 AS1]       [고객 AS2] [고객 AS3]       [고객 AS4]

- 고객은 제공자에게 비용을 지불하고 트래픽 전달을 받음
- 피어는 서로의 고객 트래픽을 무료로 교환
- 제공자는 고객의 경로를 다른 곳에 광고

6.2 라우팅 정책 규칙

BGP 정책 규칙
===============

AS X의 입장에서:

1. 고객으로부터 받은 경로: 모든 곳에 광고 (수익 발생)
2. 피어로부터 받은 경로: 고객에게만 광고 (피어나 제공자에게는 광고하지 않음)
3. 제공자로부터 받은 경로: 고객에게만 광고 (피어나 다른 제공자에게는 광고하지 않음)

원칙: 트래픽이 자신을 통과하면 비용이 발생하므로,
      수익이 되는 고객 트래픽만 적극적으로 중계

7. OSPF와 BGP의 상호작용

실제 라우터에서는 OSPF와 BGP가 함께 동작합니다.

OSPF와 BGP 상호작용
=====================

AS 내부:
  - OSPF가 AS 내부 라우터 간 최단 경로 계산
  - 각 라우터는 AS 내부의 모든 목적지에 대한 경로를 알고 있음

AS 간:
  - eBGP로 외부 AS의 프리픽스 정보를 학습
  - iBGP로 학습한 정보를 AS 내부에 전파
  - NEXT-HOP까지의 경로는 OSPF가 제공

포워딩 테이블 구성:
  목적지 프리픽스 | 다음 홉      | 출처
  ----------------+-------------+-------
  10.1.0.0/16    | 192.168.1.2 | OSPF
  172.16.0.0/12  | 192.168.1.5 | OSPF
  8.8.8.0/24     | 10.0.0.1    | BGP
  0.0.0.0/0      | 10.0.0.1    | BGP

8. 정리

개념핵심 내용
계층적 라우팅AS 단위로 내부/외부 라우팅 분리
RIPDV 기반, 홉 수 메트릭, 최대 15홉, 소규모
OSPFLS 기반, 유연한 메트릭, 영역 계층화, 대규모
eBGPAS 간 경로 정보 교환
iBGPAS 내부로 외부 경로 정보 전파
AS-PATHBGP 경로가 통과하는 AS 목록
Hot-Potato가장 가까운 출구로 트래픽을 보내는 전략
LOCAL-PREFBGP 경로 선택의 최우선 기준 (정책 반영)

다음 글에서는 네트워크 스택의 한 계층 아래인 링크 계층의 오류 검출과 다중 접속 프로토콜을 살펴보겠습니다.


참고 자료

  • James F. Kurose, Keith W. Ross, "Computer Networking: A Top-Down Approach", 6th Edition, Chapter 4
  • RFC 2328 - OSPF Version 2
  • RFC 4271 - A Border Gateway Protocol 4 (BGP-4)
  • RFC 2453 - RIP Version 2

[Computer Networking] 14. Internet Routing: OSPF and BGP

Internet Routing: OSPF and BGP

The real Internet is a massive network consisting of billions of devices. Computing routes for the entire Internet with a single routing algorithm is impossible from both scalability and management perspectives.

In this post, we examine how the Internet performs hierarchical routing at the Autonomous System (AS) level, intra-AS routing protocols RIP and OSPF, and the inter-AS routing protocol BGP.


1. Need for Hierarchical Routing

1.1 Scalability Problem

If all routers stored and computed the topology of the entire Internet:

  • Storage: Forwarding tables for billions of destinations
  • Computation: Running routing algorithms on the full topology
  • Message Overhead: Link state updates propagating worldwide

1.2 Administrative Autonomy

Each organization (ISP, enterprise, university) wants to independently manage its internal network routing. They should be free to choose their own routing algorithms, policies, and equipment.

Hierarchical Routing Structure
================================

[AS 1: ISP-A]          [AS 2: ISP-B]         [AS 3: Google]
+-----------+          +-----------+          +-----------+
| R1---R2   |          | R5---R6   |          | R8---R9   |
| |    |    |<-------->|  |   |    |<-------->|  |   |    |
| R3---R4   |          | R7        |          | R10--R11  |
+-----------+          +-----------+          +-----------+

Intra-AS: OSPF, RIP, etc. (intra-AS routing)
Inter-AS: BGP (inter-AS routing)

2. Autonomous System (AS)

2.1 Definition of AS

An Autonomous System (AS) is a group of routers managed under the same routing policy. Each AS has a unique AS Number (ASN).

AS Types
=========

1. Stub AS: Connected to only one other AS (enterprises, universities)
   [External] <---> [Stub AS]

2. Multihomed AS: Connected to multiple ASes but no transit traffic
   [AS A] <---> [Multihomed AS] <---> [AS B]

3. Transit AS: AS that allows traffic to pass through (ISPs)
   [AS A] <---> [Transit AS] <---> [AS B]
                    Transit allowed

2.2 Gateway Router

A Gateway Router is a router directly connected to a router belonging to another AS. It performs both intra-AS routing and inter-AS routing.


3. RIP (Routing Information Protocol)

3.1 Basic Characteristics

RIP is an intra-AS routing protocol based on the Distance-Vector algorithm.

RIP Characteristics
=====================

- Algorithm: Distance-Vector (Bellman-Ford)
- Metric: Hop count, maximum 15 hops
- Update interval: Sends distance vector to neighbors every 30 seconds
- Timeout: Route invalidated if no update for 180 seconds
- Transport: UDP port 520
- Suitable scope: Small networks (15 hop limit)

3.2 Limitations of RIP

  • Maximum of 15 hops makes it unsuitable for large networks
  • Slow convergence (count-to-infinity possible)
  • Uses only hop count as metric, cannot reflect bandwidth differences

4. OSPF (Open Shortest Path First)

4.1 Basic Characteristics

OSPF is an intra-AS routing protocol based on the Link-State algorithm. It was designed to overcome the limitations of RIP.

OSPF Characteristics
======================

- Algorithm: Link-State (Dijkstra)
- Metric: Bandwidth, delay, etc. configurable by administrator
- Updates: Immediately on change (or 30-minute periodic)
- Transport: IP directly (protocol number 89)
- Authentication: MD5 authentication supported
- Suitable scope: Large networks

4.2 Key Advantages of OSPF

Security: OSPF messages can be authenticated, ensuring only trusted routers participate in routing.

Equal-Cost Multipath: When multiple paths with the same cost exist, traffic can be distributed.

Hierarchical Structure: A single AS can be divided into multiple areas.

OSPF Hierarchical Structure
==============================

             [Backbone Area (Area 0)]
            /         |          \
     [Area 1]    [Area 2]    [Area 3]
     +------+   +------+    +------+
     |R1  R2|   |R4  R5|    |R7  R8|
     |  R3  |   |  R6  |    |  R9  |
     +------+   +------+    +------+

- Backbone Area (Area 0): Central area connecting all areas
- Area Border Router (ABR): Router spanning two areas
- AS Boundary Router (ASBR): Router connected to another AS

4.3 OSPF Inter-Area Routing

OSPF Inter-Area Routing
=========================

Sending packet from R1 in Area 1 to R9 in Area 3:

  R1 (Area 1)
    |
    | Area 1 internal OSPF routing
    v
  ABR1 (Area 1 / Backbone boundary)
    |
    | Backbone (Area 0) OSPF routing
    v
  ABR3 (Backbone / Area 3 boundary)
    |
    | Area 3 internal OSPF routing
    v
  R9 (Area 3)

Within each area: Detailed topology information exchanged
Between areas: Only summarized distance information exchanged

5. BGP (Border Gateway Protocol)

5.1 Role of BGP

BGP is the only protocol responsible for inter-AS routing on the Internet. It serves as the "glue of the Internet," connecting all ASes together.

Two Forms of BGP
==================

1. eBGP (External BGP): Between routers of different ASes
   AS1 gateway <---eBGP---> AS2 gateway

2. iBGP (Internal BGP): Between routers within the same AS
   AS1 gateway <---iBGP---> AS1 internal router

eBGP: Exchanges route information between ASes
iBGP: Propagates learned route information within the AS

5.2 BGP Routes and Attributes

In BGP, a route is a combination of a destination prefix and path attributes.

BGP Route Advertisement Example
==================================

AS2 advertises to AS1:
  Prefix: 138.16.64.0/24
  AS-PATH: AS3 AS2
  NEXT-HOP: 201.44.13.1

Key Path Attributes:
  - AS-PATH: List of ASes the route traverses
    Example: AS3 AS2 --> reaches AS3 via AS2
  - NEXT-HOP: IP address of gateway router toward next AS
  - LOCAL-PREF: Route preference within AS (higher is preferred)
  - MED: Value indicating preferred route to other ASes (lower is preferred)

5.3 BGP Route Selection Algorithm

When multiple routes exist, BGP selects the best route in the following order:

BGP Route Selection Priority
==============================

1. Highest LOCAL-PREF (policy-based)
2. Shortest AS-PATH
3. Closest NEXT-HOP (Hot-Potato routing)
4. Smallest BGP identifier

Example:
  Route A: LOCAL-PREF=200, AS-PATH=[AS2, AS5], NEXT-HOP=R1
  Route B: LOCAL-PREF=100, AS-PATH=[AS3], NEXT-HOP=R2

  --> Route A selected (higher LOCAL-PREF)

5.4 Hot-Potato Routing

Hot-Potato routing is a strategy of sending packets out of your own AS as quickly as possible. It selects the nearest gateway considering only intra-AS costs.

Hot-Potato Routing
====================

Inside AS1:

        iBGP          iBGP
[R1] <-------> [R2] <-------> [R3]
 |              |               |
 | Internal     | Internal      | Internal
 | cost 2       | cost 5        | cost 3
 |              |               |
[GW1]          [GW2]          [GW3]
 |eBGP          |eBGP          |eBGP
 v               v               v
[AS2]          [AS3]          [AS2]

For R2 to reach a prefix in AS2:
  - Via GW1: internal cost 2 (R2->R1->GW1)
  - Via GW3: internal cost 3 (R2->R3->GW3)
  --> GW1 selected (Hot-Potato: nearest exit)

6. BGP Routing Policies

6.1 Customer-Provider-Peer Relationships

Inter-AS Relationships
========================

         [Tier-1 ISP A] <--Peering--> [Tier-1 ISP B]
          /          \                /          \
    Provider       Provider     Provider       Provider
      /                \          /                \
[Customer AS1]   [Customer AS2] [Customer AS3] [Customer AS4]

- Customers pay providers for traffic delivery
- Peers exchange customer traffic for free
- Providers advertise customer routes elsewhere

6.2 Routing Policy Rules

BGP Policy Rules
==================

From the perspective of AS X:

1. Routes received from customers: Advertise to everyone (revenue generating)
2. Routes from peers: Advertise only to customers (not to peers or providers)
3. Routes from providers: Advertise only to customers (not to peers or other providers)

Principle: Traffic passing through incurs costs,
           so only actively relay customer traffic that generates revenue

7. Interaction Between OSPF and BGP

In practice, OSPF and BGP work together on routers.

OSPF and BGP Interaction
===========================

Intra-AS:
  - OSPF computes shortest paths between routers within the AS
  - Each router knows routes to all destinations within the AS

Inter-AS:
  - eBGP learns prefix information from external ASes
  - iBGP propagates learned information within the AS
  - Route to NEXT-HOP is provided by OSPF

Forwarding Table Composition:
  Destination Prefix | Next Hop     | Source
  -------------------+--------------+-------
  10.1.0.0/16        | 192.168.1.2  | OSPF
  172.16.0.0/12      | 192.168.1.5  | OSPF
  8.8.8.0/24         | 10.0.0.1     | BGP
  0.0.0.0/0          | 10.0.0.1     | BGP

8. Summary

ConceptKey Points
Hierarchical RoutingSeparates internal/external routing at AS level
RIPDV-based, hop count metric, max 15 hops, small scale
OSPFLS-based, flexible metrics, area hierarchy, large scale
eBGPExchanges route information between ASes
iBGPPropagates external route info within the AS
AS-PATHList of ASes a BGP route traverses
Hot-PotatoStrategy of sending traffic to nearest exit
LOCAL-PREFTop priority criterion in BGP route selection (policy)

In the next post, we will look one layer down the network stack at the link layer's error detection and multiple access protocols.


References

  • James F. Kurose, Keith W. Ross, "Computer Networking: A Top-Down Approach", 6th Edition, Chapter 4
  • RFC 2328 - OSPF Version 2
  • RFC 4271 - A Border Gateway Protocol 4 (BGP-4)
  • RFC 2453 - RIP Version 2