Computer Networks: An Introduction Hassan Hajji Department of Information and Computer Sciences, Saitama University JAPAN Hassan Hajji (
[email protected])
1
Goals ❚ Present the basic architecture of current networks ❚ Understand the basic issues in each layer ❚ A bird-view on the Internet protocol stack ❙ Case study of TCP
Hassan Hajji (
[email protected])
2
OSI Interconnection Reference Model ❚ OSI was initiated in the late 1970s, and came to a level of maturity in the late 1980s ❚ Actors ❙ The International Telegraph and Telephone Consultative Committee (CCITT) ❙ ISO and network companies (IBM, XEROX …etc)
❚ OSI defined seven layer in early 80s ❚ Layers hide the complexity of the network Hassan Hajji (
[email protected])
Application Layer Presentation Layer Session Layer Transport Layer Network Layer Data Link Layer Physical Layer
3
Layering and Protocols Logical Communication Application Layer Presentation Layer
Application Layer Logical Communication
Presentation Layer
Logical Communication Session Layer Transport Layer
Session Layer Logical Communication
Transport Layer
Logical Communication Network Layer Data Link Layer
Network Layer Logical Communication
Data Link Layer
Network Layer Physical Layer
Physical Layer
Data Link Layer Physical Communication
Physical Layer Hassan Hajji (
[email protected])
4
Internet Protocol Stack ❚ Session layer and Presentation layer are absent ❚ Applications deal explicitly with conversion, authentication …etc. ❚ Session and presentation layer services should be explicitly realized in the code Hassan Hajji (
[email protected])
Application Layer Transport Layer Network Layer Data Link Layer Physical Layer
5
Protocols ❚ Rules by which active network elements (including applications) communicate ❙ Application Processes ❙ Physical layer hardware Hi
Hi Who are you? I’am Hassan Hajji
Hassan Hajji (
[email protected])
6
Application Layer
Hassan Hajji (
[email protected])
7
Application Layer ❚ All layers exist just to support the application layer ❚ Examples ❙ SMTP ❙ POP3 ❙ HTTP
❚ The application drives the networking technology ❙ Audio, Video On-demand …etc Hassan Hajji (
[email protected])
8
Example: SMTP (RFC 821, 822) C om m and HELO M A IL F R O M RCPT TO D A TA < c r lf> .< c r lf> RESET V E R IF Y Q U IT
A rgu m en t S e n d e r d o m a in u s e r id u s e r id
U s e r ID
M e a n in g I’a m c it.ic s .s a ita m a -u .a c .jp S e n d e r o f th e e m a il In te n d e d r e c ip ie n t E m a il te x t E n d o f th e m a il R e s e t th e in te ra c tio n Ve r ifie s th e u s e r ID S e n d e r s ig n s o ff
❚ SMTP is defined in RFC 821, 822 ❚ The underlying transport service is TCP ❚ Extensions: MIME (multipurpose Internet mail Extensions): RFC 1324 multiple body parts, multimedia mail, multiple fonts and character sets Hassan Hajji (
[email protected])
9
SMTP Illustrated Hajji
220, Service ready, I’m the mail server)
mail
HELO cit.cis.saitama-u.ac.jp
250 RCPT TO
[email protected] 550, no such user in cit RCPT TO
[email protected]
250 DATA .
This is a junk mail, enjoy!
250 QUIT 221, closing the connection Hassan Hajji (
[email protected])
10
HTTP Illustrated Transaction 1 GET /DoesNotExist.html User-Agent: Mozilla/2.01 (X11; I; IRIX 5.2 IP7) Accept: image/gif, image/x-bitmap, image/jpeg
404 not found
Transaction 2
GET /index.html User-Agent: Mozilla/2.01 (X11; I; IRIX 5.2 IP7) Accept: image/gif, image/x-bitmap, image/jpeg
HTTP/1.0 200 Document follows Hassan Hajji (
[email protected])
11
Transport Layer
Hassan Hajji (
[email protected])
12
Transport Layer Issues ❚ How to reliably communicate over an unreliable channel ❚ Connection Management: ❙ Setup a connection ❙ Tear down the connection
❚ Congestion control ❚ Flow control Hassan Hajji (
[email protected])
13
Service Models ❚ Connection-Oriented Service ❙ A connection is explicitly setup and torn down ❙ TCP, (OSI) TP0~TP4
❚ Connectionless Service ❙ No connection is explicitly set up. ❙ UDP, (OSI) CLTP
❚ Virtual Circuits ❘ The packet timing is preserved ❘ Mainly to support audio and video
Hassan Hajji (
[email protected])
14
Connection Management Service Model ❚ Connection-oriented service model ❙ Explicitly setup a connection between the hosts ❙ Initial sequence number, flow window size, congestion window size ❙ Exchange data in the context of the connection ❙ TCP, TP4
❚ Connectionless service model ❙ Pure datagram ❘ Data sent once and no reply from the receiver ❘ UDP (RFC 768), and ISO CLTP (ISO 8072)
❙ Transaction-oriented ❘ single request, single reply
Hassan Hajji (
[email protected])
15
Reliable Data Transfer ❚ Ensure reliable data transfer ❚ Network can lose, corrupt, reorder packets ❚ Routers, bridges,…etc can fail
Hassan Hajji (
[email protected])
16
Physical Media Corrupt data!! ❚ We first assume that the physical media corrupts data 0
0
1
0
Channel
❚ How we ensure reliable data transfer? Hassan Hajji (
[email protected])
17
First Solution (DTP1.0) ❚ Let’s invent our protocol DTP 1.0 ❚ Check for correctness of data ❙ ❙ ❙ ❙
Insert error detection bits These bits are called checksums Think of it as a parity bit! (more powerful) Assume that it never gets corrupted!
Hassan Hajji (
[email protected])
18
Sender Protocol Machine (DTP 1.0)
Wait Wait for for Data Data
ACK Received
Data arrived •Make packet •Checksum packet •Send it
Wait Wait for for ACK ACK
•Nothing
NACK Received •Resend Packet
Hassan Hajji (
[email protected])
19
Receiver Protocol Machine (DTP 1.0)
Packet arrived •Not Corrupt Packet •Deliver to application •Send an ACK
Wait Wait for for Packet Packet
Hassan Hajji (
[email protected])
Packet arrived •Corrupt Packet •Send NACK
20
DTP2.0 Sender Data arrived
Wait Wait for for Data Data
•Make packet •Checksum packet •Send it
NACK Received || Packet Corrupt
Wait Wait for for ACK ACK
•Resend Packet
ACK Received •Nothing
Hassan Hajji (
[email protected])
21
DTP2.0 Receiver
Packet arrived •Not Corrupt Packet •Deliver to application •Send ACK
Packet arrived
Wait Wait for for Packet Packet
Hassan Hajji (
[email protected])
Corrupt Packet Send NACK
22
What If ACK gets Corrupted? Sender
Receiver Packet0 Duplicates!
ACK Corrupted Packet0
Duplicates will show up! Hassan Hajji (
[email protected])
23
Third Thought: Sender (DTP 2.1) ❚ The sender should add some sequence numbers to its packets ❚ How many are sufficient? ❙ One bit sequence number space is enough
❚ Keep in mind our assumptions ❙ The physical media can corrupt, but not loose, or delay packets!
Hassan Hajji (
[email protected])
24
Sender Protocol Machine (DTP 2.1) NACK Received || Packet Corrupt
Data arrived
Wait Wait for for Data Data 00
•Make packet •Checksum packet •Send it
•Resend packet
Wait Wait for for ACK ACK 00 ACK0 || Not Corrupt
ACK0 || Not Corrupt
•Nothing
Wait Wait for for ACK1 ACK1 NACK NACK Received Received |||| Packet Packet Corrupt Corrupt
Resend Resend packet packet
•Nothing
Data arrived
Wait Wait for for Data Data 11
•Make packet •Checksum packet •Send it Hassan Hajji (
[email protected])
25
Receiver Protocol Machine (DTP 2.1) PacketCorrupt || Packet Seq1 •Send NACK0
Wait Wait Data Data Seq Seq 00 PacketNotCorrupt || Packet Seq1
PacketNotCorrupt && Packet Seq0
•Extract packet •Deliver to application
PacketCorrupt || Packet Seq1
•Extract packet •Deliver to application
Wait Wait Data Data Seq Seq 11
•Send NACK1 Hassan Hajji (
[email protected])
26
Media Assumptions ❚ Network can ❙ Corrupt the packets ❙ Loose the packets ❙ Not reorder the packets
❚ How our DTP2.1 fails ❙ Because of no notion of time, the sender can send and wait for ever! ❙ So media can lose the packet Hassan Hajji (
[email protected])
27
Sender Protocol Machine (DTP 3.0) NACK0 Received || NACK1 || Packet Corrupt
Data arrived
Wait Wait for for Data Data 00
•Make packet •Checksum packet •Send it •Start Timer
•Resend packet •Restart timer
Wait Wait for for ACK ACK 00 ACK0 || Not Corrupt •Nothing
Timeout || (NACK0)
ACK0 && Not Corrupt
•Resend packet •Restart Timer
•Stop timer
Wait Wait for for ACK1 ACK1 NACK NACK Received Received |||| Packet Packet Corrupt Corrupt
Resend Resend packet packet
Data arrived
Wait Wait for for Data Data 11
•Make packet •Checksum packet •Send it Hassan Hajji (
[email protected])
28
Receiver Protocol Machine (DTP 3.0) PacketNot Corrupt && Packet Seq1
PacketCorrupt •Send NACK0
•Send ACK1
Wait Wait Data Data Seq Seq 00 PacketNotCorrupt && Packet Seq0
PacketNotCorrupt || Packet Seq1
•Extract packet •Deliver to application
•Extract packet •Deliver to application
PacketNotCorrupt && Packet Seq0 •Send ACK0
Wait Wait Data Data Seq Seq 11 PacketCorrupt •Send NACK1 Hassan Hajji (
[email protected])
29
DTP3.0 Example: No errors Sender
Receiver Packet0 ACK0
Packet1 ACK1
Hassan Hajji (
[email protected])
30
DTP3.0 Example: Packet loss Sender
Receiver Packet0
Time Out
Packet0 ACK1 Packet1
Hassan Hajji (
[email protected])
31
ARQ Protocol ❚ Actually there is a name for DTP 3.0: Automatic Repeat Request (ARQ) ❙ Sometimes also called Alternate Bit Protocol
❚ Half-duplex communication protocol ❚ ARQ waits until an ACK comes back ❙ What if the ACK takes a long time to come back! (e.g., case of line with narrow band width and very slow response) ❙ Better solution: ❘ Just send the packets without waiting for ACKs to come back Hassan Hajji (
[email protected])
32
Go-Back-N ARQ ❚ Operates by sending the packets without waiting for ACKs until some value N ❚ When the sender timers out or a NACK the sender retransmits beginning from the NACKed packet up to N again ❚ Burns bandwidth, but makes buffering fairly easy ❙ The sender does not need to buffer ❙ Variant of it used in TCP Hassan Hajji (
[email protected])
33
Go-Back-N Illustrated 0
Packet0
1 2
Packet1 Packet2
packet 1 Time out
ACK0 ACK2
1 2
Packet2
3
Packet1
Packet3 Hassan Hajji (
[email protected])
34
Reordered Delayed Packets ❚ Problem: ❙ Delayed packets confuse the transport entities
❚ Solution (Tomlinson) ❙ Limit the packet lifetime (some product of the real lifetime T) ❙ Add a large sequence number space such that it takes a large time to wrap around i.e., when getting to zero again, the original packet_0 should have been died out ❙ When opening a connection, choose the lowest clock k bits (length of the seq number) plus the T Hassan Hajji (
[email protected])
35
Connection Establishment Issues ❚ Crux of the problem ❙ Network can order, lose and delay packets ❙ Two or more connection requests may show up
❚ Is the packet real or duplicate? ❙ Transport protocols must keep enough state information to figure out duplicate packets
❚ Two basic approaches ❙ Two way-handshake ❙ Three way-handshake
Hassan Hajji (
[email protected])
36
Two-way Handshake ❚ Two-way handshake may fail! ❚ Operates by adding a timer to the receiving entity
•Client Client
•Sender Sender
•CR(x) CR(x) CR : Connection Request x : sequence number
•ACK(X) ACK(X) •Data(x+1) Data(x+1) •ACK(x+1) ACK(x+1) Hassan Hajji (
[email protected])
•Timer Timer Running •for for at least T
37
Three-way handshake ❚ The receiver cross-examines the sender ❚ Trades one more packet for a timer ❚ Used in TCP, TP4, DECNet
Client
Sender
CR(x) ACK(X,Y) Data(X+1,Y) DATA(X+1) ACK(x+1) Hassan Hajji (
[email protected])
38
Closing a Connection ❚ Two approaches for closing connection ❙ Asymmetric ❘ Abort: send close message to peer, and delete state information ❘ What is if peer is sending?
❙ Symmetric ❘ Graceful close: Send close message, but do not delete the state information, until peer is ready
❚ Can I close knowing that the other agreed to close? Hassan Hajji (
[email protected])
39
The Two-Army Problem ❚ The two-armies problem ❙ Blue units will win if they find a protocol to synchronize the attack ❙ Such protocol could be presented to the white unit who will surrender
Unreliable Channel
Hassan Hajji (
[email protected])
40
Connection Termination ❚ Connection termination is theoretically impossible ❙ Communication is unreliable ❚ There is no protocol to assure coordinate attacks ❙ Proof: use induction
❚ In practice, we take more risk ❙ TCP uses a four way handshake ❙ For safety reasons, a timer is also introduced ❙ In Solaris 2.6, the timer is set to 4 mn appr. Hassan Hajji (
[email protected])
41
Congestion Control ❚ Problem: ❙ ❙ ❙ ❙
Network can not support more than its capacity Slow processors Routers have limited buffer space Even if the buffer is infinite, the congestion problem won’t be solved
❚ Difficulties ❙ Delayed feedback aggravates the problem ❘ Case of high-speed networks
❙ Heterogeneous nature of networks (ways of dealing with various network implementations) Hassan Hajji (
[email protected])
42
Congestion Control ❚ Ideally ❙ Every delivered packet should be delivered until the network capacity reached ❙ Beyond capacity, deliver packets at the network supported rate
❚ Realistically ❙ As network load increases, more packets are lost, more retransmission, more losses … ❙ This degenerate cycle makes things worst ! Hassan Hajji (
[email protected])
43
Three Basic Approaches ❚ End-end Congestion Control ❙ Receiver observes congestion, and throttles the sender ❙ Closed-loop Control
❚ Network-Indicated Congestion Control ❙ Network Layer provide feedback to the sender
❚ Rate-Based Congestion Control ❙ Sender behaves smoothly ❙ Open-loop Control Hassan Hajji (
[email protected])
44
End-end Congestion Control ❚ Sending transport entity maintains congestion window ❙ Can send a packet if packet sequence number is in window ❙ Distinct from flow control
❚ On congestion ❙ Decrease the window size
❚ Normal operation ❙ Increase window size (happens in TCP) Hassan Hajji (
[email protected])
45
Network-Indicated Congestion Control ❚ Network marks packets passing through a congested node ❙ The receiver observes the marked cell, and tells the sender to slow down
❚ Congestion-experienced flag in CLNP (OSI), CWI flag in IBM SNA ❚ Upon detecting, the network layer may send choke packets back to the sender ❙ Source quench (ICMP) in the Internet ❙ Virtual route pacing (VRP in SNA) Hassan Hajji (
[email protected])
46
Rate-Based Congestion Control: Leaky bucket ❚ Goal ❙ Regulate the rate at which the sender can inject the packets in the network
The bucket can store only the first b tokens
Tokens are generated at a fixed rate r (average meantime 1/r)
Packetbuffer buffer Packet
Hassan Hajji (
[email protected])
47
Leaky-Bucket (Cont.) ❚ A packet must wait until it receives a token ❚ Token are added at rate r ❙ r controls the smoothness of the packet entry to the network
❚ And the bucket can buffer only the first b packets ❙ b controls the burstiness of the the packet entry to the network
❚ The maximum number of packets injected in the network is b+rt Hassan Hajji (
[email protected])
48
Case Study 1: TCP ❚ TCP Connections are ❙ Full-Duplex: data flows back and forth ❙ Byte-stream: no message boundaries ❙ Point-to-point: each connection has exactly two end-points, so broadcast or multicast are possible ❘ No support multicasting or broadcasting
❚ Transport entities exchange data in segments of at least 20 bytes, and at most 64 kb ❚ Uses the sliding window approach Go-Back-N Hassan Hajji (
[email protected])
49
TCP Packet format 16 bit
16 bit
Destination port
Source port
Acknowledgement number Header length
Unused
FIN SYN RST PSH ACK URG
20 bytes header
Sequence number
Checksum
Window Size Urgent Pointer
Optional Data ( 0~32bytes) Packet Payload
Hassan Hajji (
[email protected])
50
Congestion Control in TCP ❚ On time out ❙ Loss assumed ❙ Decrease congestion window ❙ Increase timer interval
❚ On ACK received ❙ Everything is OK ❙ Increase congestion window ❙ Decrease timer interval Hassan Hajji (
[email protected])
51
Congestion Control in TCP (cont.) ❚ Uses window-base congestion control ❙ cwnd : Congestion Window Size ❙ ssthresh: constant for slowing down the rate of increase
❚ TCP slow start and Congestion Avoidance ❙ Assume 4k segment size ❙ TCP window size = min (flow control window + congestion control window)
Hassan Hajji (
[email protected])
52
Jacobson Slow Start Algorithm ❚ Initialize: ❙ cwnd =0 ❙ ssthresh=16
❚ Loop forever ❙ if (ACK received and cwnd < ssthresh) ❘ cwnd = cwnd +1
❙ else if (ACK received and cwnd > ssthresh) ❘ cwnd = cwnd +1/ssthresh
❙ else if packet timeout ❘ ssthresh= cwnd/2 ❘ cwnd=1 Hassan Hajji (
[email protected])
53
Estimating Round-Trip Time (RTT) ❚ TCP designed to run on heterogeneous networks ❚ Adaptively estimate the RTT (Jacobson 88) ❙ ❙
RTTi−1 current estimate
RTTi = α RTTi−1 + (1−α ) M (M time for ACK to come back) ❙ Deviation D =α D + (1−α) | RTT− M | ❙ Most implementation use: Timeout = RTT + 4 D Hassan Hajji (
[email protected])
54
TCP State Transitions CLOSED
LISTEN SYN RCVD
SYS SENT
ESTABLISHED
FIN WAIT1
FIN WAIT2
CLOSE WAIT
CLOSING
LAST ACK
TIMED WAIT CLOSED
Hassan Hajji (
[email protected])
55