User Datagram Protocol (UDP)
Transmission Control Protocol (TCP)
Port Number
UDP와 TCP와 함꼐 사용되는 몇몇의 well-known port
User Datagram Protocol (UDP)
UDP packet는 user datagram이라고 불린다.
Example
- 다음은 16진수 형식의 UDP header에 내용이다.
Solution
a. 수신측 port number는 처음 4개이다. 16진수 CB84 or 52100
b. 수신측 port number는 두 번째 4개이다. 16진수 000D or 13
c. 세 번째 4개인 16진수 001C는 28bytes의 전체 UDP packet 길이를 정의한다.
d. data에 길이는 전체 packet 길이에서 header에 길이를 뺀 것이다. 즉 28 - 8 = 20 bytes
e. 수신측 port number는 13(well-known port)이다. packet은 client로부터 server로 가는 것이다.
f. client process는 Daytime이다.
Process-to-Process Communication
Connection-less Service
Flow Control
Error Control
Congestion Control
Encapsulation and Decapsulation
Checksum(16 bits)
Queuing
Multiplexing and Demultiplexing
UDP와 Simple Protocol 비교
UDP에 특징
DNS(Domain Name Service)는 UDP service를 사용한다.
SMTP(E-mail Service)는 UDP service를 사용하지 않는다.
Internet으로 부터 긴 text file을 다운로드 하는 것
skype와 같은 실시간 대화형 application
UDP를 사용하는 더 유용한 application
1. Process-to-Process Communication
- port 번호로 제공된다.
2. Stream Delivery Service
- TCP는 stream-oriented protocol이다.
- sending/receiving TCP process는 바이트 단위로 데이터를 delivers/obtain한다.
Sending and Receiving Buffer
- 송신, 수신 프로세스는 속도가 다르게 동작한다.
- Buffer는 TCP에 대한 flow & error control을 위해 필요하다.
TCP Segment
- TCP는 수많은 bytes를 segment로 불리는 packet으로 그룹화한다.
- Segment는 반드시 동일할 필요가 없다.
- TCP는 각 segment에 header가 추가되고 network layer로 그것을 배달한다.
- Segment는 IP datagram으로 encapsulated된다.
3. Full-duplex Communication
- TCP는 양방향 통신을 제공한다.
4. Multiplexing and Demultiplexing
- 송신측에 Multiplexing : Many to One
- 수신측에 Demultiplexing : One to Many
5. Connection-oriented Service
- TCP connection은 logical이고, physical이 아니다.
- Logical Connection between two processes
- Exchange of the data
- The close of connection
- 각 segment는 수신측까지 서로 다른 경로를 통해 라우팅될 수 있다.
- segment가 손실되거나 손상된 후, 다시 보내진다.
- TCP는 byte를 순서대로 전달할 책임이 있다.
6. Reliable Service
- IP는 connectionless, unreliable service를 제공한다.
- TCP는 data에 안전한 도착을 확인하기 위해 ACK mechanism을 사용한다.
Numbering System
Byte number
Sequnece Number
Acknowledgement Number
Example
- TCP 연결이 5000 bytes에 file을 전송하는 중을 가정한다.
- 첫번쨰 바이트는 10,001이다.
- 데이터를 각각 1,000바이트씩 5개의 세그먼트로 보낸 경우 각 세그먼트의 시퀀스 번호는 무엇인가?
Solution
TCP의 packet은 segment로 불린다.
TCP Segment Format
Source Port Address(16 bits)
Destination Port Address(16 bits)
Sequence Number(32 bits)
Acknowledgement Number(32 bits)
Header length(4 bits)
Reserved(6 bits)
Control(6 bits)
Window Size(16 bits)
Urgent Pointer(16 bits)
Option(variable)
Checksum(16 bits)
1. Connection using Three-Way Handshaking
Connection 1단계
- client는 SYN Segment를 보낸다. : 오직 SYN flag만 설정된다.
- random number를 inital Sequnece Number로 선택한다.
- SYN segment는 데이터를 실을 수 없다.
- sequnce number를 하나 소비한다.
Connection 2단계
- Server는 SYN + ACK segment를 보낸다.
- 다른 방향의 SYN와 1 단계에 SYN에 대한 ACK
- receive window size, rwnd를 포함한다.
- SYN + ACK segment는 data를 실을 수 없다.
- sequnce number를 하나 소비한다.
Connection 3단계
- Client가 ACK segment를 보낸다.
- 2단계 SYN에 대한 segment이다.
- send window size, swnd를 정의한다.
- data를 실지 않으면, sequnece number를 소비하지 않는다.
SYN Flooding Attack
- 공격자는 송신측 IP 주소를 위조하여 많은 수의 SYN 세그먼트를 서버로 전송한다.
- SYN가 오면 메모리 할당을 해놓는다.
- 잘못된 주소를 보내서 ACK가 오지 않고 메모리 공간만 늘리게 된다. -> 여러 컴퓨터에서 공격하면 DDOS
2. Data Transfer : Piggyback
- ACK는 data와 함께 piggyback된다.
Data Transfer : Pushing Data
- 수신측의 application program은 interactive application을 위한 push operation을 요청한다.
- push를 설정해서 보내면 밀어낸다. (빨리 보내기 위해)
- TCP는 segment를 만들고 즉시 push bit를 설정해서 보낸다. (PSH)
- 송신측에서는 기본적으로 push로 동작한다.
- 수신측 TCP는 application program에 가능한 빨리 segment를 전송하고 더 많은 데이터가 올때까지 기다리지 않는다. -> pull로동작
3. Connection termination
1단계 Termination
- client TCP는 FIN segment : FIN flag를 설정한다.
- FIN segment는 수신측에 data에 ACK를 포함 할 수 있다.
2단계 Termination
- server TCP는 FIN + ACK segment를 보낸다.
- 이러한 segment는 서버의 마지막 data chunck도 포함 할 수 있다.
3딘계 Termination
- client TCP는 ACK segment를 보낸다.
- 이러한 segment는 data를 서버로 전달할 수 없다.
State Transition Diagram over the Time-line
SYN-SENT : 클라이언트 SYN 보냄
LISTENED : 서버는 연결을 기다리는 중
SYN-RCVD : SYN를 받음
ESTABLISED : 연결 설정된 상태
FIN-WAIT-1, FIN-WAIT-2 : 연결 끝낼때 finish 대기
Closed-Wait : close 기다림 (Data Transfer : 보내지 못한 데이터 보냄
TIME-WAIT : Timer를 두고 시간이 지나면 close (MSL : maximum segment liftetime)
LAST-ACK : 마지막 ACK
States for TCP
TCP는 두개의 window를 사용한다 :
Send Window in TCP
TCP와 SR간에 send window 차이
1) TCP에서 window size는 bytes의 수이다.
2) TCP는 한 timer이다.
Receive Window in TCP
TCP와 SR간에 receive window의 차이
1) 수신측 window size는 결정될 수 있다. :
2) TCP에서 ACK mechanism은 누적하는 Acknowledgement이다.
Flow control producer와 consumer에 속도를 조절한다.
TCP flow control와 error control를 분리한다.
Data flow and flow control feedbacks in TCP
Flow Control
수신측은 send window의 shirinking 방지하기 위해 다음과 같은 관계를 유지한다.
Shirink of Windows
Fig b. send window의 shirinking 상황을 보여준다
send window가 shrink될 때, 문제가 발생한다.
TCP는 reliable transport-layer protocol이다.
TCP에서 error controld은 세가지 간단한 방법과 함께 이루어진다.
1) checksum
2) Acknowledgement
3) Retransimission after Time-out (RTO)
1. Checksum
각 segment는 checksum field를 가진다.
만약 segment가 손상되면, 그것을 버리고 손실된 것으로 간주한다.
2. Acknowledgement
- TCP segment를 누적해서 acknowledge한다. (ACK)
- 폐기, 손실 또는 중복 segment에 대해 feedback이 제공되지 않는다.
- 송신자에게 알려주지 않는다.
- Selectivce Acknowledgement (SACK)
- SACK는 TCP header에 end에서 option으로 구현된다.
- 사용되지는 않고 있음
3. Timeout : Retransimission
- Retransmission after Time-out (RTO)
- 수신측은 각 연결에 하나의 timer를 유지한다.
- timer가 만료되면, TCp는 queue 맨 앞에 segment를 다시 보낸다.
- RTO에 값은 동적이고 round-trip-time (RTT)에 의해 업데이트된다.
- round-trip-time : 송신측-수신측 갔다가 되돌아오는 시간
- Retransimission after Three Duplicate ACKS
- 만약 3-duplicate ACKs가 segment에 도착하면, segment는 time-out을 기다리는 것 없이 재전송한다.
순서가 잘못된 segments
Simplified FSM for the TCP sender side
Simplified FSM for the TCP receiver side
Normal Operation
Lost Segment
Fast Retransimission - Three Duplicates (Four ACK)
Lost Acknowledgement - Corrected automatically
Lost Acknowledgment –corrected by resending
반대쪽 끝은 congestion이 없지만, middle에는 congestion이 있을 수 있다.
Congestion Detection : ACks
세 개의 congestion polices:
1) Slow Start
2) Congestion Avoidnece
3) Fast Recovery
Congestion window
Congestion Detection
1) Time-out
2) Receiving of three duplicate ACKs
Congestion Policies
1. Slow Start : Exponention Increase
- cwnd에 size는 1(one segment)부터 시작해서 threshold에 도달할때까지 지수적으로 증가한다.
2. Congestion Avoidance : Additive Increase
- congestion을 피하기 위해, TCP는 지수적인 증가 속도를 늦춘다.
- cwnd에 size가 threashold에 도달할때, congestion 발견될 떄까지 1씩 증가한다.
3. Fast Recovery
- 세 duplicate ACKs가 도착할때, 가벼운 congestion으로 해석된다.
- cwnd에 사이즈를 반으로 감소시키고, fast recovery policy가 1씩 증가로 적용된다.
- time-out이 발생하면, TCP는 real congestion이고, slow start 상태로 바꾼다.
Policy Transition
1. Tahoe TCP
Tahoe TCP 예시
2. Reno TCP
Reno TCP 예시
Four timers:
Retransmission Timers
Persistence Timers
Keepalive Timers
Time wait Timers