Professional Documents
Culture Documents
Networks
(IN 2510)
Dr. C. Amalraj
13/05/2016
The University of Moratuwa
amalraj@uom.lk
Lecture 12:
Data-link Layer
Data-Link
Layer
Position of the data-link layer
Data link layer duties
LLC and MAC sublayers
IEEE standards for LANs
Error Detection
and Correction
Error Detection and Correction
Data can be corrupted during
transmission. For reliable communication,
error must be detected and corrected
Error Detection and Correction are
implemented either at the data link
layer and at the transport layer of the
OSI model
Type of Errors
Type of Errors(contd)
Single-Bit Error
~ is when only one bit in the data unit has changed
Type of Errors(contd)
Multiple-Bit Error
~ is when two or more nonconsecutive bits in the
data unit have changed(ex : ASCII B - ASCII LF)
Type of Errors(contd)
Burst Error
~ means that 2 or more consecutive bits in the data
unit have changed
Detection
Error detection uses the concept of redundancy,
which means adding extra bits for detecting
errors at the destination
Detection(contd)
Redundancy
Detection(contd)
Detection(contd)
Parity Check
A parity bit is added to every data unit so that the total number of
1s (including the parity bit) becomes even for even-parity check or
odd for odd-parity check
Simple parity check
Detection - Examples
Example 1
Suppose the sender wants to send the word world. In
ASCII the five characters are coded as
1110111 1101111 1110010 1101100 1100100
The following shows the actual bits sent
11101110 11011110 11100100 11011000 11001001
Detection - Examples
Example 2
11100111
11011101
00111001
10101001
10101010
Receiving
1. Receive F(x)
2. Divide F(x) by P(x)
3. Accept if remainder is 0, reject otherwise
Example
Send
Receive
M(x) = 110011 x5+x4+x+1 (6 bits)
P(x) = 11001 x4+x3+1 (5 bits, n = 4) 11001 1100111001
4 bits of redundancy 11001
Form xnM(x) 110011 0000 11001
x9+x8+x5+x4
11001
Divide xnM(x) by P(x) to find C(x)
00000
100001
No remainder
11001 1100110000 Accept
11001
10000
11001
1001 = C(x)
Send the block 110011 1001
Detection(contd)
CRC generator
~ uses modular-2 division.
Binary Division
in a
CRC Generator
Detection(contd)
Binary Division
in a
CRC Checker
Detection(contd)
Polynomials
CRC generator(divisor) is most often represented not
as a string of 1s and 0s, but as an algebraic polynomial.
Detection(contd)
A polynomial representing a divisor
Detection(contd)
Standard polynomials
Detection(contd)
Checksum
~ used by the higher layer protocols
~ is based on the concept of redundancy(VRC,
LRC, CRC .)
Detection(contd)
Checksum Generator
Detection(contd)
at a sender
Original data : 10101001 00111001
10101001
00111001
--------------
11100010 Sum
00011101 Checksum
10101001 00111001 00011101 data sent
Detection(contd)
Example ( at a receiver)
Received data : 10101001 00111001 00011101
10101001
00111001
00011101
---------------
11111111 Sum
00000000 Complement
Web and
HTTP
Web and HTTP
First some jargon
Web page consists of objects
Object can be HTML file, JPEG image, Java applet,
audio file,
Web page consists of base HTML-file which
includes several referenced objects
Each object is addressable by a URL
Example URL:
www.someschool.edu/someDept/pic.gif
host name path name
HTTP overview
time
6. Steps 1-5 repeated for each
of 10 jpeg objects
Response time modeling
Definition of RTT: time to send
a small packet to travel from
client to server and back.
initiate TCP
Response time: connection
one RTT to initiate TCP RTT
connection request
file
one RTT for HTTP request RTT
time to
transmit
and first few bytes of HTTP file
response to return file
received
file transmission time
total = 2RTT+transmit time time time
Persistent HTTP
Nonpersistent HTTP issues: Persistent without pipelining:
requires at least 2 RTTs per client issues new request only
object when previous response has
OS must work and allocate host been received
resources for each TCP at least one RTT for each
connection referenced object
but browsers often open parallel Persistent with pipelining:
TCP connections to fetch default in HTTP/1.1
referenced objects client sends requests as soon as
Persistent HTTP it encounters a referenced
server leaves connection open object
after sending response may be as little as one RTT for
subsequent HTTP messages all the referenced objects
between same client/server are
sent over connection
HTTP request message
two types of HTTP messages: request, response
HTTP request message:
ASCII (human-readable format)
request line
(GET, POST, GET /somedir/page.html HTTP/1.1
HEAD commands) Host: www.someschool.edu
User-agent: Mozilla/4.0
header Connection: close
lines Accept-language:fr
URL method:
Uses GET method
Input is uploaded in URL field of request line:
www.somesite.com/animalsearch?monkeys&banana
Method types
HTTP/1.0 HTTP/1.1
GET GET, POST, HEAD
POST PUT
HEAD uploads file in entity body
to path specified in URL
asks server to leave
field
requested object out of
response DELETE
deletes file specified in the
URL field
HTTP response message
status line
(protocol
status code HTTP/1.1 200 OK
status phrase) Connection: close
Date: Thu, 06 Aug 1998 12:00:15 GMT
Server: Apache/1.3.0 (Unix)
header
Last-Modified: Mon, 22 Jun 1998 ...
lines
Content-Length: 6821
Content-Type: text/html
200 OK
request succeeded, requested object later in this message
301 Moved Permanently
requested object moved, new location specified later in this
message (Location:)
400 Bad Request
request message not understood by server
404 Not Found
requested document not found on this server
505 HTTP Version Not Supported
Trying out HTTP (client side) for yourself
client server
Cookie file
usual http request msg
amazon: 1678 cookie: 1678 cookie-
ebay: 8734 specific
usual http response msg action
one week later:
client
origin
server
More about Web caching
Cache acts as both client and Why Web caching?
server Reduce response time for
Typically cache is installed by client request.
ISP (university, company, Reduce traffic on an
residential ISP) institutions access link.
Internet dense with caches
enables poor content
providers to effectively deliver
content (but so does P2P file
sharing)
Caching example
origin
Assumptions
servers
average object size = 100,000 bits
public
avg. request rate from institutions Internet
browsers to origin servers =
15/sec
delay from institutional router to
1.5 Mbps
any origin server and back to access link
router = 2 sec
institutional
Consequences network
10 Mbps LAN
utilization on LAN = 15%
utilization on access link = 100%
total delay = Internet delay + access
delay + LAN delay institutional
= 2 sec + minutes + milliseconds cache
Caching example (cont.)
origin
Possible solution
servers
increase bandwidth of access link
public
to, say, 10 Mbps
Internet
Consequences
utilization on LAN = 15%
utilization on access link = 15%
10 Mbps
Total delay = Internet delay + access access link
delay + LAN delay
institutional
= 2 sec + msecs + msecs
network
often a costly upgrade 10 Mbps LAN
institutional
cache
Caching example (cont.)
origin
Install cache servers
suppose hit rate is .4 public
Consequence Internet
40% requests will be satisfied
almost immediately
60% requests satisfied by origin
server 1.5 Mbps
access link
utilization of access link reduced
to 60%, resulting in negligible institutional
delays (say 10 msec) network
10 Mbps LAN
total avg delay = Internet delay
+ access delay + LAN delay =
.6*(2.01) secs + milliseconds <
1.4 secs
institutional
cache
Conditional GET
cache server
Goal: dont send object if cache
has up-to-date cached version HTTP request msg
cache: specify date of cached If-modified-since:
<date> object
copy in HTTP request not
If-modified-since: modified
<date> HTTP response
HTTP/1.0
server: response contains no 304 Not Modified
object if cached copy is up-to-
date:
HTTP request msg
HTTP/1.0 304 Not If-modified-since:
Modified <date> object
modified
HTTP response
HTTP/1.0 200 OK
<data>
P2P file sharing
P2P file sharing
Alice chooses one of the peers,
Example Bob.
Alice runs P2P client File is copied from Bobs PC to
application on her Alices notebook: HTTP
notebook computer While Alice downloads, other
Intermittently connects to users downloads/uploads
Internet; gets new IP to/from Alice.
address for each Alices peer is both a Web client
connection and a transient Web server.
Asks for Hey Jude All peers are servers = highly
Application displays other scalable!
peers that have copy of
Hey Jude.
P2P: centralized directory
Bob
original Napster design centralized
directory server
1) when peer connects, it 1
informs central server: peers
IP address 1
content
1 3
2) Alice queries for Hey
2 1
Jude
3) Alice requests file from Bob
Alice
P2P: problems with centralized directory
Overlay
edge
Query flooding: Gnutella
Scalability:
limited scope
flooding
Gnutella: Peer joining
controlled by
controlled by process application
application process
developer
developer socket socket
TCP with TCP with controlled by
controlled by
buffers, operating
operating buffers, internet system
system variables variables
host or host or
server server
Socket programming with TCP
inFromUser
input (inFromUser stream) , input
stream
sends to server via socket Client
(outToServer stream) Process
process
2) server reads line from socket
3) server converts line to uppercase,
sends back to client
inFromServer
outToServer
4) client reads, prints modified line output input
from socket (inFromServer stream stream
stream)
client TCP
clientSocket
socket TCP
socket
write reply to
connectionSocket read reply from
clientSocket
close
connectionSocket close
clientSocket
Socket programming with UDP
create socket,
create socket,
port=x, for clientSocket =
incoming request: DatagramSocket()
serverSocket =
DatagramSocket()
Create, address (hostid, port=x,
send datagram request
read request from using clientSocket
serverSocket
write reply to
serverSocket
specifying client read reply from
host address, clientSocket
port number close
clientSocket
Summary
Our study of network apps now complete!
Application architectures specific protocols:
client-server HTTP
P2P FTP
hybrid SMTP, POP, IMAP
application service DNS
requirements: socket programming
reliability, bandwidth, delay
Internet transport service
model
connection-oriented, reliable:
TCP
unreliable, datagrams: UDP
Summary
Most importantly: learned about protocols
typical request/reply
message exchange: centralized vs.
client requests info or decentralized
service stateless vs. stateful
server responds with data, reliable vs. unreliable
status code msg transfer
message formats:
headers: fields giving info
about data
data: info being
communicated