ggoggo
4.3 Internet Protocol 본문
네트워크 계층의 3개의 주요요소
1) IP protocol
- 주소체계 규약
- 데이터그램 포맷
- 패킷 핸들링 규약
2) Routing protocols
- 경로선택
- RIP, OSPF, BGP
3) ICMP protocol
- 오류 보고
- 라우터'시그널링'
1. Key fields in the IPv4 Datagram
네트워크 계층 패킷을 Datagram이라 함.
- Version number (4bits)
4(0100): IP version 4
6(0110): IP version 6
- Header length(4bits)
The number of bytes in the header.(IP 데이터그램에서 실제 데이터가 시작하는 곳을 결정)
대체로 20byte
- Type of service(TOS)(1byte)
- Different types such as real-time traffic, non-real-time traffic
- Mostly not implemented
- Datagram length(2bytes)
- The number of bytes in the header and the data.
- 이론상 최대 65,535 바이트, 1,500바이트보다 큰 경우 드뭄.
- Time-to-live(TTL)(1byte)
- Specify how long the datagram is allowed to live on the network
- Decremented by one each time the datagrma is processed by a router
- If the TTL field reaches 0, a router must drop that datagram
데이터그램이 네트워크에서 무한히 순환하지는 않음을 보장.
라우터가 데이터그램을 처리할 떄마다 감소하고 TTL필드값이 0이 되면 데이터그램 폐기
- Protocol(1byte)
- Indicate the specify transport-layer protocol
- Typically used only when an IP datagram reached its final destination
IP데이터그램이 최종 목적지에 도착했을 떄만 사용됨.
IP데이타그램에서 데이터 부분이 전달될 목적지의 트랜스포트 계층 프로토콜을 명시함.
ex) 6 ->TCP, 17 -> UDP로 전달하라
- Header checksum(2bytes)
- Aid a router in detecting bit errors in a received IP datagram
- Computed by treating each 2 bytes in the header as a number and summing these numbers using 1s complement arithmetic
- 1s complement of this sum is stored
라우터가 IP 데이터그램을 받을 떄 비트 오류 감지에 도움
헤더 체크섬 : 헤더에서 각 2바이트를 수로 생각하고 이 수들의 1의 보수를 합산하여 계산한 것
라우터는 수신하는 IP데이터그램마다 인터넷 체크섬을 계산하고 이 값과 데이터그램의 체크섬이 다르면 오류 상태임을 검출
- Source IP address(4bytes)
자신의 IP주소를 출발지로
- Destination IP address(4bytes)
목적지 IP주소는 DNS 검색을 통해 결정
- Options(variable)
Rarely used
- Data(payload)
Include the upper-later data such as TCP segment, UDP segment
IP 데이터 그램의 데이터 필드는 목적지에 배달하기 위해 트랜스포트 계층 세그먼트(TCP or UDP)를 포함하지만 ICMP메시지와 같은 데이터 형태를 담기도 함.ㅌ`
2. IPv4 Datagram fragmentation
- MTU(Maximum transmission unit)
The maximum amout of data that a link-layer frame can carry
링크 계층 패킷이 전달할 수 있는 최대 양
- Link-layer protocls can hava different MTUs.
- A router needs to fragment a datagram
- Note : Datagram reassembly is done in the end systems
fragmentation 하는 이유?
-> MTU(Maximum Trasmission Unit = R)보다 크면 쪼개서 보내야함
왜 IPv4 reassembly는 서로 다른 MTU size 때문에, host에서 내려온 UDP Datagram을 IP 계층에서 fragmentation한 패킷들을 다시 작업을 중간 라우터나 마지막 라우터가 아닌 dest host의 IP 계층에서 해야할까?
- Packet switching은 packet by packet switching이라 각 sub packet들이 지나가는 경로가 다 다르기 때문에 individual하게 모든 라우터들을 지남. 이론 상 하나의 라우터로 지나간다고 보장할 수 없기 때문에 중간 라우터에서 합칠 수 없음.
- 맨 마지막 라우터에서 합치면 되지 않을까? Internet의 철학. core networl는 가능한 복잡한 일을 안 하고, simple하게 빨리 deliver하는 것이 목표, 복잡한 것은 host
- Header fields for fragmentation
Identifier(2bytes)
- when a datagram is created, the sending host stamps the datagram with an identificaiton number
- A fragment has the same identification number
데이터그램 생성 시 sending host는 데이터그램 식별 번호 찍음
fragment는 데이터그램과 같은 식별번호 가짐
Flags(3bits)
- The last fragment has a flag but set to 0
- All the other fragments have this flag but set to 1
플래그 모두 1, 마지막만 0
Fragmentation offset(13bits) - unit of 8 bytes
- Specify the offset, or position, in the overall message where the data in this fragment goes
- Determine whether a fragment is missing
- Reassemble the fragments in their proper order
전체 메시지에서 fragment의 data 위치(얼마나 떨어져 있는지)
fragment누락 확인
올바른 순서로 fragment 재조합
3. IPv4 addressing
- IPv4 address
- 32 bits long, typically written in dotted-decimal notation
- Associated with an interface, rather than with the host or router
모든 호스트와 라우터는 IP 데이터그램을 보내고 받을 수 있으므로 IP는 IP주소를 갖는 각 호스트와 라우터의 인터페이스가 필요
* 인터페이스 : 호스트와 링크 사이의 경계 , 라우터와 링크 사이의 경계
- 용어
Subnet
- A network interconnecting interfaces without a router
라우터 없이 인터페이스를 연결하는 네트워크
Subnet mask
- Indicate a protion for the subnet address in the IPv4 address
서브넷 주소 보호
서브넷 주소 : 200.23.16.0/24
서브넷 마스크 : /24
32비트 주소의 왼쪽 24비트가 서브넷 주소라는 것을 가리킨다.
→ 6개의 서브넷을 연결하는 3개의 라우터
서브넷을 결정하기 위하여,
1) 먼저 호스트나 라우터에서 각 인터페이스를 분리하여 고립된 네트워크를 만든다.
2) 이 고립된 네트워크의 종단점은 인터페이스의 끝
3) 고립된 네트워크 각각 = 서브넷
- 인터넷 주소 할당 방식
Classful addressing
- before CIDR was adopted, the subnet parts were constrained to be 8(class A), 16(class B), or 24(class C) bits in length.
문제점
: C클래스(/24)서브넷은 254개의 host만을 제공하므로 많은 조직을 위해서는 부족.
: B클래스(/16) 서브넷은 65,634개의 host제공. 너무 큼. 다른 조직이 사용할 수도 없음
CIDR(Classless Interdomain Routing) [RFC 4632]
- a.b.c.d/x
- x is the number of bits in subnet portion of address = <prefix>
ex) a.b.c.d/21
첫 21비트들은 기관의 네트워크 프리픽스를 나타내고 이 기관의 모든 장비의 IP 주소에 공통됨
나머지 11비트들은 기관 내부의 특정 host들을 식별
Desination-based Forwarding
- Longest Prefix Matching
When there are multiple matches,
The router uses the longest prefix matching to determine the link interface to which the packet is forwarded.
일치항목이 여러개일 경우 라우터는 패킷이 전달되는 링크 인터페이스를 결정하기 위해 가장 긴 접두사 일치를 사용
IP broadcast address
- When a host sends a datagram with destination address 255.255.255.255,
the message is delivered to all hosts on the same subnet.
- Router optionally forward the message into neighboring subnets as well.
호스트의 dest 주소가 255.255.255.255이면 동일 subnet의 모든 host에게 메시지 전달
라우터가 선택적으로 인점 sbunet에 메시지 전달하기도!
Obtaining a Block of Addresses
기관의 subnet에서 사용하기 위한 IP 주소 블록을 얻기 위해, 네트워크 관리자는 먼저 이미 할당받은 주소의 큰 블록에서 주소를 제공하는 ISP와 접촉해야함
- ICANN(Internet Corporation for Assigned Names and Numbers)
: 비영리 단체
: Allocate IP addresses
: Manage the DNS root servers
: Assigning domain names and resolving domain name disputes
도메인 이름 할당 & 분쟁 해결
ex) ISP는 주소블록 200.23.16.0/20dmf gkfekdqkedma
ISP는 이 주소 블록을 작은 주소 블록 8개로 나누고 이것으로 8개 조직을 지원 가능함.
*ISP(Internet Service Provider) : 개인이나 기업체엑 인터넷 서비스, 웹사이트 구축 및 웹호스팅 서비스 등을 제공하는 회사( ex. KT, SK브로드밴드, LGU+)
Obtaing a Host Address : DHCP
- DHCP(Dynamic host configuration protocol)
: Allow a host to obtain an IP address automatically
: Provide additional information about the subnet mask, the address of its first-hop router, the address of its local DNS server.
: A client-server protocol at an application layer
호스트가 IP 주소를 자동으로 얻도록 허용
subnet mask, first-hop router의 주소, locla DNS server의 주소에 대한 추가 정보를 제공
애플리케이션 계층에서 클라이언트-서버 프로토콜
- DHCP Client-Server Interaction
1) use UDP
Server port num : 67
Client port num : 68
2) Several DHCP servers may respond
3) yiaddrr : the address being allocated to the client
4) Lifetime : the amount of time for which the address will be valid
<DHCP 프로토콜 4단계>
1) DHCP server discover : 새롭게 도착한 호스트는 상호 동작될 DHCP를 발견
255.255.255.255를 사용해 서브넷에 연결된 모든 노드로 전송
2) DHCP server offer(s) : DHCP 발견 메시지를 받은 DHCP 서버는 DHCP 제공 메세지를 클라이언트로 응답
255.255.255.255를 사용해 서브넷의 모든 노드로 이 메시지를 브로그 캐스트. 서브넷에는 여러 DHCP 서버가 존재하기 때문에 클라이언트는 여러 DHCP 제공 메시지로부터 가장 최적의 위치에 DHCP를 선택.
yiaddrr 전송
3) DHCP request : 서버 제공자 선책하여 응답.
yiaddrr로 응답
4) DHCP ACK : 클라이언트가 ack 받으면 상호동작은 종료 & 클라이언트는 할당 IP주소를 lifetime동안 사용 가능
4. Network address translation
- Movitation
What if there are multiple IP devices that need IP address, but the ISP allocates a small number of IP addresses only?
IP주소가 많이 필요한데 ISP에서 IP주소를 적게 할당해주면??
- NAT
- Using NAT-enabled router, the private addresses can be used within the home network
홈 네트워크 내에서 개인 주소 사용
- NAT 사용이유
- 모든 IP-capable device는 public routable IP address가 필요
- IP에게 너무 많은 범위의 IP를 받을 필요가 없고 just one IP address for all devices가 필요할 때
- 주소가 노출이 안되니 security 보장, 공격 받지x
- 내 local network안에서 device의 주소를 마음껏 바꿀 수 있고, 상위 ISP에게 알려줄 필요도 없음
- Operation
ex)
외부로는 privae IP address로 나갈 수 없음. 10.0.0.-/24는 전세계에 엄청 많을 수 있음.
1) 호스트 10.0.0.1(임의 포트번호 3345)인 홈 네트워크가 IP 주소 128.119.40.186인 웹서버(포트80) 에게 웹페이지 요청
& LAN에 데이터그램 전송(*LAN : local area network, 근거리 통신망)
2) NAT라우터는 데이터그램을 받아 새로운 출발지 포트번호 5001을 생성하고, WAN쪽 IP주소 138.76.29.7과 출발지 IP주소를 교체(*WAN : wide area network, 광역 통신망)
3) NAT 라우터에 의해 처리된 HTTP 요청이 들어 있는 데이터그램의 도착을 의식하지 못한 웹 서버는 NAT 라우터의 IP주소인 목적지 주소와 5001인 목적지 포트 번호에 대해 응답
4) 데이터 그램이 NAT라우터에 도착하면 라우터는 홈 네트워크 브라우저의 IP주소(10.0.0.1)와 목적지 포트 번호(3345)로부터 얻은 목적지 IP 주소와 목적지 포트번호를 사용해서 NAT 변환 테이블을 작성. 라우터는 데이터그램의 목적지 주소와 포트번호를 다시 기록하고, 홈네트워크 내부로 데이터그램을 전송
5. IPv6
- Initial motivation : 32-bit address space soon to be completely allocated
- When the IPv6 is designed,
other aspects such a sheader format redesign, providing QoS were considered.
- Important Changes Introduced in IPv6
- Expanded addressing capabilities
→ Increase the size of the IP address from 32 to 128 bits
확장된 주소 기능
- A streamlined 40-byte fixed-length header
→ Allow faster proessing on the IP datagram by a router
간소화된 40바이트 헤더 -> 라우터의 IP datagram 처리속도 up
- Flow labeling
→ Labeling of packets belonging to particular flows for which the sender requests special handling, such as real-time-service
특정 flow에 속하는 패킷 라벨링
- Fields in the IPv6 Datagram
- Version(4bits) : 6
- Traffic class(1byte)
: IPv4의 TOS(Type of service)필드와 비슷
: can give a priority to certain datagrams
- Flow label(20bits)
: A unique flow label is uesd to identify all the datagrams in a particular flow
: Can provide additional support for real-time datagram delivery
특정 흐름의 datagram식별
실시간 데이터 전송을 위한 추가지원 제공
- Payload length(2bytes)
: The number of bytes in the data except the 40-byte datagram header
데이터그램 헤더(40바이트)를 제외한 데이터의 바이트 수
- Next header(1byte)
: Indicate the specific transport-layer protocol(ex.TCP or UDP)
: Like the protocol field in IPv4
데이터그램의 내용이 전달될 프로토콜을 구분
- Hop limit(1byte)
: Specify how long the datagram is allowed to live on the network
: Devremented by one each time the datagram is provessed by a router
: If this field reaches 0, a router must drop that datagram
: LIke TTL in IPv4
데이터그램 보낼때마다 1씩 감소 -> 0되면 데이터그램 버림
- Source address(16bytes)
- Destination address(16bytes)
- Data
- IPv4 vs IPv6
- Fragmentation/reassembly
: No fragmentation at routers
: Fragmentation is performed at the source and the reassembly is performed at the destination.
: If a datagram is too large, then the router drops the datagram and sends a "Packet Too Bug" ICMP error message back to the sender
라우터에서 fragmentation 진행 x
fragmentation은 source에서, reassembly는 destination에서 진행
-> 라우터에서 이 기능을 삭자하고 종단시스템에서 하도록 하여 네트워크에서 IP 전달속도up
라우터가 받은 IPv6데이터그램이 너무 커서 출력 링크로 전달할 수 없다면 라우터는 데이터그램을 폐기하고 ICMP오류 메시지 보내어 크기 줄여서 다시 보내도록 함.
- Header checksum
: Removed entirely to reduce processing time at each hop
트랜스포트 계층 프로토콜과 데이터 링크 프로토콜(ethernet)은 체크섬을 수행하므로 IP설계자는 네터워크 계층의 체크섬을 수행하므로 생략
IPv4는 헤터 체크섬을 모든 라우터마다 수행
- Options
: No longer a part of the standart IP header
: One of the possible next headers prointed to from within the IPv6 header
이제 표준 아님.
'3-1 > 컴퓨터 네트워크' 카테고리의 다른 글
5.3 Intra-AS routing in the Internet : OSPF (0) | 2022.06.18 |
---|---|
5.1 Introduction / 5.2 Routing algorithms (0) | 2022.06.11 |
4.2 What's inside a router? (0) | 2022.05.29 |
4.1 Overview of Network layer (0) | 2022.05.29 |
3.7 TCP 혼잡제어 (0) | 2022.05.29 |