Network-Layer Services

- router와 end computer가 node에 해당
- network layer 사이에는 logical connection이 연결되어 데이터 전달이 이루어진다.
1) Packetetizing
- payload를 Encapsulationg / decapsulation
- Carrier service :송신측에서 수신측으로 contents에 변화 없이 보냄
2) Routing & Forwarding
- Routing : 목적지까지 가는 최적의 길을 찾아주는 것
- Forwarding : 출구(output interface)를 정하는 것
3) Others : Error, Flow, congestion, Security 등

- 여기서 payload는 transport layer에서 내려온 데이터
- header를 붙이거나 뗌
- router들은 forwarding table을 관리한다.
Packetizing
- 송신측의 IP datagram에 payload를 Encapsulating
- 수신측의 datagram으로부터 payload를 Decapsulating

Header format
- VER : 버전 정보
- HLEN : Header의 길이
- Total length : Data 포함 전체 길이
- Source Ip address : 송신측 IP 주소
- Destination IP address : 수신측 IP 주소
- Header checksum : 오류 제어를 위한 것
- network layer에서는 전체 데이터에 대해서 오류 제어를 하지 않고, header에 대해서만 오류제어
- Framentation offset : frame으로 자르는 것에 대한 정보
- Identification : 패킷 구분 번호
- Time-to-live : 패킷의 생존 기간
Routing and Forwarding
- Network layer는 가장 좋은 길을 찾아야 할 책임이 있다.
Forwarding Table
- routing algoritms은 각 forwarding table(routing table)을 생성하기 위해 적용된다.
- 각 노드에서는 forwarding table을 관리한다.
Forwarding
- packet이 interface 중 하나에 도착할 때 적용되는 작업
Router에서 Forwarding 과정
- router는 output interface number를 찾기 위해 packet header에 있는 forwarding value를 사용한다.
- 목적지 IP주소나 label이 forwarding value가 될 수 있다.

Other Services
Error control
- newtwork layer는 기본적으로 error control을 하지 않는다.
- 단지 header 부분에 오류를 체크하기 위해 checksum을 추가한다.
Internet Control Message Protocol (ICMP)
- header가 오류가 나면 datagrame을 폐기하고 송신자에게 ICMP로 폐기했다는 것을 알려준다.

Flow Control
- Network layer는 flow control을 하지 않는다.
- transport layer에서 flow control 기능을 제공한다

- flow control에서는 buffer가 필요하다.
- frame의 경우에는 medium을 사용하지 않을 때, 보낼 frame이 있으면 내보냄
Congestion Control
- network의 처리 용량을 넘어서면 congestion이 발생한다.
- network layer에서는 Congestion control도 없음
Quality of Service(Qos)
- Internet이 multimedia application을 허용함 따라 QoS가 매우 중요해졌다.
- 하지만, upper layer에서 처리한다.
Security
- Internet의 초기에는 Security가 고려되지 않았다.
- Internet Protocol Security (IPsec)
- pacekt에 data를 인증(authenticate)하고 암호화(encrypt)하는 secure network protocol
- 송신자에서 온 데이터인지, 내용이 올바른 내용인지 인증되어야 한다.
- 가로채기를 할 수 있기 때문에 암호화시킨다.
- Internet Protocol network를 통해 두 컴퓨터 간에 안전한 암호화된 통신을 제공한다.

Packet Switching
- Router는 network layer에서 input port와 output port 사이를 연결하는 switch이다.

packet-switched network에서 두 가지 route approach
- pacekt-switched netowork : 패킷 단위로 동작되는 네트워크
1) Datagram Approach : Connectionless Oriented Service
2) Virtual Circuit Approach : Connection Orietned Service
Datagram Approach
Datagram : Connnectionless Oriented Service
- network layer에서는 기본적으로 connectionless service로 설계되어 있다.
- 각각 packet은 독립적으로 가고, 다른 packet과 관계가 없다.
- packet은 같은 길로 갈 수도 안 갈 수도 있다.
Connectionless packet - switched network

- packet의 순서를 바로 잡아야 한다.
- 송신측과 수신측 사이의 connection이 없음
connectionless network에서 Forwarding process
- router는 destination address만을 가지고 routing 해준다.
- error가 발생하면 packet은 폐기하고 송신측에 ICMP를 이용해서 폐기됨을 알려준다.

Virtual-Circuit Approach
Virtual-Circuit Approach : Connection-oriented Service
- virtual 연결은 datagram의 path을 설정해야한다. (회로를연결하고 데이터를 보낸다.)
- dagrame은 모두 같은 path를 따라간다.
- packet 사이에 관계가 있다.
- Packet은 송신측과 목적지 IP 주소와 flow label을 추가해서 처리한다.
- flow label은 packet이 따라야하는 virtual path를 정의하는 virtual circuit identifier(VCI)이다.
Setup과 Teardown 단계
- router는 virtual circuit을 만들기 위해 forwarding table을 만든다.

- Request Packet : 경로 요청 packet
- Acknowledgement Packet : 확인 packet
- Teardown pacekt : 경로 폐쇄 packet
virtual-circuit packet-switched network
- datagrame은 같은 path를 따라가야한다.

virtual circuit nework에서 Forwarding process
- forwarding 결정은 packet에 label(VCI, virtual circuit identifier)값에 의해 결정된다.

- 1번 port에서 l1 label로 들어오는 packet은 2번 port로 내보내고 l2 label을 달아서 보내라는 뜻
Request packet (길 설정)
- packet은 송신측과 수신측 주소를 전송한다.

Acknowledgement Packet (ACK로 회신)
- packet은 switching table을 완성한다.

Data Transfer Phase (데이터를 보낼때)
- 모든 packet은 동일한 label 순서를 따르고, 수신측에 순서대로 도착한다.

IPv4 Address
- IP 주소는 각 장치(host or router)의 연결을 고유하게 구분한다.
- IP 주소는 address of connection이다.
- 장치에 대한 주소가 아니다.
- 여러 개를 가질수 있다. (LAN 카드마다 다르게 부여한다.)
- router는 연결선마다 IP주소를 다르게 부여한다.
- IPv4에 세가지 다른 표기법

IP Address
- 만약 host가 다른 network로 이동하면 host의 IP 주소는 변경되어야 한다.
- IP주소는 network주소에 host 주소를 연결 시켜서 구성한다.
- network가 바뀌면 IP주소가 바뀌게 된다.
IP Address Space
- Addres space는 address의 전체 수이다.
- b bits address → address space는 2^b
- IPv4 address는 32-bit address이다.
- address spase는 2^32 or 4,294,967,296
Hierachy in Addressing
- IPv4 주소는 두 part로 구분되는 계층 구조를 가진다.
- Prefix는 network를 정의한다.
- Suffix는 node(host)를 정의한다.
- Prefix는 fixed length나 variable length를 가진다.
- fixed length prefix - Classful addressing
- variabele length prefix - Classless addressing

Classful Addressing
classful IP Address
- 인터넷 초기에, IPv4 Address는fixed-length prefix로 설계되었다.
- 소형 network와 대형 network를 모두 수용하기 위해서, three fixed-length prefix를 설계했었다. (n = 8, n = 16, n = 24)

- 전체 address space는 5개 class로 나누어진다. (class A, B, C, D, E)

- 컴퓨터가 많은 기관은 적은 기관보다 높은 class를 부여한다.
Classless Addressing
- 인터넷의 성장과 함께, 더 큰 주소 공간이 필요해졌다.
- IP 주소에 길이 또한 증가했다.
- 장기적인 해결책 → 128bit의 IPv6
Classless Addressing
- 단기적 해결책 → classless Addresing 방법의 IPv4
- 각 기관에 공정한 주소 공간 분배
- 전체 주소는 variable-length block으로 나누어진다.
- block들 중 하나가 기관에 배정된다.

Classless Inter-Domain Routing (CIDR)
- prefix는 network나 subnet을 구분한다.
- suffix는 network에 포함된 host를 구분한다.
- 만약 주소가 주어진다면 어떻게 prefix 길이를 어떻게 표시하는가?
- prefix lengh (n)은 주소에 추가된다.
- slash(
/
)에 의해 구분된다. → slash notation

classless addressing에서 나타내는 정보


예시
IP주소를 부여 받을 때는 기관에서 network 주소를 부여 받아 컴퓨터마다 번호 매김


prefix의 Address Mask
- prefix를 1로 채운 것, 나머지는 0으로

address block의 정보

예시

- 230.8.24.56과 같은 주소는 prefix에 따라 여러 블록에 해당 될 수 있다.
- /를 통해 어느 블록에 있는지 결정


- subnet은 network를 다시 나눈것이다.
Network Address
- network address는 패킷을 목적지 네트워크로 라우팅하는데 사용된다.
- 패킷이 rotuer에 도착하면 패킷을 어느 network로 보내야하는지 알아야한다.

Block Allocation
ISP가 1000개의 주소 block을 요청한다.

Subnetting
- subnetting을 통해 더 많은 수준의 계층 구조를 만들 수 있다.
- subnetwork는 여러 sub-subnetwork로 나눌 수 있다.

subnet 규칙

subnet mask

예시



Address Aggregation
- 더 block들의 주소가 더 큰 block으로 결합될 때, 라우팅은 더 큰 블록의 prefix에 의해 행해질 수 있다.
- ICANN은 ISP에 큰 주소 block을 할당한다.
- 각 ISP는 할당된 block을 더 작은 하위 block으로 나누고, 해당 blcok을 고객에게 부여한다.
예시
- 4개의 작은 주소 block이 ISP에 의해 4개의 조직으로 할당된다.
- ISP는 이 4개의 block을 단일 block으로 결합한다.
- 이러한 larger blcok으로 향하는 패킷은 이 ISP로 전송되어야 한다.

DHCP (Dynamic Host Configuration Protocol)
- 동적으로 인터넷을 하는 컴퓨터의 네트워크 환경 설정을 고정시키지 않고 사용
- IP 주소를 고정하지 않고 IP 주소를 빌리고 사용하지 않으면 반납
- 기관에 주소 block이 부여된다.
- network 관리자는 개별 host나 rotuer에 수동으로 주소를 할당할 수 있다.
- DHCP 서버는 IP주소와 다른 network configuration parameter를 각 장치에 자동으로 할당한다.
- DHCP는 application-layer 프로그램으로, netowkr 계층에서 TCP/IP를 도와준다.
DHCP Message Format

DHCP Operation
- DHCP는 4단계로 나뉜다
1) server discovery - IP주소를 자동으로 부여해주는 서버를 찾음
2) IP lease offer
3) IP lease request
4) IP lease acknowledgment

FSM for the DHCP client

- BOUND : IP 주소를 확정함
- IP 주소를 일정시간 사용하지 않으면 반납을 한다.
- 50%를 사용하면 다시 요청해서 갱신함
- 시간이 지나도 사용하지 않으면 반납함
NAT (Network Address Translation)
- small network에 있는 컴퓨터의 일부만이 Internet에 동시에 접속할 필요가 있다.
- NAT를 사용하면 IP를 효율적으로 사용할 수 있다.
Network Address Translation (NAT)
- private address 와 global Internet address 사이에 mapping
- virtual private network를 지원한다.

- 공인 IP 주소는 부족하다. 또한 사용료를 내야한다.
- 동시에 Internet을 사용하는 것이 아니다.
- private IP 주소를 배정해서 내부에서 통신할 때는 이것을 사용한다.
- 외부로 나갈 때는 공인 IP주소로 변환 시켜 사용한다.
Private Address 범위

Address Translation
- NAT 기능은 router나 firewall에서 구현된다.

Translation Table

- 외부 서버 프로그램과 private netwrok 내에 host간에 multiple connection을 설정하기 위해, 더 많은 정보가 translation table에 필요하다.

IP 주소 부족 해결방법
1) IPv6
2) DHCP
3) NAT
Forwarding of IP Packet
Forwarding
- 패킷을 목적지로 향하도록 배치한다.
- 패킷을 다음 hop까지 전달한다.
Forwarding의 IP Address
- Connectionless protocl : datagrame의 수신측 IP 주소를 보고
- Connection-oriented protocol : datagrame에 붙은 label을 보고
Forwarding Based on Destination Address
- host와 router는 forwarding table을 가진다.
- router는 forwarding table을 유지 관리한다.
- router가 패킷을 받을때,
- 패킷을 다음 hop으로 전달하기 위해 forwarding table을 찾는다.
- mask를 포함해서 network 주소를 가지고 해당되는 interface로 패킷을 내보낸다.

- next-hop Ip address : 다음 router의 주소
R1의 forwarding table

- 가장 왼쪽에 26비트가 첫 번째 행의 비트와 일치하는 패킷이 도착하면, 그 패킷은 인터페이스 m2로 전송
- 가장 긴 prefix는 forwarding table의 첫번째 행에 위치한다.
- default : 매칭이 되지 않은 것들을 next hop으로 보내어 외부로 나감
예시)

- 201.1.20.140 - default, m2로 보냄
Address Aggregation
- forwarding table의 행 수를 줄일 수 있다.
- 4개의 연속된 /26 nework는 하나의 더 큰 /24로 routing table 엔트리로 aggregate될 수 있다.

가장 긴 Mask Matching
- 가장 긴 prefix는 forwarding table의 첫 번째 row에 위치된다.
- 목적지 주소가 140.24.7.200인 패킷이 R2에 도착했을때 R2의 처음 두 개 엔트리가 교체되면, 패킷은 m0에 보내질 수 있다.

Hierarchical Routing
- region ISP는 120.14.64.0부터 16384개의 주소를 부여받는다.
- 마스크 /18이 있는 원래 block은 4개의 block으로 나누어진다.
Forwarding Based on Label
Forwarding Based on Destination IP Address
- 패킷이 router에 도착하면 the longest mask algortim을 사용하여 forwarding table을 searching한다.
- 일치하는 것을 찾을 때까지 network address를 확인한다.
- 시간이 오래걸린다.

Forwarding Based on Label
- table의 index로 label이 사용되므로, 표에서 정보를 즉시 찾는 것이 가능하다.

Multi-Protocol Label Switching (MPLS)
- 지금까지 router는 이렇게 동작하지 않는다.
- rotuer를 switch처럼 빠르게 동작 시키기 위한 추가적인 패킷이 필요하다.
- MPLS Router는 router와 switch처럼 동작한다.
- router처럼 : 패킷은 수신측 주소를 사용하여 forwarding
- siwtch처럼 : 패킷은 label을 사용하여 forwarindg된다.
Label Switch Router(LSR)
- LSR은 어떤 traffic의 전체 IP주소가 아니라 MPLS label을 해석한다.
- 패킷을 수신한 최초 라우터는 패킷의 전체 경로를 미리 계산한다.
- 패킷 헤더의 label을 사용하여 고유 식별자를 이후 라우터에 전달한다.
