Title: Layering and Applications
1Layering and Applications
- Layered network protocols
- The OSI Model
- The IP Model
- Some example IP Applications
- Sockets and network programming
2Client/Server Protocol
Request
HTTP server
HTTP client
Response
- Client and Server exchange service information
- Interaction relies on an established channel
- Lower layers handle establishment and control of
communication channel
Figure 2.1
3Client/Server Channel -- TCP
HTTP server
HTTP client
Ephemeral Port
Port 80
GET 80,
TCP
TCP
, 80 STATUS
Figure 2.2
4Other Examples -- DNS
- Event
- Application requests name translation
- Name Query formed
- DNS server looks up information
- Response from server
- Header OPCODESQUERY, QNAMEceet.niu.edu,
QCLASSIN,QTYPEA - Header OPCODESQUERY, RESPONSE, AA, Question
QNAMEceet.niu.edu, QCLASSIN,QTYPEA, - Answer ceet.niu.edu, 86400 IN A 123.45.67.89
5Peer-to-Peer Networking
Peer to Peer
Client/Server
User
User
User
User
User
Server
User
User
- Users exchange information directly
- Often uses a client/server protocol with one user
being the server for one transaction - No central server
- Users need a way to locate users
- No central bottleneck
- Users communicate only with a server
- Server knows about users and how to find them
- Server is a bottleneck (server capacity limits
system capacity)
6One Protocol Layer
n-PDUs
n entity
n entity
- Peer Processes exchange Protocol data units
- Each unit contains protocol (header) information
and content (data)
Figure 2.3
7Layered Packet Protocols
L3 header
L3 data
L2 header
L2 data
L1 header
L1 data
- Protocols define the Packet Structure and
procedures - Layers separate solutions to different
communications problems. - One layer can be different without effecting
others - Layer header information is nested.
- Not all Packet Protocols are layered the same way
8Layering of Protocols
n1 entity
n1 entity
n-SDU
n-SDU
n-SAP
n-SAP
n-SDU
H
n entity
n entity
n-SDU
H
n-PDU
Figure 2.4
9Protocol and Service Units
- Layer n1 exchanges Messages as Service Data
Units - Units passed in to layer n
- Meaningful to Layer n1
- Layer n exchanges messages as Protocol Data Units
- Unit of information exchanged between sides.
- May not be the same as PDUs
- Requires adaptation
10PDU Smaller than SDU
Segmentation
Reassembly
n-SDU
n-SDU
n-PDU
n-PDU
n-PDU
n-PDU
n-PDU
n-PDU
- Single SDU broken into multiple PDUs, each sent
independently - Receiving side must hold PDUs until all that are
part of one SDU arrive - PDU loss, errors, and out of order arrival create
problems - How to decide when a PDU is lost
- Whether to correct the loss
- How to report the problem
Figure 2.5
11PDUs bigger than SDUs
Blocking
Unblocking
n-SDU
n-SDU
n-SDU
n-SDU
n-SDU
n-SDU
n-PDU
n-PDU
- SDUs may need to be grouped for efficient
exchange - No new issues with loss or errors
- Blocking adds delay (waiting for multiple SDUs)
- How long do you want to wait?
Figure 2.5
12OSI Layering Structure
Application A
Application B
Application Layer
Application Layer
Presentation Layer
Presentation Layer
Session Layer
Session Layer
Transport Layer
Transport Layer
Communication Network
Network Layer
Network Layer
Network Layer
Network Layer
Data Link Layer
Data Link Layer
Data Link Layer
Data Link Layer
Physical Layer
Physical Layer
Physical Layer
Physical Layer
Electrical and/or Optical Signals
13OSI Layers 1-3
- Physical
- electrical/optical formats and codes (signal
leads, voltages, modulation, timing - Data link transfers frames
- message framing, error checking, multipoint
addressing, flow control - Network packet transfer
- routing, congestion control, internetworking
14OSI Layers 4-7
- Transport end-to-end transfer
- streams, datagrams, segmentation, blocking
- Session establishing connections
- set-up/teardown, option negotiation, naming
- Presentation data representation
- data type representation and conversion
- Application the service
15The Internet Model
G gateway/router
net 3
G
net 1
G
G
G
net 5
net 2
net 4
G
- Multiple interconnected networks
- Users are part of one network
- Gateways must handle different frame sizes,
addressing, etc.
Figure 2.8
16Layering in the internet
Layer Function Structure
Internet Layers
Application Layer
OSI 5-7
Application Layer
Transport Layer
Transport Layer
OSI 4
Internet Layer
Internet Layer
OSI 3
Network Interface
Network Interface
OSI 1-2
- Internetworking is the major addition
- Layering isnt strict (Application access all
lower layers, Applications use other
Applications) - Mapping to OSI isnt exact
Figure 2.10
17Processing of layers in the internet
Machine B
Machine A
Application
Transport
Router/Gateway
Internet
Network Interface
Network 1
Network 2
Figure 2.11
18Layer alternatives
SMTP
RTP
HTTP
DNS
Many Applications
TCP
UDP
Datagrams
Streams
Universal
Many Implementations
19Example internet connection
(1,1)
(2,1)
The Network
(2,2)
router
s
PPP
(1,3) r
w
Network
Node
Ethernet
(1,2)
Server
PC
HTTP
HTTP
TCP
TCP
Router
IP
IP
IP
Net Interface
Net Interface
Net Interface
Layer Processing
Ethernet
PPP
Figure 2.13
20IP Basics
- Network interfaces have unique internet protocol
(IP) addresses - Assigned permanently (static) or temporarily
(dynamic) - Machines can have multiple addresses (gateways)
- Gateways receive messages both for themselves and
for machines reached through other interfaces - Routing tables determine who packets are
retransmitted by gateways. - Multiple technologies (ethernet, point-to-point
link, even another packet network) can be
connected
21Layers for an HTTP request
Header contains source and destination port
numbers
TCP Header
Header contains source and destination IP
addresses transport protocol type
IP Header
Header contains source and destination physical
addresses network protocol type
Frame Check Sequence
Ethernet Header
Figure 2.15
22Class Exercise
B
A
PPP
Ethernet
router
10Mb/s 1500 byte limit Bit error Rate 10-9
1.5Mb/s 1024 byte limit Bit error Rate 10-6
- If machine A is sending 4096 byte service data
units to machine B, - How many packet fragments arrive at B before one
service data unit is available? - If no error recovery is performed, what fraction
of service data units will be lost?
23Class Exercise
B
A
PPP
Ethernet
router
10Mb/s 1500 byte limit Bit error Rate 10-9
1.5Mb/s 1024 byte limit Bit error Rate 10-6
3 packets 1500, 1500, 1096 loss rate
4096810-9 3.2 10-5
6 packets 1024, 476, 1024, 476, loss rate
4096810-6 3.2 10-2
Roughly 3.2 of Service data units will be lost,
all on the PPP link (actually a bit more than
this because of protocol overhead)
24The Socket interface
- Common programming interface to internet for
applications - Hides network details from the program
- Supports both datagram and stream communication
- Variants for Unix (Berkley Sockets) and Windows
(Winsock)
25Definitions
- Socket a software abstraction used to connect
one program to another - Can be local, or connected to a network
- Really a short-hand for a full address of the
other participant - Internet address Network address of a machine
interface on a network - Machines can have more than one IP address
- Port
- Identifies a specific communication point within
an IP address - Some ports are assigned as contact points for
application services
26Socket Structure
socket interface
socket interface
Application 1
Application 2
user
user
kernel
kernel
Socket
Socket
Port
Underlying communication Protocols
Underlying communication Protocols
Communications network
Network Interface (IP address)
Figure 2.16
27A stream application
Create a socket
Connect to protocol and port
listen for clients
wait for and connect to client
connect to server
read a block of data
write a block of data
close client connection
Figure 2.17
28A datagram client-server application
Server
socket()
Client
socket()
bind()
bind()
wait for data from client
recvfrom()
send data to server
blocks until server
sendto()
data
receives data from client
send data to client
sendto()
data
receive data from server
recvfrom()
close()
close()
Figure 2.18
29Internet application protocol basic
- Most protocols use a TCP/IP Control Channel
- One per session
- Opened to a unique port (FTP21, HTTP80, etc.)
- ASCII (text) commands and responses with numeric
codes - Many use auxiliary data connections
- Opened on demand to temporary ports
- may exchange text or binary data
- Documented online via RFCs at www.ietf.org
30Internet Protocol Philosophy
- Protocols should be readable by both humans and
machines - Use text, not arbitrary binary encodings (not
like ITU) - Easily implemented by people without protocol
analyzers - Protocols should allow extensions
- Use keywords, not positions to identify
parameters - Allow extension and options without breaking the
old protocol.
31Internet applications - Telnet
- Designed to exchange characters from a terminal
to a mainframe computer - options for terminal control, editing, character
sets, echoing, etc. - Forms the basis for control channels for other
protocols - You can telnet to an FTP server, mail server,
web server, news server, etc.
32Example File Transfer
User Interface
Control Connection
Text commands and responses (one connection)
User PI
Server PI
Data Connection
User DTP
Server DTP
File data (created on demand)
User FTP
Server FTP
PI Protocol interpreter DTP Data transfer
process
Figure 2.19
33Standard response codes (FTP)
- 1yz positive reply, but action in progress
- 2yz success, action done
- 3yz intermediate success more information
needed to complete - 4yz transient failure resend later
- 5yz permanent failure dont retry
- x0z syntax errors
- x1z information messages
- x2c connection errors
- x3c authentication information or errors
- x4c unspecified errors
- x5c file system status and errors
34Some useful utilities
- ping
- exchanges data with another internet node
- times round-trip delay
- traceroute
- determines routing of a request through routers
- ipconfig
- displays network addresses and protocols
- can refresh dynamic addresses
Figure 2.20
35Delay and Loss analysis
- Key part of design (sizing capacities of links,
elements, etc.) - Very complicated topic
- We will use simple approximations
- Some more detail in Appendix A
- Beware of simple approximations!
36Simple network element model
Delay Box Multiplexer Switch Network
Message, Packet, Cell Arrivals
Message, Packet, Cell Departures
Rate?
T seconds
Rate?
Lost or Blocked
Fraction Pb
Figure A.1
37Arrival times and rates
n1
A(t)
n
n-1
2
1
t
?2
?n
?1
?n1
0
?3
Time of nth arrival ?1 ?2 . . . ?n
n arrivals
1
Arrival Rate (?)
1
E?
?1 ?2 . . . ?n seconds
(?1?2 ...?n)/n
Arrival Rate 1 / mean interarrival time
38Waiting time intervals
A(t)
T7
Assumes first-in first-out
T6
T5
T4
D(t)
T3
T2
T1
Arrivals
C1
C2
C3
C4
C5
C6
C7
C1
C2
C3
C4
C5
C6
C7
Departures
- Waiting time for ith packet is difference between
ith arrival and departure times
Figure A.4
39Littles Formula
EN ?ET
- ET Expected Value of the waiting time
- EN Expected Value of the number waiting
- Alternatively average waiting time average
number waiting divided by the arrival rate. - If I know that 100 students use an ATM in an
hour, and on average 10 are in line to use it,
how long is the wait? - If ping tells me it takes 100 ms to get a
response to a packet from a server, and I want to
send 500 packets per second, how many will on
average be sent before I get a response to the
first?
40A basic queuing model
Servers
Arrival process
1
Queue
A(t)
D(t)
2
t
t
?
?i
?i1
c
B(t)
X
Service time
? 1/E?
?i 1/EXi
Figure A.6
41Exponential arrival times
P?gtt e-?t E? 1/?
PAtk (?t)k/k!e-?t At being of
arrivals in time t
- Exponential arrival distributions can be analyzed
- Exponential arrival distributions arise naturally
in many places - Arrivals from many independent sources
42Queuing System Classes
Arrival Process / Service Time / Servers / Max
Occupancy
Interarrival times ? M exponential D
deterministic G general Arrival
Rate ???????E?
Service times X M exponential D
deterministic G general Service
Rate ???????EX
K customers unspecified if unlimited
1 server c servers infinite
Multiplexer Models M/M/1/K, M/M/1, M/G/1,
M/D/1 Trunking Models M/M/c/c, M/G/c/c User
Activity M/M/?, M/G/ ?
Figure A.7
43A complete model
N(t) number in system
N(t) Nq(t) Ns(t)
Nq(t) number in queue
Ns(t)
Nq(t)
Ns(t) number in service
1
?????Pb)
2
?
?
T total delay
c
W
X
W waiting time
??Pb
T W X
X service time
EN ?(1-Pb) ET Littles formula for the
system
ENq ?(1-Pb) EW Littles formula for the
queue
ENs ?(1-Pb) EX Littles formula for the
servers
Figure A.8
44An M/M/1 Queue
Infinite buffer
????????X?
Poisson arrivals rate ?
State Model (each state is in the buffer)
1 - (???????t
1 - (???????t
1 - (???????t
1 - (???????t
1 - (???????t
1 - ???t
???t
???t
???t
???t
n
2
n-1
0
1
n1
???t
???t
???t
???t
P1 arrival ???t P1 departure ???t Pno
changes 1 - (???????t
Figure A.9
45Analyzing the steady state
- If the system is stable, probabilities dont
change - Transitions from n1 to n and from n to n1 must
be equal - pn1??t pn??t , or pn1 (?/?) pn ? pn
- Probabilities must sum to 1, implying
- p0 1/ (1-?)
- Now find the average of the series ?i/(1-?)
- EN ?/ (1-?)
- ET (1/?)/(1-?)
- EW ET-EX ?(1/?)/(1-?)
46Scaling and Performance
?
?
?
m separate systems
m?
One consolidated system
?
versus
m?
?
?
Et ?
Et (1/?)/(1-?)
Figure A.11
47Queue classes and Delay
M/D/1
M/
Er/1
M/M/1
M/H/1
Interarrivals
Constant
Erlang
Exponential
Hyperexponential
lt1
VarX/EX2
0
gt1
1
gt1
EW/EWM/M/1
1/2
1/2lt , lt1
1
- Delay depends on variance of service times
- Constant times have half the delay of exponential
Figure A.13
48Trunk usage and blocking
N(t)
Poisson arrivals
1
Limited number of trunks
Many lines
?????Pb)
2
?
?
c
??Pb
EX1/?
- Blocked calls are cleared from the system no
waiting allowed. - Performance parameter Pb fraction of arrivals
that are blocked - Pb PN(t)c B(c,a) where a???
- B(c,a) is the Erlang B formula which is valid for
any service time distribution
Figure A.14
49For the Next class
- Problem Set 2 (due at start of class)
- Read Chapter 3 Sections 3.1-3.5
- We will go over problems from problem set 1.