본문 바로가기
Computer Network/컴퓨터네트워크

[컴퓨터네트워크] 1108

by leziwn.cs 2023. 11. 10.
IPv4 fragmentation, reassembly

IPv4 fragmentation, reassembly

IPv4 datagram은 Ethernet frame에서 보통 1,500 byte를 전송할 수 있지만, 중간에 wide-area link에서 MTU 크기가 줄어들기 때문에, 그 링크를 통과하기 위해, fragmentation이 일어난다.

Datagram이 fragmentated되면 header가 늘어나기 때문에 오버헤드가 발생한다.

하지만 이러한 fragmentated된 datagram은 중간에 reassemble되지 않고, 마지막에 목적지 host에서 reassemble된다.

 

IPv4 fragmentation at router: example

IPv4 fragmentation at router: example

보내야 하는 datagram의 길이는 4000 byte인데, MTU가 1500 byte라고 가정하자.

따라서 이 큰 datagram은 3개의 fragment로 쪼개진다.

  • length: Fragment의 길이는 1500 byte인데, 이 중 20 byte는 고정 길이 헤더이고, 나머지 1480 byte가 data이다.
  • ID: ID는 같은 datagram임을 나타내야 하므로, x로 같다.
  • fragflag: fragflag가 1이면, 뒤에 따라오는 나머지 datagram이 있음을 나타내고, fragflag 값이 0이면, 그것이 마지막 datagram임을 의미한다.
  • offset: (앞선 fragment의 데이터 길이/8) 값을 적는다. 그리고 이 값은 누적되므로, 나중의 fragment에는 앞선 offset을 누적해줘야 한다.

 

Fragmentation: example

Fragmentation: example

2400 byte의 datagram을 보내야 하고, MTU는 700 byte라고 가정하자.

2400 byte의 datagram 중 20 byte는 헤더, 나머지 2380 byte가 데이터이다.

MTU가 700이므로, (2380/700 = 3.xx). 따라서, 4개의 fragment가 필요하다.

  • Total datagram length: 700 bytes
  • ID: 같다.
  • Frag.Flag: 마지막은 0, 나머지는 1
  • offset: (680/8 = 85)를 누적해서 적는다.

 


4.3.2 IPv4 addressing

IP 주소 addressing에 대해 배울 때는, 전체 IP 주소가 부족하다는 것을 꼭 기억해야 한다. 예전에 비해 device 수가 늘어남에 따라, IP 주소가 더 많이 필요해졌기 때문이다.

 

IPv4 addressing: introduction

IPv4 addressing: introduction

IP 주소는 device마다 할당된다고 많이들 생각하지만, 사실 router와 host의 interface에 할당되는 것이다.

  • Router는 보통 multiple interface를 가지고 있다.
  • Host는 보통 하나 또는 두 개의 interface를 가지고 있다: Ethernet, wireless WiFi

▶ dotted-decimal IP address: 8비트를 10진수로 표시한다.

 

Q. 그렇다면 이러한 interface들은 실제로 어떻게 연결되어 있을까?

A. link layer에 연결되어 있다: Ethernet switches, WiFi base station

  • Wired Ethernet interfaces: connected by Ethernet switches.
  • Wireless WiFi interfaces: connected by WiFi base station.

 

 

Subnets

Subnets

▶ Subnet

: Device interfaces with same subnet part of IP address can physically reach each other without intervening router.

--> 즉, router의 개입 없이 연결된 인터넷의 집합이다.

 

▶ IP address structure: subnet part + host part

IP address structure: subnet part + host part

--> IP 주소는 subnet part와 host part로 나뉘어 있기 때문에, subnet part를 subnet mask로 표현해준다.

  • 같은 subnet에 속하면, subnet part를 서로 공유한다.

 

 

IPv4 addressing

IPv4 addressing 방법에는 subnet part의 길이를 미리 정해놓는 방식과, 가변 길이를 이용하는 방식(CIDR)이 있다.

 

IPv4 careful addressing

IPv4 careful addressing

이 방법에서는 class를 5가지로 구분하고, first high bits 몇 개를 이용하여 class를 식별할 수 있도록 한다.

A class의 경우, subnet part가 8 bit이다. 따라서 A class에 속할 수 있는 주소의 수는 적고, A class 내에서는 다양한 주소를 생성할 수 있다. 따라서 subnet 규모가 큰 경우, A class를 이용한다.

  • Number of Networks = 2^(subnet part - 1) - 2
  • Hosts per Network = 2^(32 - subnet part) - 2

이러한 고정 길이 subnet part 방식은, 주소의 낭비가 심하다는 단점이 있다. 예를 통해 그 이유를 설명하겠다.

C class의 경우, subnet의 규모가 너무 작다. 반면 B class의 경우, subnet 규모가 크다. 사용자 입장에서는 subnet 규모가 큰 것이 모자라는 것보다는 나으므로, 주로 B class를 자주 이용한다. 하지만 이 거대한 B class의 subnet은 종종 사용되지 않는다. 즉, 낭비되는 것이다.

 

IPv4 careless addressing: CIDR

따라서 대안으로 제시된 방법이 CIDR 방법이다. 

이 방식에서는 subnet part의 길이를 가변 길이로 설정한다. 따라서 아래와 같이 subnet part를 표시해 주어야 한다.

IPv4 careless addressing: CIDR

 

 

CDIR example

 

CDIR example

 


IP addresses: how to get one?

그렇다면, 이러한 IP 주소는 어떻게 얻을까?

 

Q1. host는 network 내에서 어떻게 IP 주소를 얻을까?

  • hard-coded by system admin in a configuration file. 
  • DHCP (Dynamic Host Configuration File)

Q2. Network는 어떻게 IP 주소를 얻을까? (subnet part of address)

 

 

IP addresses: How does host get IP address?

▶ hard-coded by system admin in a configuration file.

 

DHCP (Dynamic Host Configuration File)

: host가 server에서 일시적으로 쓸 IP 주소를 받아오는 방식이다.

  • 이때, client와 server 모두 well-know port 번호를 이용한다.

 

 

DHCP (Dynamic Host Configuration File)

: Host가 network로부터 IP 주소를 dynamic하게 받아온다.

--> IP 주소의 재사용이 가능하고, mobile user에게 유리하다.

 

 DHCP overview: 4개의 message

  1. Client: host broadcast DHCP discover message. (optional)
  2. Server: DHCP server responds with DHCP offer message. (optional)
  3. Client: host requests IP adddress -- DHCP request message
  4. Server: DHCP server sends address -- DHCP ack message

 

 

DHCP client-server scenario

DHCP client-server scenario

  1. DHCP client: DHCP discover - DHCP server 거기 있니?
  2. DHCP server: DHCP offer - 이 IP 주소를 써보는게 어때?
  3. DHCP client: 좋아, 나 그 주소 쓸게!
  4. DHCP server: 그래, 이 주소 너꺼 해.

 

 

DHCP: more than IP addressing

DHCP는 IP 주소 이외에도 다른 정보들을 보내준다.

  • DNS server의 IP 주소
  • Address of first-hop router (default gateway) for client
  • Network mask (subnet part)

 

 

DHCP: example

DHCP: example

  1. DHCP client가 DHCP server에게 DHCP request를 broadcast한다.
  2. DHCP server가 DHCP ACK으로 응답한다.

이때, DHCP ACK에는 client의 IP 주소뿐만 아니라, 

name and IP address of DNS server, IP address of its first-hop router를 포함한다.

 

 

 

 

 

출처: 이화여자대학교 이미정교수님 컴퓨터네트워크