lec17_net
lec17_net
Operating Systems
Hong Xu
https://github.com/henryhxu/CSCI3150
https://github.com/henryhxu/CSCI3150
Agenda
Layering
Transport layer
3
What we want
4
(Some of) What happens…
5.6.7.8
1.2.3.48 1.2.3.156 ...
... host host host
host host DNS
1.2.3.19
1.2.3.* router router router
5.6.7.*
5
(More of) What happens
5.6.7.8
1.2.3.48 1.2.3.156 ...
... host host host
host host DNS
1.2.3.19
1.2.3.* router router router
5.6.7.*
6
What we get
Hello
7
Inspiration…
➢ CEO A writes letter to CEO B
❑ Folds letter and hands it to administrative aide
➢ Aide:
❑ Puts letter in envelope with CEO B’s full name
❑ Takes to SF Express
➢ SF Express Office
❑ Puts letter in a larger envelope
❑ Puts name and street address on the envelope
Aide Envelope
Identity Aide
SF Express Location
SF-Express Envelope SF Express
9
Three steps
➢ Decompose the problem into tasks
➢ Organize these tasks
➢ Assign tasks to entities (who does what)
10
Back to the Internet:
Decomposition
Applications
in built on
Reliable or unreliable transport
in built on
Best-effort global packet delivery
in built on
Best-effort local packet delivery
in built on
Physical transfer of bits
11
Communication organization
Applications
in built on
Reliable or unreliable transport L7 Application
in built on
L4 Transport
Best-effort global packet delivery
L3 Network
in built on
Best-effort local packet delivery L2 Data link
in built on L1 Physical
Physical transfer of bits
12
OSI layers
➢ OSI stands for Open Systems
Interconnection model L7 Application
❑ Developed by the ISO L6 Presentation
L5 Session
13
Layers
➢ Layer: a part of a system with well-defined
interfaces to other parts
➢ One layer interacts only with layer above and
layer below
➢ Two layers interact only through the interface
between them
14
Layers and protocols
L7 Application Application L7
L4 Transport Transport L4
L3 Network Network L3
L2 Data link Data link L2
L1 Physical Physical L1
Friendly
greeting
Time?
12:10 PM
Thanks!
Let’s start
16
What is a Protocol?
➢ An agreement between parties (in the same
layer) on how to communicate
➢ Defines the syntax of communication
❑ Header → instructions on how to process packet
❑ Each protocol defines the format of its headers
Header DataPayload
Data 17
What is a Protocol?
➢ An agreement between parties on how to
communicate
➢ Defines the syntax of communication
➢ And semantics
❑ “First a hello, then a request…”
❑ We will study many protocols later in the semester
18
Protocols at different layers
L3 Network IP
19
ONE network layer protocol
L3 Network IP
20
Layer encapsulation:
Protocol headers
User A User B
HTTP
request/response
TCP header
IP header
Ethernet
header
21
Three steps
➢ Decompose the problem into tasks
➢ Organize these tasks
➢ Assign tasks to entities (who does what)
22
What gets implemented where?
L7 Application Application L7
L4 Transport Transport L4
L3 Network Network L3
L2 Data link Data link L2
L1 Physical Physical L1
23
What gets implemented
at the end systems?
➢ Bits arrive on wire, must make it up to
application
24
What gets implemented in
the network?
➢ Bits arrive on wire → physical layer (L1)
➢ Packets must be delivered across links and
local networks → datalink layer (L2)
➢ Packets must be delivered between networks
for global delivery → network layer (L3)
➢ The network does not support reliable delivery
❑ Transport layer (and above) not supported
25
Simple Diagram
➢ Lower three layers implemented everywhere
➢ Top two layers implemented only at hosts
Application Application
Transport Transport
Network Network Network
Datalink Datalink Datalink
Physical Physical Physical
27
What gets implemented in
the network?
➢ Bits arrive on wire → physical layer (L1)
➢ Packets must be delivered across links and
local networks → datalink layer (L2)
➢ Packets must be delivered between networks
for global delivery → network layer (L3)
link
switch
29
A closer look at the network
link
switch routers
switch
30
Switches vs. Routers
➢ Switches do what routers do but don’t
participate in global delivery, just local delivery
❑ Switches only need to support L1, L2
❑ Routers support L1-L3
31
Logical communication
➢ A layer interacts with its peers in the
corresponding layer
Application Application
Transport Transport
Network Network Network
Datalink Datalink Datalink
Physical Physical Physical
Application Application
Transport Transport
Network Network Network
Datalink Datalink Datalink
Physical Physical Physical
TCP segment
TCP TCP
router router
IP packet IP packet IP packet
IP IP IP IP
35
IP is the narrow waist of the
layering hourglass
TCP UDP
IP
36
Implications of hourglass
➢ Single network-layer protocol (IP)
➢ Allows arbitrary networks to interoperate
❑ Any network that supports IP can exchange packets
➢ Decouples applications from low-level
networking technologies
❑ Applications function on all networks
➢ Supports simultaneous innovations above and
below IP
➢ But changing IP itself is hard (e.g., IPv4 →
IPv6)
37
Placing network functionality
➢ End-to-end arguments by Saltzer, Reed, and
Clark
❑ Dumb network and smart end systems
❑ Functions that can be completely and correctly
38
Quick recap
➢ Layering is a good way to organize networks
➢ Unified Internet layer decouples applications
from networks, allows technologies to evolve
independently
➢ E2E argument encourages us to keep IP
simple
39
TRANSPORT LAYER
Why a transport layer?
➢ IP addresses capture hosts, but end-to-end
communication happens between applications
❑ Need a way to decide which packets go to which
applications (multiplexing/demultiplexing)
➢ IP provides a weak service model (best-effort)
❑ Packets can be corrupted, delayed, dropped,
reordered, duplicated
❑ No guidance on how much traffic to send and when
application
Length Checksum
DATA
UDP (cont’d)
➢ Optional error checking on the packet contents
❑ (checksum field = 0 means “don’t verify checksum”)
➢ Source port is also optional
❑ Useful to respond back to the sender in some cases
Why a transport layer?
➢ IP packets are addressed to a host but end-to-
end communication is between application
processes at hosts
❑ Need a way to decide which packets go to which
applications (mux/demux)
➢ IP provides a weak service model (best-effort)
❑ Packets can be corrupted, delayed, dropped,
reordered, duplicated
❑ No guidance on how much traffic to send and when
@Sender @Receiver
❑ Send packets ❑ Wait for packets
Reliable transport
➢ In a perfect world, reliable transport is easy
➢ All the bad things best-effort can do…
❑ A packet is corrupted (bit errors)
❑ A packet is lost (why?)
1
ack
2
nack
Sender Receiver
Time
Dealing with packet corruption
1
1
Packet
#1 or #2?
Sender Receiver
Data and
WhatACK
if the
packets
ACK/NACK
Timecarry sequence
is corrupted?
numbers
Dealing with packet loss
1
Timeout
duplicate!
Sender Receiver
Time
Dealing with delay
1
Timeout
. duplicate!
.
.
Sender Receiver
Timer-driven retransmission
Time can lead to duplicates
Components of a solution
➢ Checksums (to detect bit errors)
➢ Timers (to detect loss)
➢ Acknowledgements (positive or negative)
➢ Sequence numbers (to deal with duplicates)
DESIGNING A RELIABLE TRANSPORT
A Solution: “Stop and Wait”
@Sender @Receiver
⚫ Send packet(i); (re)set timer; ⚫ Wait for packet
wait for ack ⚫ If packet is OK, send ACK
⚫ If (ACK) ⚫ Else, send NACK
⚫ i++; repeat ⚫ Repeat
⚫ If (NACK or TIMEOUT)
⚫ repeat
TRANS DATA
RTT
ACK
If (TRANS << RTT) then
Throughput ~ DATA/RTT
Sender Receiver
Orders of magnitude
➢ Transmission time for 10Gbps link:
❑ ~ microsecond for 1500 byte packet
➢ RTT:
❑ 1,000 kilometers ~ O(10) milliseconds
Three design decisions
➢ Which packets can sender send?
➢ How does receiver ack packets?
➢ Which packets does sender resend?
Sliding window
➢ Window = set of adjacent sequence numbers
❑ The size of the set is the window size; assume window
size is n
➢ General idea: send up to n packets at a time
❑ Sender can send packets in its window
❑ Receiver can accept packets in its window
reception/acknowledgement
❑ Window contains all packets that might still be in transit
Cannot be sent
sequence number →
❑ L7 applications
❑ Network management