You are on page 1of 543

CENG435 Data Communications and

Networking
2017-2018 Fall

Dr. Ertan Onur

WINS Lab

2017-2018 Fall
Courseware

Section 1

Courseware
Courseware

Logistics

I 2016-2017 Fall (3 Credits)


I Section 1
I Fridays (BMB4, 13:40 - 15:30)
I Wednesdays (BMB5, 11:40 - 12:30)
I Section 2
I Fridays (BMB4, 10:40 - 12:30)
I Wednesdays (BMB5, 12:40 - 13:30)

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 1 / 487


Courseware

Lecturer

I Ertan Onur
I Room: Z019 (WINS Lab) or B211 (Dept. of Computer Eng.)
I Tel: +90 (312) 210 5534
I Email: eronur@metu.edu.tr
I Office Hours: (Fridays) 09:30-10:30 and by appointment

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 2 / 487


Courseware

Teaching Assistants

I Alperen Eroğlu, alperen@ceng.metu.edu.tr, 5535, B205


I M. Cagri Kaya, mckaya@ceng.metu.edu.tr, 5592, A402

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 3 / 487


Courseware

Communication

I Mainly MOODLE: http://odtuclass.metu.edu.tr/


I COW: http://cow.ceng.metu.edu.tr (Only for newsgroup)

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 4 / 487


Courseware

Textbook

Textbook
Kurose, J.F. and Ross, K.W., Computer
Networking: A Top-down Approach, 6th
Ed., Pearson, 2013
(http://www.pearsonhighered.com/
kurose-ross/)

Supplemental Book
Tanenbaum, A. S. and Wetherall, D.,
Computer Networks, 5th Ed., Prentice Hall,
2011 (http://computernetworks5e.org)

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 5 / 487


Courseware

Intended Audience

This textbook is for a first course on computer networking. It can be used in


both computer science and electrical engineering departments. In terms of
programming languages, the book assumes only that the student has
experience with C, C++, Java, or Python (and even then only in a few
places). Although this book is more precise and analytical than many other
introductory computer networking texts, it rarely uses any mathematical
concepts that are not taught in high school. We have made a deliberate
effort to avoid using any advanced calculus, probability, or stochastic process
concepts (although we’ve included some homework problems for students
with this advanced background). The book is therefore appropriate for
undergraduate courses and for first-year graduate courses. It should also
be useful to practitioners in the telecommunications industry. (Kurose and
Ross, 2013).

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 6 / 487


Courseware

Disclaimer

Some of these slides are identical to those published by


I Jim Kurose and Keith Ross (Kurose and Ross, 2013).
I Andrew Tanenbaum and David Wetherall (Tanenbaum and
Wetherall, 2011).

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 7 / 487


Courseware

Course Objectives

At the end of this course, YOU will be able to:


1. Understand the basic principles of communication protocols in the context of the Internet.
2. Explain the operation and architecture of the Internet including the software and hardware
components to provide Internet services.
3. Compare and contrast various application layer protocols such as HTTP, SMTP, DNS;
connection-oriented communication protocols such as TCP and connectionless
communication protocols such as UDP at transport layer; virtual-circuit and packet
switching at network layer; link-state and distance-vector routing at network layer; and
multiple access techniques at link layer.
4. Devise protocols for reliable data transfer over unreliable channels, congestion control or
flow control either in the user or kernel space of operating systems at the transport layer.
5. Design and implement networking protocols at any layer of the OSI communication stack
above the physical layer using socket programming interface.

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 8 / 487


Courseware

Course Outline

Introduction and physical layer . . . . (Chapter 1) . . . . 9 hours


Application layer . . . . . . . . . . . (Chapter 2) . . . . . . . . . . . 6 hours
Transport layer . . . . . . . . . . . . (Chapter 3) . . . . . . . . . . . . 9 hours
Network layer . . . . . . . . . . . . . (Chapter 4) . . . . . . . . . . . . . 9 hours
Link layer . . . . . . . . . . . . . . .(Chapter 5) . . . . . . . . . . . . . . .6 hours

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 9 / 487


Courseware

Assessment and Grading

Assignments (×2) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13+17%


Midterm exams (×2) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17+20%
Final . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33%

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 10 / 487


Courseware

Rules

Academic Honesty: There will be no tolerance to cheating in the


exam, to plagiarism (copying someone else’s work as if it is yours) and
to taking advantage in group assignments and projects. The student
who cheats will fail the course and be punished according to METU
regulations.
Attendance Policy: Attendance may play a critical role in the exams.
Participation in the discussions is strongly encouraged.
NA Grade: Regardless of your overall grade at the end of the class,
you will get an NA grade if you have no valid assignment submissions
or if you have not attended at least one of the midterms. Empty/dummy
assignment submissions will not be considered as a valid submission.

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 11 / 487


Computer Networks and the Internet

Section 2

Computer Networks and the Internet


Computer Networks and the Internet

What is This?

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 12 / 487


Computer Networks and the Internet

Objectives of the Lecture

At the end of this lecture, you will be able to


define the context of this course and explain the introductory concepts
(protocol, packet- and circuit-switching, reference models and security)
in networking

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 13 / 487


Computer Networks and the Internet

Overview and Compulsory Reading

I Focus of the course


I What’s the Internet? What’s a protocol? . . . . . . . . . . . . . . . . . . . . . . 1.1
I Network edge; hosts, access net, physical media . . . . . . . . . . . . . 1.2
I Network core: switching, Internet structure . . . . . . . . . . . . . . . . . . . . 1.3
I Protocol layers, service models . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.5
I Security (reading) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.6
I History (reading) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.7

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 14 / 487


Computer Networks and the Internet

Ticket to Retention (TtR) Questions

1. Packet- versus circuit-switching: Suppose that all of the network


sources are bursty -that they only occasionally have data to send.
Would packet-switching or circuit switching be more desirable in
this case? Why?
2. Network of networks: Draw figures representing the evolution of
the structure of the Internet.
3. Protocol layers: Draw a figure showing the layers of the Internet
stack, associate each layer with the name of packets processed at
that layer and the task(s) of the layer.

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 15 / 487


Computer Networks and the Internet Focus of the Course

Focus of the Course

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 16 / 487


Computer Networks and the Internet Focus of the Course

Focus of the Course

Distributed Systems Applications


Networking Packets
Communications Signals

Scope
We are focusing on networking that is in the middle. Networks enable
distributed applications by using and organizing the
communication technologies.

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 17 / 487


Computer Networks and the Internet Focus of the Course

Focus of the Course


Why Do You Take This Course?

Your Objectives in this Course


What do you want to be able to do at the end of this course?

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 18 / 487


Computer Networks and the Internet Focus of the Course

Focus of the Course


Why Do You Take This Course?

Your Objectives in this Course


What do you want to be able to do at the end of this course?

I We use the Internet a lot. Learning how it works.


I What is TCP/IP, ADSL, LTE, etc?
I As engineers, we may design new networks. Learning the
principles of a successful system, the Internet.
I Societal and economic impact of the Internet.
I Evolution/revolution?

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 18 / 487


Computer Networks and the Internet Focus of the Course

Focus of the Course


What happens on the Internet in a minute. (Source: INTEL)

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 19 / 487


Computer Networks and the Internet Focus of the Course

Focus of the Course


Why do we build networks?

What are the example uses of the networks?


I Work: email, file sharing, ...
I Home: listening to music, measuring temperature, ...
I Mobile: navigation, ...

Why do we build networks?


Human and/or computer communication, resource sharing, content
delivery, cyberphysical systems and connected digital world ...

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 20 / 487


Computer Networks and the Internet What is the Internet?

What is the Internet?


Elements of a Data Network

THINK PAIR SHARE


Plot figures illustrating relationships
among network elements

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 21 / 487


Computer Networks and the Internet What is the Internet?

What is the Internet?


Elements of a Data Network

Example:

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 22 / 487


Computer Networks and the Internet What is the Internet?

What is the Internet?


Network (Nuts and Bolts) View

I millions of connected
computing devices: hosts (end
systems) running network
applications
I communication links (fiber,
copper, radio, satellite) with a
transmission rate (bandwidth)
I Packet switches and routers:
forward packets (chunks of
data)

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 23 / 487


Computer Networks and the Internet What is the Internet?

What is the Internet?


Network (Nuts and Bolts) View

I Internet: “network of
networks”: Interconnected
Internet Service Providers
(ISP)
I protocols control sending,
receiving of messages; e.g.,
TCP, IP, HTTP, Skype, 802.11
I Internet standards; RFC:
Request for comments, IETF:
Internet Engineering Task
Force

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 24 / 487


Computer Networks and the Internet What is the Internet?

What is the Internet?


Turkey: ULAKNET (http://www.ulakbim.gov.tr/ulaknet)

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 25 / 487


Computer Networks and the Internet What is the Internet?

What is the Internet?


Turkey: TeknoTel Satellite (http://www.teknotel.com)

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 26 / 487


Computer Networks and the Internet What is the Internet?

What is the Internet?


Turkey: TTNET-PANTEL Fiber (http://www.turktelekomint.com)

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 27 / 487


Computer Networks and the Internet What is the Internet?

What is the Internet?


Service View

I Infrastructure that provides


services to applications: Web,
VoIP, email, games,
e-commerce, social nets.
I Provides programming
interface to applications
I hooks that allow sending
and receiving application
programs to “connect” to
Internet
I provides service options,
analogous to postal service

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 28 / 487


Computer Networks and the Internet What is the Internet?

What is the Internet?


Information-centric View (HOT RESEARCH TOPIC)
I Network of Information
I Main purpose is to acquire information

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 29 / 487


Computer Networks and the Internet What is the Internet?

What is a Protocol?

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 30 / 487


Computer Networks and the Internet What is the Internet?

What is a Protocol?

Definition of Protocol
A protocol defines the format and the order of messages exchanged
between two or more communicating entities, as well as the actions
taken on the transmission and/or receipt of a message or other event.

Mastering Computer Networking


Mastering the field of computer networking is equivalent to
understanding the what, why, and how of networking protocols

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 31 / 487


Computer Networks and the Internet What is the Internet?

Practice What You Preach


Protocols: Brainstorm

In a lecture, there are many students. Sometimes


students want to ask a question to the teacher.
I What are the issues here?
I What kind of a protocol can you employ?
Why?

PAIR UP and
DISCUSS

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 32 / 487


Computer Networks and the Internet What is the Internet?

Practice What You Preach


Protocols: Brainstorm

In a lecture, there are many students. Sometimes


students want to ask a question to the teacher.
I What are the issues here?
I What kind of a protocol can you employ?
Why?

Typical answer
I Collisions, two or more students talking
simultaneously; medium reservation for
avoiding collisions.
PAIR UP and
I Raise the hand, get permission from lecturer,
DISCUSS
ask, listen, ack.

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 32 / 487


Computer Networks and the Internet What is the Internet?

Practice What You Preach


Protocols: Brainstorm
Assume that you cannot directly talk to your
partner in a crowded party. You can only talk to
your neighbor(s). How can you send a message
to your partner (with the help of neighbors) when
your partner is far away from you?
I What are the issues here?
I What kind of a protocol can you employ?
Why?

PAIR UP and
DISCUSS

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 33 / 487


Computer Networks and the Internet What is the Internet?

Practice What You Preach


Protocols: Brainstorm
Assume that you cannot directly talk to your
partner in a crowded party. You can only talk to
your neighbor(s). How can you send a message
to your partner (with the help of neighbors) when
your partner is far away from you?
I What are the issues here?
I What kind of a protocol can you employ?
Why?

Typical answer
PAIR UP and I Discovering neighbors, learning the topology,
DISCUSS routing decisions, ...
I Routing protocols

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 33 / 487


Computer Networks and the Internet Network Edge

Network Edge
End-system Interaction

Scenario: Assume you access


Google from your smartphone
connected to a mobile network.

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 34 / 487


Computer Networks and the Internet Network Edge

Network Edge
Access Network

I Network edge: hosts: clients


and servers
I Access networks, physical
media: wired, wireless
communication links
I Network core: interconnected
routers, network of networks

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 35 / 487


Computer Networks and the Internet Network Edge

Network Edge
Access Network

Access Network
The network that physically connects an end system to the first router
-also known as the “edge router”- on a path from the end system to
any other distant end system

Examples:
I Home Access: DSL, Cable, FTTH, Dial-Up, and Satellite
I Access in the Enterprise (and the Home): Ethernet and WiFi
I Wide-Area Wireless Access: 3G and LTE

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 36 / 487


Computer Networks and the Internet Network Edge

Network Edge
Digital Subscriber Line (DSL) Internet Access

I Use existing telephone line to central office DSLAM


I Data over DSL phone line goes to Internet
I Voice over DSL phone line goes to telephone net
Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 37 / 487
Computer Networks and the Internet Network Edge

Network Edge
A Hybrid Fiber Coaxial access Network

I Asymmetric: up to 30Mbps downstream transmission rate, 2 Mbps


upstream transmission rate
I Homes share access network to cable headend unlike DSL, which
Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 38 / 487
Computer Networks and the Internet Network Edge

Network Edge
Fiber to The Home (FTTH)

I Optical fiber path from central office to home


I Gigabits per second
Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 39 / 487
Computer Networks and the Internet Network Edge

Network Edge
Ethernet Internet Access

I Typically used in companies, universities, ...


I 10 Mbps, 100Mbps, 1Gbps, 10Gbps transmission rates
IDr. Today, end Lab)
Ertan Onur (WINS systems typicallyCENG435
connect into Ethernet switch
2017-2018 Fall 40 / 487
Computer Networks and the Internet Network Edge

Network Edge
A Typical Home Network

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 41 / 487


Computer Networks and the Internet Network Edge

Network Edge
Wireless Access Networks

I provided by telco (cellular)


I within building (30-40 meters) operator, 10’s of kilometers
I 802.11b/g (WiFi): 11, 54 Mbps I between 1 and 10 Mbps
transmission rate I 3G, 4G: LTE

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 42 / 487


Computer Networks and the Internet Network Core

Network Core

I mesh of interconnected
routers

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 43 / 487


Computer Networks and the Internet Network Core

Network Core
Packet- and Circuit-Switching

Packet switching
Hosts break application-layer Circuit Switching
messages into packets and End-to-end resources are allocated
packets are sent as soon as they to and reserved for the call
are available. No need to setup a between source and destination. A
dedicated path in advance. dedicated (physical) path is setup
Routers use store-and-forward in advance.
transmission.

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 44 / 487


Computer Networks and the Internet Network Core

Network Core
Packet-switching: Store-and-forward

I takes L/R seconds to transmit L-bit


packet into link at R bps
I store and forward: entire packet must
arrive at router before it can be
transmitted on next link
I end-end delay = 2L/R (assuming 0
propagation delay)
Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 45 / 487
Computer Networks and the Internet Network Core

Network Core
Packet-switching: Store-and-forward

I takes L/R seconds to transmit L-bit


packet into link at R bps
Question
I store and forward: entire packet must
L = 7.5 Mbits R = 1.5 Mbps
arrive at router before it can be
What is the one-hop
transmitted on next link
transmission delay?
I end-end delay = 2L/R (assuming 0
propagation delay)
Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 45 / 487
Computer Networks and the Internet Network Core

Network Core
Packet-switching: Store-and-forward

I takes L/R seconds to transmit L-bit


packet into link at R bps
Question
I store and forward: entire packet must
L = 7.5 Mbits R = 1.5 Mbps
arrive at router before it can be
What is the one-hop
transmitted on next link
transmission delay? 5sec.
I end-end delay = 2L/R (assuming 0
propagation delay)
Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 45 / 487
Computer Networks and the Internet Network Core

Practice What You Preach


Packet-switching: Brainstorm

Consider the general case of sending one packet


from source to destination over a path consisting
of N links each of rate R? What is the end-to-end
transmission delay?

Hint
There are N − 1 routers.

PAIR UP and
DISCUSS

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 46 / 487


Computer Networks and the Internet Network Core

Practice What You Preach


Packet-switching: Brainstorm

Consider the general case of sending one packet


from source to destination over a path consisting
of N links each of rate R? What is the end-to-end
transmission delay?

Hint
There are N − 1 routers.

Answer
PAIR UP and L
NR
DISCUSS

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 46 / 487


Computer Networks and the Internet Network Core

Network Core
Queueing Delays and Packet Loss

I If arrival rate (in bits) to link exceeds transmission rate of link for a
period of time:
I packets will queue, wait to be transmitted on link
I packets can be dropped (lost) if memory (buffer) fills up

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 47 / 487


Computer Networks and the Internet Network Core

Network Core
Two Key Network Core Functions

Routing (control plane) Forwarding (data plane)


Determines source-destination Move packets from router’s input to
route taken by packets appropriate router output

IN-CLASS ACTIVITY
There are two steps:
1. Assume that you are connected to (i.e., can communicate
with) those friends of yours within 1 meter range.
Determine the shortest route to another random friend of
yours.
2. Send a piece of text message to the selected friend over
the shortest route.

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 48 / 487


Computer Networks and the Internet Network Core

Network Core
Alternative Core: Circuit Switching

I In diagram, each link has four


circuits
I call gets 2nd circuit in top link
and 1st circuit in right link

THINK PAIR
SHARE
What are the
advantages and
disadvantages of
circuit switching
compared to packet
switching?

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 49 / 487


Computer Networks and the Internet Network Core

Network Core
Packet- and Circuit-Switching

Packet switching Circuit Switching


End-end resources allocated to,
Hosts break application-layer
reserved for call between source
messages into packets
and destination.
I shared resources
I dedicated resources, no
I forward packets from one sharing
router to the next, across links
I circuit-like (guaranteed)
on path from source to
performance
destination
I circuit segment idle if not used
I each packet transmitted at full
by call (no sharing)
link capacity
I Commonly used in telephone
I no call setup
networks

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 50 / 487


Computer Networks and the Internet Network Core

Practice What You Preach


Packet- versus Circuit-switching

Fill in the table? CS: Circuit switched, PS: Packet


Switched.
Item CS PS
Call setup required
Dedicated physical path
Packet follows the same route
Packets arrive in order?
Is a switch crash fatal?
Fixed bandwidth availability
PAIR UP and
Congestion at setup?
DISCUSS
Store and forward transmission?
Wasted bandwidth (potentially)

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 51 / 487


Computer Networks and the Internet Network Core

Network Core
Packet- and Circuit-Switching Comparison

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 52 / 487


Computer Networks and the Internet Network Core

Practice What You Preach


Circuit-switching: Brainstorm

You have one cable but many circuits? How is


this possible?

Hint
How do you schedule classroom(s) for different
courses?

PAIR UP and
DISCUSS

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 53 / 487


Computer Networks and the Internet Network Core

Practice What You Preach


Circuit-switching: Brainstorm

You have one cable but many circuits? How is


this possible?

Hint
How do you schedule classroom(s) for different
courses?

Answer
I Two courses at the same time in different
classrooms.
PAIR UP and I Two courses at different times in the same
DISCUSS classroom.

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 53 / 487


Computer Networks and the Internet Network Core

Network Core
Circuit Switching: FDM versus TDM

I FDM: Frequency-division multiplexing


IDr. TDM:
Ertan OnurTime-division
multiplexing
(WINS Lab) CENG435 2017-2018 Fall 54 / 487
Computer Networks and the Internet Network Core

Practice What You Preach


Packet-switching versus Circuit-switching

Suppose N users share a 1 Mbps link. Also


suppose that each user alternates between
periods of activity, when a user generates data at
a constant rate of 100 kbps, and periods of
inactivity, when a user generates no data.
Suppose further that a user is active only 10 per
cent of the time (and is idly drinking coffee during
the remaining 90 per cent of the time). How
many simultaneous users, N can this system
PAIR UP and support when circuit- or packet-switching is
DISCUSS employed?

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 55 / 487


Computer Networks and the Internet Network Core

Practice What You Preach


Packet-switching versus Circuit-switching

With circuit switching, 100 kbps must be


reserved for each user at all times. For example,
with circuit-switched TDM, if a one-second frame
is divided into 10 time slots of 100 ms each, then
each user would be allocated one time slot per
frame. Thus, the circuit-switched link can support
only 10 (= 1 Mbps/100 kbps) simultaneous
users.
PAIR UP and
DISCUSS

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 55 / 487


Computer Networks and the Internet Network Core

Practice What You Preach


Packet-switching versus Circuit-switching

With packet switching, the probability that a


specific user is active is 0.1. If there are 35 users,
the probability that there are 11 or more
simultaneously active users is approximately
0.0004 (minuscule). When there are 10 or fewer
simultaneously active users, the aggregate arrival
rate of data is less than or equal to 1 Mbps, the
output rate of the link. Thus, when there are 10 or
fewer active users, users’ packets flow through
the link essentially without delay, as is the case
PAIR UP and with circuit switching. Packet switching allows for
DISCUSS more than three times (35) the number of users.

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 55 / 487


Computer Networks and the Internet Network Core

Network Core
Internet Structure I

I End systems connect to Internet via access ISPs (Internet Service


Providers)
I Access ISPs in turn must be interconnected.

THINK PAIR SHARE


How would you connect millions of
access ISPs to each other? Connecting
each ISP to each other directly does
not scale: O N 2 connections.

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 56 / 487


Computer Networks and the Internet Network Core

Network Core
Internet Structure II

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 57 / 487


Computer Networks and the Internet Network Core

Network Core
Internet Structure III

I At the center there are small number of well-connected large


networks
I “tier-1” commercial ISPs (e.g., Level 3, Sprint, AT&T, NTT),
national & international coverage
I content provider network (e.g, Google): private network that
connects it data centers to Internet, often bypassing tier-1,
regional ISPs

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 58 / 487


Computer Networks and the Internet Layering

Layering
Modularity

The network does much for applications


I Make and break connections
I Find a path through the network
I Transfers information reliably
I Transfers arbitrary length information
I Send as fast as the network allows
I Shares bandwidth among users
I Secures information in transit
I Lets many new hosts be added
I ...

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 59 / 487


Computer Networks and the Internet Layering

Layering
Modularity

Modularity
We need a form of modularity to manage complexity and facilitate
reusability

Protocols and layering is the main structuring method used to divide


up network functionality
I Each instance of a protocol talks virtually to its peer using the
protocol
I Each instance of a protocol uses only the services of the lower
layer

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 60 / 487


Computer Networks and the Internet Layering

Layering
An Example: Taking an Airplane Trip

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 61 / 487


Computer Networks and the Internet Layering

Layering
An Example: Taking an Airplane Trip

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 62 / 487


Computer Networks and the Internet Layering

Layering
Protocols and Layers

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 63 / 487


Computer Networks and the Internet Layering

Layering
Protocol Stack

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 64 / 487


Computer Networks and the Internet Layering

Layering
Internet Protocol Stack and OSI Reference Model

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 65 / 487


Computer Networks and the Internet Layering

Layering
Internet Protocol Stack

I application: supporting network applications, FTP, SMTP, HTTP


I transport: process-process data transfer, TCP, UDP
I network: routing of datagrams from source to destination, IP,
routing protocols
I link: data transfer between neighboring network elements,
Ethernet, 802.11 (WiFi), PPP
I physical: bits “on the wire”
link + physical = interface

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 66 / 487


Computer Networks and the Internet Layering

Layering
Internet Protocol Stack

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 67 / 487


Computer Networks and the Internet Layering

Layering
ISO/OSI reference model

Internet Protocol Stack +


I presentation: allow applications to interpret meaning of data,
e.g., encryption, compression, machine, specific conventions
I session: synchronization, checkpointing, recovery of data
exchange
On the Internet, these functionalities are implemented in the
application layer.

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 68 / 487


Computer Networks and the Internet Layering

Practice What You Preach


Protocol Stack

What is the protocol stack when a web browser


on a host is wireless connected to the Internet?

PAIR UP and
DISCUSS

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 69 / 487


Computer Networks and the Internet Layering

Layering
Encapsulation

Encapsulation
Encapsulation is the mechanism used to effect protocol layering: lower
layer wraps higher layer content, adding its own information to make a
new message for delivery

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 70 / 487


Computer Networks and the Internet Layering

Layering
Encapsulation

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 71 / 487


Computer Networks and the Internet Layering

Layering
Encapsulation Example

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 72 / 487


Computer Networks and the Internet Layering

Layering
Encapsulation Example

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 73 / 487


Computer Networks and the Internet Layering

Practice What You Preach


Which Protocol?

For an incoming packet, how do you identify the


protocol associated with the packet?

PAIR UP and
DISCUSS

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 74 / 487


Computer Networks and the Internet Layering

Layering
Demultiplexing

Incoming message must be passed to the protocols that it uses

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 75 / 487


Computer Networks and the Internet Layering

Layering
Demultiplexing

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 76 / 487


Computer Networks and the Internet Layering

Layering
Advantages and Disadvantages

Advantages
Information hiding and reuse

Disadvantages
Information hiding and overhead

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 77 / 487


Computer Networks and the Internet Ticket to Retention

Ticket to Retention (TtR) Discussion


Summary - Main Learning Points

1. Packet- versus circuit-switching: Suppose that all of the network


sources are bursty -that they only occasionally have data to send.
Would packet-switching or circuit switching be more desirable in
this case? Why?
2. Network of networks: Draw figures representing the evolution of
the structure of the Internet.
3. Protocol layers: Draw a figure showing the layers of the Internet
stack, associate each layer with the name of packets processed at
that layer and the task(s) of the layer.

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 78 / 487


Physical Layer

Section 3

Physical Layer
Physical Layer

Objectives of the Lecture

At the end of this lecture, you will be able to


explain the elementary concepts in phsical layer such as signal
propagation, modulation, bit error rate and fundamental limits.

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 79 / 487


Physical Layer

Overview and Compulsory Reading

I Performance: loss, delay, throughput . . . . . . . . . . . . . . . . . . . . . . . . . 1.4


I Physical media . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Tanenbaum, 2.2
I Signals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Tanenbaum, 2.1
I Fundamental limits . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Tanenbaum, 2.1
I Modulation and multiplexing . . . . . . . . . . . . . . . . . . . . . Tanenbaum, 2.5
OPTIONAL: For a broad discussion on the topic, refer to Part II of
Stallings, W., Data and Computer Communications, 9th Ed., Prentice
Hall, 2010 (Stallings, 2013).

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 80 / 487


Physical Layer

Ticket to Retention (TtR) Questions

1. Fundamental limits: Why can we not transmit infinitely many bits


per second over a channel. What are the limits?
2. Signals over a wire: What happens to signals as they propagate
over a wire?
3. Base- and pass-band signals: How can we transmit baseband
signals over higher frequency carriers?

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 81 / 487


Physical Layer Introduction to Physical Layer

Physical Layer
Where Are We in the Course?

Physical layer
concerns how signals are used to
transfer bits over a link

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 82 / 487


Physical Layer Introduction to Physical Layer

Physical Layer
Simple Link Model

Abstraction of physical channel


I Rate (bandwidth, capacity, speed) in bits/sec
I Delay in seconds
I Broadcast or not?
I Error rate (related to the rate)

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 83 / 487


Physical Layer Introduction to Physical Layer

Physical Layer
Latency in Simple Link Model

I Transmission delay dt : time to put M bit frame on the wire


I Propagation delay dg : time for bits to propagate across the wire
I Latency D = dt + dg is the delay to send a message over a link

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 84 / 487


Physical Layer Introduction to Physical Layer

Physical Layer
Bandwidth-Delay Product

I Messages take space on the wire.


I The amount of data in flight is the bandwidth-delay product
BD = D × R (bits)
Example: Assume a cross country fiber: rate, R = 40 Mbps and
average delay, D = 50 ms. When fiber is broken, how much data do
you lose? BD = 40 × 106 × 50 × 10−3 = 2000 Kbits.

THINK PAIR SHARE


For store-and-forward switching, what
are the other types of delay?

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 85 / 487


Physical Layer Performance

Performance
How Do Loss and Delay Occur?

I packets queue in router buffers


I packet arrival rate to link (temporarily) exceeds output link capacity
I packets queue, wait for turn

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 86 / 487


Physical Layer Performance

Performance
How Do Loss and Delay Occur?

dn = dp + dq + dt + dg : total delay
I dp processing delay (checking bit errors, routing)
I dq queuing delay, time waiting at output links, depends on
congestion
I dt = L/R transmission delay where L is packet length and R is
link bandwidth
I dg = d/s propagation delay where d is length of physical link and s
Dr. is propagation
Ertan Onur (WINS Lab) speed in medium × 108 Fall
(in space it is c = 32017-2018
CENG435 m/s 87 / 487
Physical Layer Performance

Performance
Queueing Delay (Could be a course on its own)

I R link bandwidth (bps)


I L packet length (bits)
I a packet arrival rate
(packets/sec)
I When La/R ∼ 0, average
queueing delay is small
I When La/R ∼ 1, average
queueing delay is large
When La/R > 1, average
I
queueing delay is infinite
Use traceroute to measure end-to-end delay to routers.

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 88 / 487


Physical Layer Performance

Practice What You Preach


Queueing Delay

What happens when La/R > 1 and the queue


size is finite?
Hint
In a restaurant, the arrival rate of the customers
is larger than the service rate?

PAIR UP and
DISCUSS

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 89 / 487


Physical Layer Performance

Practice What You Preach


Queueing Delay

What happens when La/R > 1 and the queue


size is finite?
Hint
In a restaurant, the arrival rate of the customers
is larger than the service rate?

Answer
Queue fills up and packets will be dropped.
PAIR UP and Instable system. Large packet loss.
DISCUSS

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 89 / 487


Physical Layer Performance

Performance
Throughput
Throughput
rate (bits per unit time) at which bits transferred between
sender/receiver.
I instantaneous: rate at a given point in time
I average: rate over longer period of time

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 90 / 487


Physical Layer Performance

Performance
Throughput

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 91 / 487


Physical Layer Physical Media

Physical Media
I bit: propagates between transmitter-receiver pairs
I physical link: what lies between transmitter & receiver

Guided media
signals propagate in solid media: twisted pair, optical fiber, coaxial
cable

Unguided media
signals propagate freely, e.g., radio (wireless)

I Simplex: in one direction


I Half-duplex: both ends may transmit, but only one at a time
I Full-duplex: both ends may transmit simultaneously

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 92 / 487


Physical Layer Physical Media

Physical Media
Coaxial cable
Fiber optic cable
I two concentric copper
I glass fiber carrying light
conductors
pulses, each pulse a bit
I bidirectional
I high-speed 10’s-100’s Gpbs
I broadband:multiple channels
I low error rate
on cable, HFC

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 93 / 487


Physical Layer Physical Media

Physical Media
Electromagnetic Spectrum for Telecommunications

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 94 / 487


Physical Layer Physical Media

Physical Media
Transmission Characteristics of Guided Media

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 95 / 487


Physical Layer Physical Media

Physical Media
Transmission Characteristics of Guided Media

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 96 / 487


Physical Layer Physical Media

Physical Media
Radio

Types
Radio I Terrestrial microwave: up to
45 Mbps channels
I signal carried in
electromagnetic spectrum I LAN: (e.g., WiFi) 11Mbps, 54
Mbps
I no physical “wire”
I Wide-area: (e.g., cellular) 3G
I bidirectional
cellular: few Mbps
I propagation environment
I Satellite: Kbps to 45Mbps
effects: reflection, obstruction
channel (or multiple smaller
by objects, interference
channels), 270 msec end-end
delay

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 97 / 487


Physical Layer Signals

Signals
Analog and Digital Waveforms

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 98 / 487


Physical Layer Signals

Signals
Periodic Signals

s(t + T ) = s(t), −∞ < t < +∞ where T is the period of the signal


(smallest T value satisfying the equation)

A generic sine wave (sinusoid) s(t) = A sin (2πf t + φ)

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 99 / 487


Physical Layer Signals

Signals
Sinusoid s(t) = A sin (2πf t + θ)

sin(0)
x

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 100 / 487
Physical Layer Signals

Signals
Sinusoid s(t) = A sin (2πf t + θ)

sin(30)

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 100 / 487
Physical Layer Signals

Signals
Sinusoid s(t) = A sin (2πf t + θ)

sin(45)

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 100 / 487
Physical Layer Signals

Signals
Sinusoid s(t) = A sin (2πf t + θ)

sin(60)

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 100 / 487
Physical Layer Signals

Signals
Sinusoid s(t) = A sin (2πf t + θ)

sin(90)

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 100 / 487
Physical Layer Signals

Signals
Sinusoid s(t) = A sin (2πf t + θ)

sin(135)

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 100 / 487
Physical Layer Signals

Signals
Sinusoid s(t) = A sin (2πf t + θ)

sin(180)
x

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 100 / 487
Physical Layer Signals

Signals
Sinusoid s(t) = A sin (2πf t + θ)

sin(225)

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 100 / 487
Physical Layer Signals

Signals
Sinusoid s(t) = A sin (2πf t + θ)

sin(270)

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 100 / 487
Physical Layer Signals

Signals
Sinusoid s(t) = A sin (2πf t + θ)

sin(315)

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 100 / 487
Physical Layer Signals

Signals
Sinusoid s(t) = A sin (2πf t + θ)

sin(330)

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 100 / 487
Physical Layer Signals

Signals
Sinusoid s(t) = A sin (2πf t + θ)

sin(360)
x

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 100 / 487
Physical Layer Signals

Signals
Sinusoid s(t) = A sin (2πf t + θ)

s(t) = A sin (2πf t + θ)

Plot the sinusoids where


A = 1, f = 1, φ = 0
A = 0.5, f = 1, φ = 0
A = 1, f = 2, φ = 0
A = 1, f = 1, φ = π/4

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 101 / 487
Physical Layer Signals

Signals
Sinusoid s(t) = A sin (2πf t + θ)

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 102 / 487
Physical Layer Signals

Signals
Example: Let’s construct a periodic square wave

I Fourier analysis: any signal is made up of components at various


frequencies
I By adding together enough sinusoids (with appropriate amplitude,
frequency and phase), any electromagnetic signal can be
constructed.

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 103 / 487
Physical Layer Signals

Signals
4 1
 
Example: s(t) = π
sin(2πf t) + 3
sin(2π(3f )t)

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 104 / 487
Physical Layer Signals

Signals
4 1
 
Spectrum - Example: s(t) = π
sin(2πf t) + 3
sin(2π(3f )t)

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 105 / 487
Physical Layer Signals

Signals
4 1
 
Example: s(t) = π
sin(2πf t) + 3
sin(2π(3f )t) + . . .

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 106 / 487
Physical Layer Signals

Signals
Example

 
4 1 1
s(t) = sin(2πf t) + sin(2π(3f )t) + sin(2π(5f )t)
π 3 5
When the fundamental frequency f = 106 Hz = 1 MHz, what is the
bandwidth?
Answer
Bandwidth = 5f − f = 4f = 4 MHz.
T = 1016 = 1µs. Treat the waveform a sequence of 0s and 1s, one bit
occurs every 0.5µs for a data rate of 2 × 106 bps.

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 107 / 487
Physical Layer Signals

Signals
Example

 
4 1 1
s(t) = sin(2πf t) + sin(2π(3f )t) + sin(2π(5f )t)
π 3 5
When the fundamental frequency f = 2 × 106 Hz = 2 MHz, what is the
bandwidth?
Answer
Bandwidth = 5f − f = 4f = 8 MHz.
1
T = 2×10 6 = 0.5µs. Treat the waveform a sequence of 0s and 1s, one

bit occurs every 0.25µs for a data rate of 4 × 106 bps.

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 108 / 487
Physical Layer Signals

Signals
Example

Let’s filter out the 5f component.


 
4 1
s(t) = sin(2πf t) + sin(2π(3f )t)
π 3
When the fundamental frequency f = 2 × 106 Hz = 2 MHz, what is the
bandwidth?
Answer
Bandwidth = 3f − f = 2f = 4 MHz.
1
T = 2×10 6 = 0.5µs. Treat the waveform a sequence of 0s and 1s, one

bit occurs every 0.25µs for a data rate of 4 × 106 bps.

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 109 / 487
Physical Layer Signals

Signals
Conclusions of the Example

I Any digital waveform will have infinite bandwidth.


I Larger bandwidth = higher cost
I Practical and economic reasons dictate us to limit the bandwidth
(e.g., filtering out the 5f component out.)
I Limiting the bandwidth distorts (corrupts) the signal, the task of
the receiver becomes more difficult.

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 110 / 487
Physical Layer Signals

Signals
Conclusions of the Example

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 111 / 487
Physical Layer Signals

Signals
Acoustic Spectrum

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 112 / 487
Physical Layer Signals

Signals
Noise

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 113 / 487
Physical Layer Fundamental Limits

Signals
Signals over a Wire: What happens to a signal?

I The signal is delayed (propagates at 2c/3)


I The signal is attenuated
I Frequencies above a cutoff are highly attenuated
I Noise is added to the signal

Bandwidth
EE: width of frequency band in Hz
CS: information carrying capacity

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 114 / 487
Physical Layer Fundamental Limits

Signals
Channel Capacity

I Data rate: The rate, in bits per second (bps), at which data can be
communicated
I Bandwidth: The bandwidth of the transmitted signal as
constrained by the transmitter and the nature of the transmission
medium, expressed in Hertz
I Noise: The average level of noise over the communications path
I Error rate: The rate at which errors occur, where an error is the
reception of a 1 when a 0 was transmitted or the reception of a 0
when a 1 was transmitted

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 115 / 487
Physical Layer Fundamental Limits

Signals
Channel Capacity

I the larger the bandwidth, the greater the cost.


I transmission channels are of limited bandwidth.
I physical properties of the transmission medium
I deliberate limitations to prevent interference
I make as efficient use as possible of a given bandwidth.

Design Objective
Get as high a data rate as possible at a particular limit of error rate for
a given bandwidth. The main constraint on achieving this efficiency is
noise.

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 116 / 487
Physical Layer Fundamental Limits

Signals
Nyquist Bandwidth (Rate)

Nyquist Rate
Given a bandwidth of B Hz, the highest signal rate that can be carried
is 2B bps.

Nyquist Bandwidth
If the rate of signal transmission is 2B bps, then a signal with
frequencies no greater than B Hz is sufficient to carry the signal rate.

C = 2B log2 M,
where M is the number of signalling levels.

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 117 / 487
Physical Layer Fundamental Limits

Signals
Shannon Capacity

http://www.youtube.com/watch?v=z7bVw7lMtUg

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 118 / 487
Physical Layer Fundamental Limits

Signals
Shannon Capacity

I The higher the data rate, the more damage that unwanted noise
can do.
I Signal-to-noise ratio (SNR, S/N): the ratio of the power in a signal
to the power contained in the noise that is present at a particular
point in the transmission.
I Let’s consider only thermal noise (white noise)

Shannon Capacity
C = B log2 (1 + SN R)
where C is the capacity of the channel in bps and B is the bandwidth
of the channel in Hz.

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 119 / 487
Physical Layer Fundamental Limits

Practice What You Preach


Capacity

Suppose that the spectrum of a channel is


between 3 MHz and 4 MHz and SNRdB = 24 dB.
What is the Shannon capacity? Based on
Nyquist’s formula how many signaling levels are
required to provide the Shannon capacity?

PAIR UP and
DISCUSS

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 120 / 487
Physical Layer Fundamental Limits

Practice What You Preach


Capacity

Suppose that the spectrum of a channel is


between 3 MHz and 4 MHz and SNRdB = 24 dB.
What is the Shannon capacity? Based on
Nyquist’s formula how many signaling levels are
required to provide the Shannon capacity?

Answer
Bandwidth B = 4 − 3 = 1 MHz = 106 Hz
SNR (in linear scale) is 102.4 = 251.
⇒ C = 106 × log2 (1 + 251) = 8 × 106 bits.
PAIR UP and Nyquist says C = 2B log2 M , so
DISCUSS 8 × 106 = 2 × 106 × log2 M ;
⇒ M = 16.

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 120 / 487
Physical Layer Fundamental Limits

Signals
Thermal Noise
The amount of thermal noise to be found in a bandwidth of 1 Hz in any
device or conductor is
N0 = kT
in W/Hz where
I N0 is the noise power density in Watts per 1 Hz
I k is the Boltzmann’s constant = 1.38 × 10−23 J/K
I T is the temperature, in Kelvins (absolute temperature)

Example
Room temperature is T = 17o C, or 290 K. At this temperature, the
thermal noise power density is N0 = (1.38 × 10−23 × 290 = 4 × 10−21
W/Hz
= −204 dBW/Hz

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 121 / 487
Physical Layer Fundamental Limits

Signals
Boltzmann’s grave in the Zentralfriedhof, Vienna

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 122 / 487
Physical Layer Fundamental Limits

Signals
Thermal Noise

The amount of thermal noise to be found in a bandwidth of B Hz in any


device or conductor is
N0 = kT B
in W and in decibel-Watts it is

N = 10 log k + 10 log T + 10 log B

= −228.6dBW + 10 log T + 10 log B


since the thermal noise is assumed to be independent of the
frequency.

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 123 / 487
Physical Layer Fundamental Limits

Signals
Eb /N0
Eb /N0 is the ratio of the signal energy per bit to the noise power
density per Hertz.

Eb = STb
where S is the signal power and Tb is the time required to send one bit.
Then, the data rate is R = 1/Tb . This follows,

Eb S/R S
= =
N0 N0 kT R
in linear scale. Or in decibel notation
 
Eb
= SdBW − 10 log R + 228.6dBW − 10 log T
N0 dB

Bit Error Rate (BER) is a decreasing function of Eb /N0 .


Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 124 / 487
Physical Layer Fundamental Limits

Signals
Bit Error Rate (BER)

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 125 / 487
Physical Layer Fundamental Limits

Practice What You Preach


Eb /N0

For some sort of modulation scheme, Eb /N0 = 8.4 dB is


required for a bit error rate of 10−4 (one bit error out of
every 10,000). If the effective noise temperature is 290o K
(room temperature) and the data rate is 2400 bps, what
received signal level is required?

PAIR UP and
DISCUSS

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 126 / 487
Physical Layer Fundamental Limits

Practice What You Preach


Eb /N0

For some sort of modulation scheme, Eb /N0 = 8.4 dB is


required for a bit error rate of 10−4 (one bit error out of
every 10,000). If the effective noise temperature is 290o K
(room temperature) and the data rate is 2400 bps, what
received signal level is required?

Answer
 
Eb
= SdBW − 10 log R + 228dBW − 10 log T
PAIR UP and N0 dB
DISCUSS
8.4 = SdBW − 10 log 2400 + 228.6dBW − 10 log 290
Then, S = −161.8 dBW.

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 126 / 487
Physical Layer Modulation

Modulation
Definition

I Carrier signal: analog constant-frequency signal


I Carrier signal is chosen to be compatible with medium
I Data is transmitted using a carrier signal by modulation

Modulation
is the process of encoding source data onto a carrier with frequency fc

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 127 / 487
Physical Layer Modulation

Modulation
Baseband - Passband

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 128 / 487
Physical Layer Modulation

Modulation
Digital Data, Digital Signal

I Signal spectrum: lack of high frequency components, no dc,


concetrate power in the middle (coding)
I Clocking: determine the beginning and end of frame (instead of
additional clock, self-synchronization)
I Error detection: mostly data link layer
I Signal to Interference + Noise Ratio: coding gain, transmission
power adaptation, ...
I Cost complexity: larger bandwidth higher cost

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 129 / 487
Physical Layer Modulation

Modulation
Digital Data, Digital Signal

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 130 / 487
Physical Layer Modulation

Modulation
Modulation Rate: Bit rate versus baud rate

When bit duration is Tb then bit rate is R = 1/Tb

Modulation (baud) rate, D


is the rate at which signal elements (symbols) are generated

R
D=
log2 M

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 131 / 487
Physical Layer Modulation

Passband (Analog) Modulation


Types

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 132 / 487
Physical Layer Modulation

Passband (Analog) Modulation


Amplitude Shift Keying (ASK)

Amplitude Shift Keying (ASK)


Change the amplitude of sinusoid
(
A cos(2πfc t) binary 1
s(t) =
0 binary 0

THINK PAIR SHARE


What is the bit rate compared to baud
(symbol) rate and how can you
increase it?

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 133 / 487
Physical Layer Modulation

Passband (Analog) Modulation


Frequency Shift Keying

Frequency Shift Keying (FSK)


Change the frequency of sinusoid
(
A cos(2πf1 t) binary 1
s(t) =
A cos(2πf2 t) binary 0

THINK PAIR SHARE


What is the bit rate compared to baud
(symbol) rate and how can you
increase it?

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 134 / 487
Physical Layer Modulation

Passband (Analog) Modulation


Multiple Frequency Shift Keying

Multiple Frequency Shift Keying (MFSK)


Change the frequency of sinusoid si (t) = A cos(2πfi t)
where 1 ≤ i ≤ M
fi = fc + (2i − 1 − M )fd ,
fc is the carrier (center) frequency,
fd is the difference frequency.

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 135 / 487
Physical Layer Modulation

Passband (Analog) Modulation


Phase Shift Keying

Phase Shift Keying (PSK)


Change the phase of sinusoid
(
A cos(2πfc t) binary 1
s(t) =
A cos(2πfc t + π) binary 0

THINK PAIR SHARE


What is the bit rate compared to baud
(symbol) rate and how can you
increase it?

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 136 / 487
Physical Layer Modulation

Passband (Analog) Modulation


Quadrature Phase Shift Keying

Qudrature Shift Keying (QPSK)





A cos(2πfc t + π/4) 11

A cos(2πf t + 3π/4)
c 01
s(t) =


A cos(2πfc t − 3π/4) 00

A cos(2πf t − π/4)
c 10

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 137 / 487
Physical Layer Modulation

Passband (Analog) Modulation


Quadrature Phase Shift Keying

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 138 / 487
Physical Layer Modulation

Passband (Analog) Modulation


Different Constellations

We can modulate phase and amplitude at the same time.

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 139 / 487
Physical Layer Modulation

Passband (Analog) Modulation


Different Constellations

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 140 / 487
Physical Layer Ticket to Retention

Ticket to Retention (TtR) Discussion


Summary - Main Learning Points

1. Fundamental limits: Why can we not transmit infinitely many bits


per second over a channel. What are the limits?
2. Signals over a wire: What happens to signals as they propagate
over a wire?
3. Base- and pass-band signals: How can we transmit baseband
signals over higher frequency carriers?

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 141 / 487
Application Layer

Section 4

Application Layer
Application Layer

Objectives of the Lecture

At the end of this lecture, you will be able to


understand the conceptual and implementation aspects of network
application protocols by examining popular application-level protocols
such as HTTP, FTP, SMTP, DNS and develop network applications
using socket programming API.

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 142 / 487
Application Layer

Overview and Compulsory Reading

I Principles of network applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.1


I Web and HTTP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.2
I File transfer protocol . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.3
I Electronic mail . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.4
Domain name server . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.5
I Peer to peer applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.6
I Socket programming . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.7
(Kurose and Ross, 2013)

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 143 / 487
Application Layer

Ticket to Retention (TtR) Questions

1. Client/server versus peer-to-peer: Compare and contrast


client/server architecture with peer-to-peer (P2P) architecture.
2. Peer-to-peer systems: What are the ways to locate information in
a P2P system?
3. Transport layer services: Compare and contrast TCP and UDP
services.
4. Centralized versus distributed application: What are the
disadvantages of centralized systems?
5. Domain name server: What are the types of DNS queries?
Compare and contrast.

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 144 / 487
Application Layer Principles of Network Applications

Practice What You Preach


Network Applications

Tell me some of the network applications you


use? Do you know the names of the underlying
protocols?

PAIR UP and
DISCUSS

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 145 / 487
Application Layer Principles of Network Applications

Practice What You Preach


Network Applications

Tell me some of the network applications you


use? Do you know the names of the underlying
protocols?

Typical answer
e-mail, web, text messaging, remote login, P2P
file sharing, multi-user network games, streaming
stored video (YouTube, Hulu, Netflix), voice over
IP (e.g., Skype), real-time video conferencing,
PAIR UP and social networking, search, ...
DISCUSS

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 145 / 487
Application Layer Principles of Network Applications

Network Applications
Communication

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 146 / 487
Application Layer Principles of Network Applications

Network Applications
Communication

I write programs that:


I run on (different) end systems
I communicate over network
I e.g., web server software communicates with browser software
I no need to write software for network-core devices
I network-core devices do not run user applications
I applications on end systems allows for rapid app development,
propagation

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 147 / 487
Application Layer Principles of Network Applications

Network Applications
Client-server and Peer-to-peer Architectures

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 148 / 487
Application Layer Principles of Network Applications

Network Applications
Client-server Architecture

Server
I always-on host
I permanent IP address
I data centers for scaling

Client
I communicate with server
I may be intermittently
connected
I do not communicate directly
with each other

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 149 / 487
Application Layer Principles of Network Applications

Network Applications
Peer-to-peer Architecture

I no always-on server
I arbitrary end systems directly
communicate
I peers request service from
other peers, provide service in
return to other peers
I self scalability: new peers
bring demand and also
capacity
I peers are intermittently
connected and change IP
addresses, complex
management

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 150 / 487
Application Layer Principles of Network Applications

Network Applications
Peer-to-peer Architecture

Process
is the program running within a host. Within same host, two processes
communicate by using inter-process communication and processes
in different hosts communicate by exchanging messages.

Who is client? Who is server?

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 151 / 487
Application Layer Principles of Network Applications

Network Applications
Peer-to-peer Architecture

Process
is the program running within a host. Within same host, two processes
communicate by using inter-process communication and processes
in different hosts communicate by exchanging messages.

Who is client? Who is server?


client process: process that initiates communication,
server process: process that waits to be contacted.

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 151 / 487
Application Layer Principles of Network Applications

Network Applications
Application Processesç, Sockets and Transport Protocol

process sends/receives messages to/from its socket


Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 152 / 487
Application Layer Principles of Network Applications

Network Applications
Addressing Processes

I to receive messages, process must have identifier


I host device has unique 32-bit IP address
I Question: Does IP address of host on which process runs suffice
for identifying the process?

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 153 / 487
Application Layer Principles of Network Applications

Network Applications
Addressing Processes

I to receive messages, process must have identifier


I host device has unique 32-bit IP address
I Question: Does IP address of host on which process runs suffice
for identifying the process?
I Answer: no, many processes can be running on same hosts
I identifier includes both IP address and port numbers associated
with process on host.
I example port numbers: HTTP server: 80, mail server: 25

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 153 / 487
Application Layer Principles of Network Applications

Network Applications
Application Layer Protocols

I types of messages exchanged, e.g., request, response


I message syntax: what fields in messages & how fields are
delineated
I message semantics, meaning of information in fields
I rules for when and how processes send & respond to messages

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 154 / 487
Application Layer Principles of Network Applications

Network Applications
Requirements from Lower (Transport) Layer

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 155 / 487
Application Layer Principles of Network Applications

Network Applications
Requirements from Lower (Transport) Layer

I Reliable data transfer


I Throughput
I Timing
I Security

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 156 / 487
Application Layer Principles of Network Applications

Network Applications
Internet transport protocols services

TCP Service UDP Service


I reliable transport I unreliable data
I flow control I does not provide:
I congestion control reliability, flow control,
I connection-oriented congestion control, timing,
Idoes not provide: timing, throughput guarantee,
minimum throughput security, or connection
guarantee, security setup,
Neither TCP nor UDP provides security. We will cover this aspect in
another course.

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 157 / 487
Application Layer Principles of Network Applications

Network Applications
Example Applications and Transport Protocols Thereof

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 158 / 487
Application Layer HTTP

HTTP
Overview

I uses TCP
I stateless
I non-persistent HTTP: at most one object sent over TCP
connection, connection then closed
I persistent HTTP: multiple objects can be sent over single TCP
connection between client, server
http://eonur.eu/academics/index.html

Question
Who is client, who is server?

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 159 / 487
Application Layer HTTP

HTTP
Overview

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 160 / 487
Application Layer HTTP

HTTP
Non-persistent HTTP

Assume user enters URL http://eonur.eu/academics/index.html


1. Client initiates TCP connection to HTTP server (process) at
eonur.eu
2. Server waiting for TCP connection at port 80, accepts connection,
notifying client
3. Client sends HTTP request message (containing URL) into TCP
connection socket. Message indicates that client wants the object
academics/index.html.
4. Server receives request message, forms response message
containing requested object, and sends message into its socket
5. Client received the response and parses the object
6. Server closes TCP connection.

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 161 / 487
Application Layer HTTP

HTTP
Non-persistent HTTP

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 162 / 487
Application Layer HTTP

Network Applications
Internet transport protocols services

Persistent HTTP
I server leaves connection open
Non-persistent HTTP after sending response
I requires 2 RTTs per object I subsequent HTTP messages
I OS overhead for each TCP between same client/server
connection sent over open connection
I browsers often open I client sends requests as soon
parallel TCP connections as it encounters a referenced
to fetch referenced objects object
I as little as one RTT for all the
referenced objects

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 163 / 487
Application Layer HTTP

HTTP
HTTP Messages
I Two types of HTTP messages: request, response
I HTTP request message: ASCII (human-readable)

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 164 / 487
Application Layer HTTP

HTTP
HTTP Request Methods

POST Method
I web page often includes form input
I input is uploaded to server in entity body

GET Method
I input is uploaded in URL field of request line
I www.somesite.com/animalsearch?monkeys&banana

HEAD Method
I asks server to leave requested object out of response

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 165 / 487
Application Layer HTTP

HTTP
HTTP Request Methods

PUT Method
I uploads file in entity body to path specified in URL field

DELETE Method
I deletes file specified in the URL field

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 166 / 487
Application Layer HTTP

HTTP
HTTP Response Message

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 167 / 487
Application Layer HTTP

HTTP
HTTP Response Status Codes

I 200 OK: request succeeded, requested object later in this msg


I 301 Moved Permanently: requested object moved, new location
specified
I 400 Bad Request: request msg not understood by server
I 404 Not Found: requested document not found on this server
I 505 HTTP Version Not Supported

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 168 / 487
Application Layer HTTP

Practice What You Preach


HTTP

How can you introduce state to this system?

PAIR UP and
DISCUSS

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 169 / 487
Application Layer HTTP

Practice What You Preach


HTTP

How can you introduce state to this system?

Typical answer
Cookies

PAIR UP and
DISCUSS

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 169 / 487
Application Layer HTTP

HTTP
Cookies

I cookie header line of HTTP response message


I cookie header line in next HTTP request message
I cookie file kept on user’s host, managed by user’s browser
I back-end database at Web site
I http messages carry state

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 170 / 487
Application Layer HTTP

HTTP
Cookies

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 171 / 487
Application Layer HTTP

Practice What You Preach


HTTP

How can you reduce the response time for client


requests?

PAIR UP and
DISCUSS

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 172 / 487
Application Layer HTTP

Practice What You Preach


HTTP

How can you reduce the response time for client


requests?

Typical answer
Caching

PAIR UP and
DISCUSS

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 172 / 487
Application Layer HTTP

HTTP
Caching

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 173 / 487
Application Layer HTTP

HTTP
Caching

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 174 / 487
Application Layer HTTP

Practice What You Preach


Caching

Average object size: 1 Mbits


Average request rate: 15 requests/sec
Average Internet delay: 2 sec
Can you neglect LAN delay? Can you neglect
delay on access link?

PAIR UP and
DISCUSS

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 175 / 487
Application Layer HTTP

Practice What You Preach


Caching

Average object size: 1 Mbits


Average request rate: 15 requests/sec
Average Internet delay: 2 sec
Can you neglect LAN delay? Can you neglect
delay on access link?

Typical answer
The traffic intensity on the LAN is (15 requests/sec) . (1
Mbits/request)/(100 Mbps) = 0.15 << 1. Therefore, LAN delay can
be neglected
PAIR UP and The traffic intensity on the access link is (15 requests/sec) . (1
Mbits/request)/(15 Mbps) = 1. Delay is very large
DISCUSS

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 175 / 487
Application Layer HTTP

Practice What You Preach


Caching

Same scenario but using local cache


Cache hit rate: 0.4
What is the average delay when cache is used?

PAIR UP and
DISCUSS

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 176 / 487
Application Layer HTTP

Practice What You Preach


Caching

Same scenario but using local cache


Cache hit rate: 0.4
What is the average delay when cache is used?

Typical answer
When cache is used LAN delay + 0.6 × 2 sec.

PAIR UP and
DISCUSS

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 176 / 487
Application Layer HTTP

HTTP
Conditional GET (use cache)

I Goal: do not send object if cache has up-to-date cached version


I no object transmission delay
I lower link utilization
I cache: specify date of cached copy in HTTP request
I If-modified-since: ¡date¿
I server: response contains no object if cached copy is up-to-date:
HTTP/1.0 304 Not Modified

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 177 / 487
Application Layer File Transfer Protocol

File Transfer Protocol (FTP)

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 178 / 487
Application Layer File Transfer Protocol

File Transfer Protocol (FTP)

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 179 / 487
Application Layer File Transfer Protocol

File Transfer Protocol (FTP)

I FTP client contacts FTP server at port 21, using TCP


I Client authorized over control connection
I Client browses remote directory, sends commands over control
connection
I When server receives file transfer command, server opens 2nd
TCP data connection (for file) to client
I After transferring one file, server closes data connection
I Server opens another TCP data connection to transfer another file
I Control connection: ”out of band”
I FTP server maintains ”state”: current directory, earlier
authentication

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 180 / 487
Application Layer Electronic Mail

Electronic Mail
Simple Mail Transfer Protocol

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 181 / 487
Application Layer Electronic Mail

Electronic Mail
Simple Mail Transfer Protocol

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 182 / 487
Application Layer Electronic Mail

Simple Mail Transfer Protocol


Comparison with HTTP

I HTTP: pull, SMTP: push


I Both uses TCP (HTTP:80, SMTP:25)
I Both command/response interaction
I Both have ASCII command/response interaction, status codes
I HTTP: each object encapsulated in its own response msg
I SMTP: multiple objects sent in multipart msg

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 183 / 487
Application Layer Domain Name Server

Domain Name Server


Name Resolution

I people: many identifiers: SSN, name, passport number


I Internet hosts, routers: IP address (32 bit) - used for addressing
datagrams
I name, e.g., www.yahoo.com - used by humans

THINK PAIR SHARE


How can you map between IP address
and name, and vice versa?

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 184 / 487
Application Layer Domain Name Server

Domain Name Server


Name Resolution

Domain Name System


is a distributed database implemented in hierarchy of many name
servers.

I application-layer protocol: hosts, name servers communicate to


resolve names (address/name translation)
I implemented as application-layer protocol: complexity at network’s
edge
I services: name resolution, host aliasing, load distribution

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 185 / 487
Application Layer Domain Name Server

Practice What You Preach


Domain Name Server (DNS)

Why should you not centralize DNS?

PAIR UP and
DISCUSS

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 186 / 487
Application Layer Domain Name Server

Practice What You Preach


Domain Name Server (DNS)

Why should you not centralize DNS?

Typical answer
I single point of failure
I traffic volume
I distant centralized database
I maintenance
PAIR UP and
I does not scale
DISCUSS

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 186 / 487
Application Layer Domain Name Server

Domain Name Server


Hierarchy

I client wants IP for www.amazon.com; 1st approx:


I query root server to find com DNS server
I query .com DNS server to get amazon.com DNS server
I query amazon.com DNS server to get IP address for
www.amazon.com
Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 187 / 487
Application Layer Domain Name Server

Domain Name Server


DNS Server Classes
Root DNS Servers
I There are 13 root DNS servers (a through m)

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 188 / 487
Application Layer Domain Name Server

Domain Name Server


DNS Server Classes

Top-level domain (TLD) Servers


I responsible for com, org, net, edu, aero, jobs, museums, and all
top-level country domains, e.g.: uk, fr, ca, jp
I Network Solutions maintains servers for .com TLD
I Educause for .edu TLD

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 189 / 487
Application Layer Domain Name Server

Domain Name Server


DNS Server Classes

Authoritative Servers
I organization’s own DNS server(s), providing authoritative
hostname to IP mappings for organization’s named hosts
I can be maintained by organization or service provider

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 190 / 487
Application Layer Domain Name Server

Domain Name Server


DNS Server Classes

Local DNS Servers


I does not strictly belong to hierarchy
I each ISP (residential ISP, company, university) has one also called
default name server
I when host makes DNS query, query is sent to its local DNS server
I has local cache of recent name-to-address translation pairs (but
may be out of date!)
I acts as proxy, forwards query into hierarchy

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 191 / 487
Application Layer Domain Name Server

Domain Name Server


Interaction of Various DNS Servers: Iterated Queries

I don’t know this name, but


contact this server to find it
out yourself

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 192 / 487
Application Layer Domain Name Server

Domain Name Server


Interaction of Various DNS Servers: Recursive Queries

I don’t know this name, but


let me find it out for you.

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 193 / 487
Application Layer Domain Name Server

Domain Name Server


DNS Records

Resource Records
RR = (name, value, type, ttl)
I Type=A, name:hostname, value:IP Address
I Type=NS, name:domain, value:hostname of authoritative server
I Type=CNAME, name:alias, value:canonical name
I Type=MX, name:name, value:name of mailserver

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 194 / 487
Application Layer Domain Name Server

Domain Name Server


Interaction of Various DNS Servers: Recursive Queries

Flags:
I query or reply
I recursion
desired
I recursion
available
I reply is
authoritative

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 195 / 487
Application Layer Domain Name Server

Practice What You Preach


Inserting records into DNS

What are the DNS records that have to be created when


networkutopia.com is registered at a DNS registrar.

PAIR UP and
DISCUSS

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 196 / 487
Application Layer Domain Name Server

Practice What You Preach


Inserting records into DNS

What are the DNS records that have to be created when


networkutopia.com is registered at a DNS registrar.

Typical answer
I provide names, IP addresses of authoritative name
server
I registrar inserts two RRs into .com TLD server:
I (networkutopia.com, dns1.networkutopia.com, NS)
PAIR UP and I (dns1.networkutopia.com, 212.212.212.1, A)
DISCUSS I type A record for www.networkuptopia.com; type
MX record for networkutopia.com

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 196 / 487
Application Layer Peer-to-peer Architecture

Peer-to-peer Architecture
Pure P2P Architecture

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 197 / 487
Application Layer Peer-to-peer Architecture

Peer-to-peer Architecture
Pure P2P Architecture

I no always-on server
I arbitrary end systems directly communicate
I peers are intermittently connected and change IP addresses

THINK PAIR SHARE


How much time to distribute file (size F )
from one server to N peers? (peer
upload/download capacity is limited
resource)

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 198 / 487
Application Layer Peer-to-peer Architecture

Peer-to-peer Architecture
Distribution Problem: Client-server Approach

I server
transmission:
must
sequentially
send (upload) N
file copies:
I time to send one
copy: F/us
I time to send N
copies: N F/us

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 199 / 487
Application Layer Peer-to-peer Architecture

Peer-to-peer Architecture
Distribution Problem: Client-server Approach

I client: each
client must
download file
copy
I dmin = minimum
client download
rate
I min client
download time:
F/dmin

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 200 / 487
Application Layer Peer-to-peer Architecture

Peer-to-peer Architecture
Distribution Problem: Client-server Approach

The time to distribute F to N


clients using client-server
approach is
 
NF F
Dcs ≥ max ,
us dmin

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 201 / 487
Application Layer Peer-to-peer Architecture

Peer-to-peer Architecture
Distribution Problem: P2P Approach

I server transmission: must


upload at least one copy
I time to send one copy: F/us
I client: each client must
download file copy
I min client download time:
F/dmin
I clients: as aggregate must
download N F bits
I max upload rate (limiting
P max
download rate) is us + ui

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 202 / 487
Application Layer Peer-to-peer Architecture

Peer-to-peer Architecture
Distribution Problem: Client-server Approach

The time to distribute F to N clients using P2P


approach is
 
F F NF
Dp2p ≥ max , , P
us dmin us + ui

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 203 / 487
Application Layer Peer-to-peer Architecture

Peer-to-peer Architecture
Client-server versus Peer-to-peer

client upload rate = u, F/u = 1 hour, us = 10u, dmin ≥ us


Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 204 / 487
Application Layer Peer-to-peer Architecture

Peer-to-peer Architecture
Example: Bittorent

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 205 / 487
Application Layer Peer-to-peer Architecture

Peer-to-peer Architecture
Distributed Hash Tables (DHT)

I DHT: a distributed P2P database


I Database has (key, value) pairs; examples:
I key: ss number; value: human name
I key: movie title; value: IP address
I Distribute the (key, value) pairs over peers
I A peer queries DHT with key: DHT returns values that match the
key
I Peers can also insert (key, value) pairs

THINK PAIR SHARE


How will you assign keys to peers?

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 206 / 487
Application Layer Peer-to-peer Architecture

Peer-to-peer Architecture
Distributed Hash Tables (DHT)

Basic idea:
I Convert each key to an integer
I Assign integer to each peer
I Put (key,value) pair in the peer that is closest to the key
For instance:
I assign integer identifier to each peer in range [0, 2n−1 ] for some n.
I each identifier represented by n bits.
I to get integer key, hash the original key
I e.g., key = hash(”Led Zeppelin IV”)

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 207 / 487
Application Layer Peer-to-peer Architecture

Peer-to-peer Architecture
Distributed Hash Tables (DHT)

I rule: assign key to the peer that has the closest ID.
I convention in lecture: closest is the immediate successor of the
key.
I e.g., n=4; peers: 1,3,4,5,8,10,12,14;
I key = 13, then successor peer = 14
I key = 15, then successor peer = 1

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 208 / 487
Application Layer Peer-to-peer Architecture

Peer-to-peer Architecture
Circular DHT

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 209 / 487
Application Layer Peer-to-peer Architecture

Peer-to-peer Architecture
Peer churn

handling peer churn:


I peers may come and go (churn)
I each peer knows address of its two successors
I each peer periodically pings its two successors to check aliveness
I if immediate successor leaves, choose next successor as new
immediate successor

THINK PAIR SHARE


What happens when a node joins?

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 210 / 487
Application Layer Socket Programming

Socket Programming
Goals

I Goal: learn how to build client/server applications that


communicate using sockets
I Socket: door between application process and end-end-transport
protocol

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 211 / 487
Application Layer Socket Programming

Socket Programming
Socket Types

I UDP: unreliable datagram


I TCP: reliable, byte stream-oriented

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 212 / 487
Application Layer Socket Programming

UDP Socket Programming

I UDP: no ”connection” between client & server


I no handshaking before sending data
I sender explicitly attaches IP destination address and port number
to each packet
I receiver extracts sender IP address and port number from received
packet
I transmitted data may be lost or received out-of-order
I UDP provides unreliable transfer of groups of bytes (datagrams)
between client and server

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 213 / 487
Application Layer Socket Programming

UDP Socket Programming

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 214 / 487
Application Layer Socket Programming

UDP Socket Programming: Client I


/* Sample UDP client */
#include <sys/socket.h>
#include <netinet/in.h>
#include <stdio.h>
int main(int argc, char**argv)
{
int sockfd,n;
struct sockaddr_in servaddr,cliaddr;
char sendline[1000];
char recvline[1000];
if (argc != 2) {
printf("usage: udpcli <IP-address>\n");
exit(1);
}
sockfd=socket(AF_INET,SOCK_DGRAM,0);
bzero(&servaddr,sizeof(servaddr));
servaddr.sin_family = AF_INET;
servaddr.sin_addr.s_addr=inet_addr(argv[1]);
servaddr.sin_port=htons(32000);

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 215 / 487
Application Layer Socket Programming

UDP Socket Programming: Client II

while (fgets(sendline, 10000,stdin) != NULL) {


sendto(sockfd,sendline,strlen(sendline),0,
(struct sockaddr *)&servaddr,sizeof(servaddr));
n=recvfrom(sockfd,recvline,10000,0,NULL,NULL);
recvline[n]=0;
fputs(recvline,stdout);
}
}

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 216 / 487
Application Layer Socket Programming

UDP Socket Programming: Server I


/* Sample UDP server */
#include <sys/socket.h>
#include <netinet/in.h>
#include <stdio.h>
int main(int argc, char**argv)
{
int sockfd,n;
struct sockaddr_in servaddr,cliaddr;
socklen_t len;
char mesg[1000];

sockfd=socket(AF_INET,SOCK_DGRAM,0);
bzero(&servaddr,sizeof(servaddr));
servaddr.sin_family = AF_INET;
servaddr.sin_addr.s_addr=htonl(INADDR_ANY);
servaddr.sin_port=htons(32000);
bind(sockfd,(struct sockaddr *)&servaddr,sizeof(servaddr));
for (;;) {
len = sizeof(cliaddr);

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 217 / 487
Application Layer Socket Programming

UDP Socket Programming: Server II

n = recvfrom(sockfd,mesg,1000,0,(struct sockaddr *)&


cliaddr,&len);
sendto(sockfd,mesg,n,0,(struct sockaddr *)&cliaddr,sizeof
(cliaddr));
printf("---------------\n");
mesg[n] = 0;
printf("Received the following:\n");
printf("%s",mesg);
printf("---------------\n");
}
}

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 218 / 487
Application Layer Socket Programming

TCP Socket Programming

I client must contact server


I server process must first be running
I server must have created socket (door) that welcomes client’s
contact
I client contacts server by:
I Creating TCP socket, specifying IP address, port number of server
process
I when client creates socket: client TCP establishes connection to
server TCP
I when contacted by client, server TCP creates new socket for
server process to communicate with that particular client
I allows server to talk with multiple clients
I source port numbers used to distinguish clients (more in Chap 3)

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 219 / 487
Application Layer Socket Programming

TCP Socket Programming

From the application view-point


TCP provides reliable, in-order byte-stream transfer (”pipe”) between
client and server

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 220 / 487
Application Layer Socket Programming

TCP Socket Programming


TCP Server Process

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 221 / 487
Application Layer Socket Programming

TCP Socket Programming

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 222 / 487
Application Layer Socket Programming

TCP Socket Programming: Client I


/* Sample TCP client */

#include <sys/socket.h>
#include <netinet/in.h>
#include <stdio.h>
int main(int argc, char**argv)
{
int sockfd,n;
struct sockaddr_in servaddr,cliaddr;
char sendline[1000];
char recvline[1000];
if (argc != 2)
{
printf("usage: client <IP address>\n");
exit(1);
}

sockfd=socket(AF_INET,SOCK_STREAM,0);
bzero(&servaddr,sizeof(servaddr));

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 223 / 487
Application Layer Socket Programming

TCP Socket Programming: Client II

servaddr.sin_family = AF_INET;
servaddr.sin_addr.s_addr=inet_addr(argv[1]);
servaddr.sin_port=htons(32000);
connect(sockfd, (struct sockaddr *)&servaddr, sizeof(
servaddr));
while (fgets(sendline, 10000,stdin) != NULL)
{
sendto(sockfd,sendline,strlen(sendline),0,
(struct sockaddr *)&servaddr,sizeof(servaddr));
n=recvfrom(sockfd,recvline,10000,0,NULL,NULL);
recvline[n]=0;
fputs(recvline,stdout);
}
}

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 224 / 487
Application Layer Socket Programming

TCP Socket Programming: Server I

/* Sample TCP server */

#include <sys/socket.h>
#include <netinet/in.h>
#include <stdio.h>

int main(int argc, char**argv)


{
int listenfd,connfd,n;
struct sockaddr_in servaddr,cliaddr;
socklen_t clilen;
pid_t childpid;
char mesg[1000];

listenfd=socket(AF_INET,SOCK_STREAM,0);
bzero(&servaddr,sizeof(servaddr));
servaddr.sin_family = AF_INET;
servaddr.sin_addr.s_addr=htonl(INADDR_ANY);

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 225 / 487
Application Layer Socket Programming

TCP Socket Programming: Server II


servaddr.sin_port=htons(32000);
bind(listenfd,(struct sockaddr *)&servaddr,sizeof(servaddr))
;

listen(listenfd,1024);

for(;;) {
clilen=sizeof(cliaddr);
connfd = accept(listenfd,(struct sockaddr *)&cliaddr,&
clilen);

if ((childpid = fork()) == 0) {
close (listenfd);

for(;;) {
n = recvfrom(connfd,mesg,1000,0,(struct sockaddr *)
&cliaddr,&clilen);
sendto(connfd,mesg,n,0,(struct sockaddr *)&cliaddr,
sizeof(cliaddr));
printf("-----------\n");
Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 226 / 487
Application Layer Socket Programming

TCP Socket Programming: Server III

mesg[n] = 0;
printf("Received the following:\n");
printf("%s",mesg);
printf("-----------\n");
}
}
close(connfd);
}
}

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 227 / 487
Application Layer Ticket to Retention

Ticket to Retention (TtR) Discussion


Summary - Main Learning Points

1. Client/server versus peer-to-peer: Compare and contrast


client/server architecture with peer-to-peer (P2P) architecture.
2. Peer-to-peer systems: What are the ways to locate information in
a P2P system?
3. Transport layer services: Compare and contrast TCP and UDP
services.
4. Centralized versus distributed application: What are the
disadvantages of centralized systems?
5. Domain name server: What are the types of DNS queries?
Compare and contrast.

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 228 / 487
Transport Layer

Section 5

Transport Layer
Transport Layer

Objectives of the Lecture


At the end of this lecture, you will be able to
understand principles behind transport layer services such as
multiplexing, demultiplexing, reliable data transfer, flow control and
congestion control.

At the end of this lecture, you will be able to


describe the Internet transport layer protocols; namely, UDP:
connectionless transport, TCP: connection-oriented reliable transport
and TCP congestion control.

At the end of this lecture, you will be able to


assemble the mechanisms required for reliable data transfer over
unreliable channels.

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 229 / 487
Transport Layer

Overview and Compulsory Reading

I Transport-layer services . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3.1


I Multiplexing and demultiplexing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3.2
I Connectionless transport: UDP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3.3
I Principles of reliable data transfer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3.4
I Connection-oriented transport: TCP . . . . . . . . . . . . . . . . . . . . . . . . . . 3.5
I Principles of congestion control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3.6
I TCP congestion control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3.7

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 230 / 487
Transport Layer

Ticket to Retention (TtR) Questions

1. Reliable data transfer: What are the mechanisms for reliable data
transfer and how do you use them?
2. Flow control: Why and how do you implement flow control?
3. Congestion control: Why and how do you implement congestion
control?
4. UDP versus TCP Describe why an application developer might
choose to run an application over UDP rather than TCP.

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 231 / 487
Transport Layer Transport Layer Services

Transport Services and Protocols

I provide logical
communication
between
application
processes
running on
different hosts
I transport
protocols run in
end systems

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 232 / 487
Transport Layer Transport Layer Services

Transport Services and Protocols

I reliable, in-order delivery (TCP)


I congestion control
I flow control
I connection setup
I unreliable, unordered delivery (UDP)
I no-frills extension of ”best-effort” IP
I services not available:
I delay guarantees
I bandwidth guarantees

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 233 / 487
Transport Layer Multiplexing and Demultiplexing

Multiplexing and Demultiplexing

I Multiplexing: handle data from multiple sockets, add transport


header
I Demultiplexing: use header info to deliver received segments to
correct socket
Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 234 / 487
Transport Layer Multiplexing and Demultiplexing

Multiplexing and Demultiplexing


How Does It Work?

I host receives IP datagrams


I each datagram has source
IP address, destination IP
address
I each datagram carries one
transport-layer segment
I each segment has source,
destination port number
I host uses IP addresses & port
numbers to direct segment to
appropriate socket

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 235 / 487
Transport Layer Multiplexing and Demultiplexing

Multiplexing and Demultiplexing


Connectionless Demultiplexing

I when host receives UDP


segment:
I checks destination port
number in segment
I directs UDP segment to
socket with that port number
I IP datagrams with same
destination port number, but
different source IP addresses
and/or source port numbers
will be directed to same
socket at destination

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 236 / 487
Transport Layer Multiplexing and Demultiplexing

Multiplexing and Demultiplexing


Connectionless Demultiplexing

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 237 / 487
Transport Layer Multiplexing and Demultiplexing

Multiplexing and Demultiplexing


Connection-oriented Demultiplexing

I TCP socket identified by 4-tuple:


I source IP address
I source port number
I dest IP address
I dest port number
I Demultiplexing: receiver uses all four values to direct segment to
appropriate socket
I server host may support many simultaneous TCP sockets: each
socket identified by its own 4-tuple
I web servers have different sockets for each connecting client:
non-persistent HTTP will have different socket for each request

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 238 / 487
Transport Layer Multiplexing and Demultiplexing

Multiplexing and Demultiplexing


Connection-oriented Demultiplexing

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 239 / 487
Transport Layer Connectionless Transport

Connectionless Transport
User Datagram Protocol [RFC 768]

I ”best effort” service, UDP segments may be lost or delivered


out-of-order to application
I Connectionless: no handshaking between UDP sender and
receiver;
I Each UDP segment handled independently of others
I Example applications using UDP: DNS, SNMP, streaming
multimedia

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 240 / 487
Transport Layer Connectionless Transport

Practice What You Preach


User Datagram Protocol [RFC 768]

How can you make applications over UDP


reliable? No packet losses or out-of-order
delivery?

PAIR UP and
DISCUSS

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 241 / 487
Transport Layer Connectionless Transport

Practice What You Preach


User Datagram Protocol [RFC 768]

How can you make applications over UDP


reliable? No packet losses or out-of-order
delivery?

Typical answer
I add these features at the application layer
I application-specific error recovery?
PAIR UP and
DISCUSS

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 241 / 487
Transport Layer Connectionless Transport

User Datagram Protocol [RFC 768]


Segment Header

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 242 / 487
Transport Layer Connectionless Transport

Practice What You Preach


User Datagram Protocol [RFC 768]

Why is there a transport layer protocol such as


UDP?

PAIR UP and
DISCUSS

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 243 / 487
Transport Layer Connectionless Transport

Practice What You Preach


User Datagram Protocol [RFC 768]

Why is there a transport layer protocol such as


UDP?
Typical answer
I no connection establishment (which can add
delay)
I simple: no connection state at sender,
receiver
I small header size
PAIR UP and I no congestion control: UDP can blast away
DISCUSS as fast as desired

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 243 / 487
Transport Layer Connectionless Transport

User Datagram Protocol [RFC 768]


Internet Checksum

Goal
detect ”errors” (e.g., flipped bits) in transmitted packet (note: used at
transport layer only)

I Sender
I treat segment contents as sequence of 16-bit integers
I checksum: addition of segment contents and then 1’s complement
of the sum
I sender puts checksum value into UDP checksum field
I Receiver
I treat segment contents as sequence of 16-bit integers
I expected result = addition of segment contents and the checksum
sent in the header
I if expected result = all 1’s then everything is ok
I Otherwise, the segment is corrupt
Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 244 / 487
Transport Layer Reliable Data Transfer

Reliable Data Transfer


Service Model

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 245 / 487
Transport Layer Reliable Data Transfer

Reliable Data Transfer


Getting Started

I incrementally develop sender, receiver sides of reliable data


transfer protocol (rdt)
I consider only unidirectional data transfer
I but control info will flow on both directions!
I use finite state machines (FSM) to specify sender, receiver

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 246 / 487
Transport Layer Reliable Data Transfer

Reliable Data Transfer


RDT 1.0 (over a reliable channel)

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 247 / 487
Transport Layer Reliable Data Transfer

Practice What You Preach


RDT 1.0

Underlying channel may flip bits, how can we


recover from errors? Real-life case: How do
humans recover errors in conversations?

PAIR UP and
DISCUSS

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 248 / 487
Transport Layer Reliable Data Transfer

Practice What You Preach


RDT 1.0

Underlying channel may flip bits, how can we


recover from errors? Real-life case: How do
humans recover errors in conversations?
Typical answer
I Error detection
I Acknowledgments (ACKs): receiver explicitly
tells sender that pkt received OK
I negative acknowledgments (NAKs): receiver
PAIR UP and explicitly tells sender that pkt had errors
DISCUSS I sender retransmits pkt on receipt of NAK

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 248 / 487
Transport Layer Reliable Data Transfer

Reliable Data Transfer


RDT 2.0 (over an unreliable channel)

Extension to RTD 1.0 is error detection and feedback (ACK, NAK)

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 249 / 487
Transport Layer Reliable Data Transfer

Reliable Data Transfer


RDT 2.0 (over an unreliable channel)

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 250 / 487
Transport Layer Reliable Data Transfer

Practice What You Preach


RDT 2.0
What are the flaws or is there room for
improvement in RDT 2.0?

PAIR UP and
DISCUSS

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 251 / 487
Transport Layer Reliable Data Transfer

Practice What You Preach


RDT 2.0
What are the flaws or is there room for
improvement in RDT 2.0?

Typical answer
I Corrupted ACK or NAK!
I Duplicates
I Should not we ACK the ACK or NAK?
I Stop and wait, waste resources!
I Lost packets!
I Infinite re-transmissions?
PAIR UP and I How long would you wait for an ACK?
DISCUSS I Weak checksum: bit errors that cannot be
detected?

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 251 / 487
Transport Layer Reliable Data Transfer

Reliable Data Transfer


RDT 2.1 Sender (garbled ACK/NAK)

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 252 / 487
Transport Layer Reliable Data Transfer

Reliable Data Transfer


RDT 2.1 Receiver (garbled ACK/NAK)

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 253 / 487
Transport Layer Reliable Data Transfer

Reliable Data Transfer


RDT 2.2 Sender (NAK-free)

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 254 / 487
Transport Layer Reliable Data Transfer

Reliable Data Transfer


RDT 2.2 Receiver (NAK-free)

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 255 / 487
Transport Layer Reliable Data Transfer

Reliable Data Transfer


RDT 3.0 Receiver (lost packets)

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 256 / 487
Transport Layer Reliable Data Transfer

Reliable Data Transfer


RDT 3.0 Receiver (Same as RDT 2.2)

notcorrupt
AND
seq=0
corrupt corrupt
OR Wait for 0 Wait for 1 OR
seq=1 seq=0
notcorrupt
AND
seq=1

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 257 / 487
Transport Layer Reliable Data Transfer

Reliable Data Transfer


RDT 2.3: The Alternating-bit Protocol

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 258 / 487
Transport Layer Reliable Data Transfer

Reliable Data Transfer


RDT 2.3: The Alternating-bit Protocol

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 259 / 487
Transport Layer Reliable Data Transfer

Practice What You Preach


RDT 3.0

Performance of RDT 3.0: 1 Gbps link, 15 ms


prop. delay, 8000 bit packet. What is the
utilization of sender?

PAIR UP and
DISCUSS

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 260 / 487
Transport Layer Reliable Data Transfer

Practice What You Preach


RDT 3.0

Performance of RDT 3.0: 1 Gbps link, 15 ms


prop. delay, 8000 bit packet. What is the
utilization of sender?
Typical answer
dt = L/R = 8000/109 = 8 microseconds
Ack at the sender at 15 + 15 + 0.008 = 30.008
msec (assuming dt for ACK is negligible.)
When RTT=30 msec, 1KB packet every 30 msec;
then, 33 kB/sec throughput over 1 Gbps link!
Utilization of sender,
PAIR UP and
Us = RT TL/R
+L/R = 0.008/30.008 = 0.00027
DISCUSS
Not a good performance. What can you do?

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 260 / 487
Transport Layer Reliable Data Transfer

Reliable Data Transfer


Stop-and-wait Operation

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 261 / 487
Transport Layer Reliable Data Transfer

Reliable Data Transfer


Stop-and-wait versus pipelined

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 262 / 487
Transport Layer Reliable Data Transfer

Reliable Data Transfer


Pipelining

Pipelining
Rather than operating in a stop-and-wait manner, the sender is allowed
to send multiple packets without waiting for acknowledgments. Many
in-transit sender-to-receiver packets can be visualized as filling a
pipeline.

Consequences:
I sequence numbers
I buffer
I responding to lost, corrupted, and overly delayed packets.
Two basic approaches toward pipelined error recovery can be
identified: Go-Back-N and selective repeat.

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 263 / 487
Transport Layer Reliable Data Transfer

Reliable Data Transfer


Pipelined Operation

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 264 / 487
Transport Layer Reliable Data Transfer

Practice What You Preach


Pipelining

1 Gbps link, 15 ms prop. delay, 8000 bit packet.


What is the utilization of sender when 3-packet
pipelining is employed.

PAIR UP and
DISCUSS

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 265 / 487
Transport Layer Reliable Data Transfer

Practice What You Preach


Pipelining

1 Gbps link, 15 ms prop. delay, 8000 bit packet.


What is the utilization of sender when 3-packet
pipelining is employed.

Typical answer
Utilization of sender,
Us = RT3L/R
T +L/R = 0.0024/30.008 = 0.00081
Increased by a factor of 3.
PAIR UP and
DISCUSS

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 265 / 487
Transport Layer Reliable Data Transfer

Reliable Data Transfer


Pipelining

Go-back-N
I sender can have up to N unacked packets in pipeline
I receiver only sends cumulative ack: does not ack packet if there is
a gap
I sender has timer for oldest unacked packet: when timer expires,
retransmit all unacked packets

Selective Repeat
I sender can have up to N unacked packets in pipeline
I receiver sends individual ack for each packet
I sender maintains timer for each unacked packet: when timer
expires, retransmit only that unacked packet

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 266 / 487
Transport Layer Reliable Data Transfer

Reliable Data Transfer


Go-back-N

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 267 / 487
Transport Layer Reliable Data Transfer

Reliable Data Transfer


Go-back-N Sender

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 268 / 487
Transport Layer Reliable Data Transfer

Reliable Data Transfer


Go-back-N Receiver

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 269 / 487
Transport Layer Reliable Data Transfer

Reliable Data Transfer


Go-back-N in Operation

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 270 / 487
Transport Layer Reliable Data Transfer

Reliable Data Transfer


Selective Repeat: Sender

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 271 / 487
Transport Layer Reliable Data Transfer

Reliable Data Transfer


Selective Repeat: Receiver

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 272 / 487
Transport Layer Reliable Data Transfer

Reliable Data Transfer


Selective Repeat in Operation

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 273 / 487
Transport Layer Reliable Data Transfer

Reliable Data Transfer


Selective Repeat: Too Large Windows I

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 274 / 487
Transport Layer Reliable Data Transfer

Reliable Data Transfer


Selective Repeat: Too Large Windows II

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 275 / 487
Transport Layer Reliable Data Transfer

Reliable Data Transfer


Summary of Mechanisms for Reliable Data Transfer

I Checksum: any errors?


I Timer: packet or its ACK is lost?
I Sequence number: in-order, lost packet?
I Acknowledgment: correctly received?
I Negative acknowledgement: not received correctly?
I Window, pipelining: increased utilization

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 276 / 487
Transport Layer Transmission Control Protocol (TCP)

Transmission Control Protocol (TCP)


Introduction (RFCs: 793,1122,1323, 2018, 2581)

I point-to-point: one sender, one receiver


I reliable, in-order byte stream: no ”message boundaries”
I pipelined: TCP congestion and flow control set window size
I full duplex data: bi-directional data flow in same connection
I connection-oriented: handshaking (exchange of control msgs)
inits sender, receiver state before data exchange
I flow controlled: sender will not overwhelm receiver

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 277 / 487
Transport Layer Transmission Control Protocol (TCP)

Transmission Control Protocol (TCP)


Send and Receive Buffers

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 278 / 487
Transport Layer Transmission Control Protocol (TCP)

Transmission Control Protocol (TCP)


Segment Structure

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 279 / 487
Transport Layer Transmission Control Protocol (TCP)

Transmission Control Protocol (TCP)


Dividing File into TCP Segments

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 280 / 487
Transport Layer Transmission Control Protocol (TCP)

Transmission Control Protocol (TCP)


Sequence Numbers

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 281 / 487
Transport Layer Transmission Control Protocol (TCP)

Transmission Control Protocol (TCP)


Round Trip Time, Timeout

How to set TCP timeout value?


I longer than RTT but RTT varies
I too short: premature timeout, unnecessary retransmissions
I too long: slow reaction to segment loss

How to estimate RTT?


I SampleRTT: measured time from segment transmission until ACK
receipt, ignore retransmissions
I SampleRTT will vary, want estimated RTT ”smoother”: average
several recent measurements, not just current SampleRTT

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 282 / 487
Transport Layer Transmission Control Protocol (TCP)

Transmission Control Protocol (TCP)


Estimating Round Trip Time and Setting Timeout
EstimatedRTT = (1 − α) EstimatedRTT + αSampleRTT
DevRTT = (1 − β) DevRTT + β |SampleRTT - EstimatedRTT |
TimeoutInterval = EstimatedRTT + 4 DevRTT

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 283 / 487
Transport Layer Transmission Control Protocol (TCP)

Transmission Control Protocol (TCP)


Reliable Data Transfer

I TCP creates RDT service on top of unreliable network layer


I pipelined segments
I cumulative acks
I single retransmission timer
I retransmissions triggered by:
I timeout events
I duplicate acks

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 284 / 487
Transport Layer Transmission Control Protocol (TCP)

Transmission Control Protocol (TCP)


TCP Sender

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 285 / 487
Transport Layer Transmission Control Protocol (TCP)

Transmission Control Protocol (TCP)


Retransmission Due to Lost Ack

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 286 / 487
Transport Layer Transmission Control Protocol (TCP)

Transmission Control Protocol (TCP)


Premature Timeout

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 287 / 487
Transport Layer Transmission Control Protocol (TCP)

Transmission Control Protocol (TCP)


Cumulative Ack

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 288 / 487
Transport Layer Transmission Control Protocol (TCP)

Transmission Control Protocol (TCP)


Ack Generation

Event at receiver TCP receiver action


Arrival of in-order segment with ex- Delayed ACK. Wait up to 500ms fo
pected seq #. All data up to ex- next segment. If no next segmen
pected seq # already ACKed send ACK
Arrival of in-order segment with ex- Immediately send single cumula
pected seq #. One other segment tive ACK, ACKing both in-order seg
has ACK pending ments
arrival of out-of-order segment immediately send duplicate ACK
higher than expect seq. #. Gap indicating seq.# of next expecte
detected byte
arrival of segment that partially or immediate send ACK, provided tha
completely fills gap segment starts at lower end of gap

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 289 / 487
Transport Layer Transmission Control Protocol (TCP)

Transmission Control Protocol (TCP)


Fast Retransmit

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 290 / 487
Transport Layer Transmission Control Protocol (TCP)

Transmission Control Protocol (TCP)


Flow Control
Flow Control
receiver controls sender, so sender won’t overflow receiver’s buffer by
transmitting too much, too fast

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 291 / 487
Transport Layer Transmission Control Protocol (TCP)

Transmission Control Protocol (TCP)


Connection Management
Handshake
agree to establish connection (each knowing the other willing to
establish connection) and agree on connection parameters

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 292 / 487
Transport Layer Transmission Control Protocol (TCP)

Transmission Control Protocol (TCP)


Closing TCP Connection

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 293 / 487
Transport Layer Transmission Control Protocol (TCP)

Transmission Control Protocol (TCP)


TCP States: Client

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 294 / 487
Transport Layer Transmission Control Protocol (TCP)

Transmission Control Protocol (TCP)


TCP States: Server

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 295 / 487
Transport Layer Congestion Control

Congestion Control
Principles

Congestion (informal)
too many sources sending too much data too fast for network to handle

Manifestations:
I lost packets (buffer overflow at routers)
I long delays (queueing in router buffers)

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 296 / 487
Transport Layer Congestion Control

Congestion Control
Causes/costs: Scenario 1

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 297 / 487
Transport Layer Congestion Control

Congestion Control
Causes/costs: Scenario 1

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 298 / 487
Transport Layer Congestion Control

Congestion Control
Causes/costs: Scenario 2

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 299 / 487
Transport Layer Congestion Control

Congestion Control
Causes/costs: Scenario 2

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 300 / 487
Transport Layer Congestion Control

Congestion Control
Causes/costs: Scenario 3

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 301 / 487
Transport Layer Congestion Control

Congestion Control
Causes/costs: Scenario 3

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 302 / 487
Transport Layer Congestion Control

Congestion Control
Approaches Towards Congestion Control

End-to-end Congestion Control


I no explicit feedback from network
I congestion inferred from end-system observed loss, delay
I approach taken by TCP

Network-assisted Congestion Control


I routers provide feedback to end systems
I single bit indicating congestion (SNA, DECbit, TCP/IP ECN, ATM)
I explicit rate for sender to send at

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 303 / 487
Transport Layer Congestion Control

TCP Congestion Control


TCP Slow Start

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 304 / 487
Transport Layer Congestion Control

TCP Congestion Control


TCP Congestion Control

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 305 / 487
Transport Layer Congestion Control

TCP Congestion Control


Evolution of TCP’s Congestion Window

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 306 / 487
Transport Layer Congestion Control

TCP Congestion Control


Fairness
Fairness Goal
If K TCP sessions share same bottleneck link of bandwidth R, each
should have average rate of R/K.

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 307 / 487
Transport Layer Congestion Control

TCP Congestion Control


Additive Increase Multiplicative Decrease (AIMD)

sender increases transmission rate (window size), probing for usable


bandwidth, until loss occurs
I additive increase: increase cwnd by 1 MSS every RTT until loss
detected
I multiplicative decrease: cut cwnd in half after loss

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 308 / 487
Transport Layer Congestion Control

TCP Congestion Control


Additive Increase Multiplicative Decrease (AIMD)

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 309 / 487
Transport Layer Congestion Control

TCP Congestion Control


Additive Increase Multiplicative Decrease (AIMD)

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 310 / 487
Transport Layer Congestion Control

TCP Congestion Control


Additive Increase Multiplicative Decrease (AIMD)

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 311 / 487
Transport Layer Congestion Control

TCP Congestion Control


Additive Increase Multiplicative Decrease (AIMD)

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 312 / 487
Transport Layer Congestion Control

TCP Congestion Control


Additive Increase Multiplicative Decrease (AIMD)

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 313 / 487
Transport Layer Congestion Control

TCP Congestion Control


UDP, Parallel TCP Connections and Fairness

Fairness and UDP


Multimedia applications often do not use TCP, do not want rate
throttled by congestion control. Therefore, they send audio/video at
constant rate, tolerate packet loss.

Fairness and parallel TCP connections


Applications may open multiple parallel connections between two
hosts such as web browsers. In this case, what happens to fairness?

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 314 / 487
Transport Layer Congestion Control

TCP Congestion Control


TCP Throughput

I Ignoring the slow start, the average TCP throughput is


T = 0.75W/RT T bytes/sec.
I In terms of segment
√ loss probability L the throughput is
T = 1.22S/(RT T L) where S is the maximum segment size.

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 315 / 487
Transport Layer Ticket to Retention

Ticket to Retention (TtR) Discussion


Summary - Main Learning Points

1. Reliable data transfer: What are the mechanisms for reliable data
transfer and how do you use them?
2. Flow control: Why and how do you implement flow control?
3. Congestion control: Why and how do you implement congestion
control?
4. UDP versus TCP Describe why an application developer might
choose to run an application over UDP rather than TCP.

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 316 / 487
Network Layer

Section 6

Network Layer
Network Layer

Objectives of the Lecture

At the end of this lecture, you will be able to


understand and describe the principles behind network layer services
such as network layer service models, forwarding versus routing, how
a router works, routing (path selection), broadcast, multicast and
analyze their implementation in the Internet.

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 317 / 487
Network Layer

Overview and Compulsory Reading

I Forwarding versus routing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4.1


I Virtual-circuit and datagram networks . . . . . . . . . . . . . . . . . . . . . . . . . 4.2
I Routers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4.3
I Internet Protocol (IP) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4.4
I Routing Algorithms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4.5
I Routing in the Internet . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4.6
I Broadcast and multicast . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4.7

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 318 / 487
Network Layer

Ticket to Retention (TtR) Question

1. Forwarding versus routing: What is relationship between


forwarding and routing?
2. Difference from Transport Layer Connection Setup: What is most
important difference between TCP 3-way handshake and virtual
circuit connection setup?
3. Datagram versus Virtual-circuits Compare?
4. What is inside a router?
5. LS or DV? Compare link state routing protocols with distance
vector protocols?

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 319 / 487
Network Layer Introduction to Network Layer

Network Layer
Introduction

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 320 / 487
Network Layer Introduction to Network Layer

Network Layer
Two Key Functions: Forwarding and Routing

Forwarding
move packets from router’s input to appropriate router output

Routing
determine route taken by packets from source to destination

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 321 / 487
Network Layer Introduction to Network Layer

Network Layer
Relationship Between Forwarding and Routing

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 322 / 487
Network Layer Introduction to Network Layer

Network Layer Services


For Individual Datagrams

Network service model


defines the characteristics of end-to-end transport of packets between
sender and receiver.
Network layer services for individual datagrams:
I guaranteed delivery
I guaranteed delivery with bounded delay

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 323 / 487
Network Layer Introduction to Network Layer

Network Layer Services


For Flow of Datagrams

Network layer services for for flow of datagrams:


I in-order datagram delivery
I guaranteed minimal bandwidth
I guaranteed maximal jitter (inter packet spacing)
I security services

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 324 / 487
Network Layer Introduction to Network Layer

Practice What You Preach


Internet Best-Effort Service

The Internet’s network layer provides a single


service: best-effort service.
Fill in the table.
Service Internet
Bandwidth guarantee
No-loss guarantee
Ordering
Timing guarantee
Packet delivery guar.
Congestion feedback
PAIR UP and Security
DISCUSS

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 325 / 487
Network Layer Introduction to Network Layer

Practice What You Preach


Internet Best-Effort Service

The Internet’s network layer provides a single


service: best-effort service.
Fill in the table.
Service Internet
Bandwidth guarantee NONE
No-loss guarantee NONE
Ordering ANY ORDER
Timing guarantee NONE
Packet delivery guar. NONE
Congestion feedback NONE
PAIR UP and Security NONE
DISCUSS How to you infer congestion in TCP?

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 325 / 487
Network Layer Virtual-circuit and Datagram Networks

Virtual-circuit and Datagram Networks


Definitions

Datagram network
provides network-layer connectionless service

Virtual-circuit network
provides network-layer connection service

Similar to TCP/UDP connecton-oriented/connectionless transport-layer


services, but:
I service: host-to-host
I no choice: network provides one or the other
I implementation: in network core

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 326 / 487
Network Layer Virtual-circuit and Datagram Networks

Virtual-circuit
Implementation
I call setup before data flow
I packets carry VC identifier (not host address)
I routers maintain “state” for each passing connection
I bandwidth, buffers may be allocated to VC

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 327 / 487
Network Layer Virtual-circuit and Datagram Networks

Virtual-circuit
Implementation
A virtual circuit consists of
I Path: e.g., A-R1-R2-B
I VC numbers for each link on path e.g., 12,22,32
I Forwarding table on each router: shown below for R1

I How does a router determine the replacement VC number?


I Why not the same VC number on each link?
Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 328 / 487
Network Layer Virtual-circuit and Datagram Networks

Virtual-circuit
Implementation

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 329 / 487
Network Layer Virtual-circuit and Datagram Networks

Datagram Networks
Attributes
I no call setup at network layer
I routers have no state about end-to-end connections
I no network-level concept of “connection”
I packets forwarded using destination host address

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 330 / 487
Network Layer Virtual-circuit and Datagram Networks

Datagram Networks
Forwarding Table

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 331 / 487
Network Layer Virtual-circuit and Datagram Networks

Datagram Networks
Forwarding Table

What happens if ranges don’t divide up so nicely?


Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 332 / 487
Network Layer Virtual-circuit and Datagram Networks

Datagram Networks
Forwarding Table

Longest Prefix Matching


Router finds the longest matching entry in the forwarding table and
forwards the packet to the link interface associated with the entry.

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 333 / 487
Network Layer Virtual-circuit and Datagram Networks

Ticket to Retention (TtR) Question


Datagram versus Virtual Circuit
Datagram versus Virtual-circuits Fill in the below table?
Feature Datagram VC
Packets go on same routes
Out of sequence pkts possible
Packets contain addr/conn-id
Table changes for each connection
Requires connection setup
First packet delay large
Impact of router failure
Bursty traffic
Routers have conn. state
Bandwidth reservation possible

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 334 / 487
Network Layer Virtual-circuit and Datagram Networks

Ticket to Retention (TtR) Question


Datagram versus Virtual Circuit
Datagram versus Virtual-circuits Fill in the below table?
Feature Datagram VC
Packets go on same routes
may be diff. same
Out of sequence pkts possible
may be not possible
Packets contain addr/conn-id
addresses conn-id
Table changes for each connection
no yes
Requires connection setup
no yes
First packet delay large
no yes
Impact of router failure
moderate large
Bursty traffic
yes yes
Routers have conn. state
no yes
Bandwidth reservation possible
no yes

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 334 / 487
Network Layer What is inside a Router?

Routers
What is inside?

Router Functions
running routing algorithms/protocol (RIP, OSPF, BGP) and forwarding
datagrams from incoming to outgoing link
Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 335 / 487
Network Layer What is inside a Router?

Routers
Input Port Processing

Decentralized Switching
I given datagram dest., lookup output port using forwarding table in
input port memory
I goal: complete input port processing at ’line speed’
I queuing: if datagrams arrive faster than forwarding rate into switch
fabric
Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 336 / 487
Network Layer What is inside a Router?

Switching Fabrics
Switching via Memory

First generation
I traditional computers with switching under direct control of CPU
I packet copied to system’s memory
I speed limited by memory bandwidth (2 bus crossings per
datagram)
Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 337 / 487
Network Layer What is inside a Router?

Switching Fabrics
Switching via Bus

Bus contention
I datagram from input port memory to output port memory via a
shared bus
I bus contention: switching speed
Dr. Ertan Onur (WINS Lab)
limited by bus bandwidth
CENG435 2017-2018 Fall 338 / 487
Network Layer What is inside a Router?

Switching Fabrics
Switching via Crossbar (interconnecting network)

I overcome bus bandwidth limitations


Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 339 / 487
Network Layer What is inside a Router?

Routers
Output Port Processing

I buffering required when datagrams arrive from fabric faster than


the transmission rate
I scheduling discipline chooses among queued datagrams for
transmission

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 340 / 487
Network Layer What is inside a Router?

Routers
Output Port Queuing

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 341 / 487
Network Layer What is inside a Router?

Routers
Input Port Queuing

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 342 / 487
Network Layer What is inside a Router?

Ticket to Retention (TtR) Question


Routers
What is inside a router Suppose that a datagram can be transferred from an input port
to a given output port in a time slot, but different output ports can receive datagrams
from different input ports in a single time slot. What is the minimal number of time
slots needed to transfer the packets shown from input ports to their output ports,
assuming any input queue scheduling order you want?

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 343 / 487
Network Layer What is inside a Router?

Ticket to Retention (TtR) Question


Routers
What is inside a router Suppose that a datagram can be transferred from an input port
to a given output port in a time slot, but different output ports can receive datagrams
from different input ports in a single time slot. What is the minimal number of time
slots needed to transfer the packets shown from input ports to their output ports,
assuming any input queue scheduling order you want?

The minimal number of time slots needed is 3. The scheduling is as follows. Slot 1: send X in top
input queue, send Y in middle input queue. Slot 2: send X in middle input queue, send Y in
bottom input queue Slot 3: send Z in bottom input queue.

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 343 / 487
Network Layer Internet Protocol (IP)

Internet Protocol (IP)


Overview

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 344 / 487
Network Layer Internet Protocol (IP)

Internet Protocol (IP)


Datagram Format

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 345 / 487
Network Layer Internet Protocol (IP)

Internet Protocol (IP)


IP Fragmentation and Reassembly

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 346 / 487
Network Layer Internet Protocol (IP)

Internet Protocol (IP)


IP Fragmentation and Reassembly

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 347 / 487
Network Layer Internet Protocol (IP)

IPv4 Addressing
Interface Addresses and Subnets

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 348 / 487
Network Layer Internet Protocol (IP)

IPv4 Addressing
Subnets

Subnet
is a network where devices can reach each other without an
intervening router. High order bits of IP addresses are the subnet part.

To determine the subnets, detach each interface from its host or router,
creating islands of isolated networks, with interfaces terminating the
end points of the isolated networks. Each of these isolated networks is
called a subnet.

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 349 / 487
Network Layer Internet Protocol (IP)

IPv4 Addressing
Subnet Addresses

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 350 / 487
Network Layer Internet Protocol (IP)

IPv4 Addressing
Subnets: Example

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 351 / 487
Network Layer Internet Protocol (IP)

IPv4 Addressing
CIDR

CIDR
The Internet’s address assignment strategy is known as Classless
Interdomain Routing (CIDR pronounced cider) [RFC 4632]. CIDR
generalizes the notion of subnet addressing. As with subnet
addressing, the 32-bit IP address is divided into two parts and again
has the dotted-decimal form a.b.c.d/x, where x indicates the number of
bits in the first part of the address.

How to get an IP Address


I Manual
I Dynamic Host Configuration Protocol (DHCP)

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 352 / 487
Network Layer Internet Protocol (IP)

IPv4 Addressing
Dynamic Host Configuration Protocol (DHCP)

I host broadcasts DHCP discover msg [optional]


I DHCP server responds with DHCP offer msg [optional]
I host requests IP address: DHCP request msg
I DHCP server sends address: DHCP ack msg
DHCP uses UDP service.

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 353 / 487
Network Layer Internet Protocol (IP)

IPv4 Addressing
Dynamic Host Configuration Protocol (DHCP)

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 354 / 487
Network Layer Internet Protocol (IP)

IPv4 Addressing
Dynamic Host Configuration Protocol (DHCP)

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 355 / 487
Network Layer Internet Protocol (IP)

IPv4 Addressing
How does an organization get IP address from ISP?

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 356 / 487
Network Layer Internet Protocol (IP)

IPv4 Addressing
How does an ISP get IP addresses?

ICANN
ICANN: Internet Corporation for Assigned Names and Numbers
(http://www.icann.org)
I allocates addresses
I manages DNS
I assigns domain names, resolves disputes

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 357 / 487
Network Layer Internet Protocol (IP)

IPv4 Addressing
Hierarchical Addressing

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 358 / 487
Network Layer Internet Protocol (IP)

IPv4 Addressing
Hierarchical Addressing

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 359 / 487
Network Layer Internet Protocol (IP)

IPv4 Addressing
Network Address Translation

motivation: local network uses just one IP address as far as outside


world is concerned:
I range of addresses not needed from ISP: just one IP address for
all devices
I can change addresses of devices in local network without
notifying outside world
I can change ISP without changing addresses of devices in local
network
I devices inside local net not explicitly addressable, visible by
outside world (a security plus)

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 360 / 487
Network Layer Internet Protocol (IP)

IPv4 Addressing
Network Address Translation

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 361 / 487
Network Layer Internet Protocol (IP)

IPv4 Addressing
Network Address Translation Problem
I client wants to connect to server with address 10.0.0.1
I server address 10.0.0.1 local to LAN (client cannot use it as
destination addr)
I externally visible address: 138.76.29.7. SOLUTION?

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 362 / 487
Network Layer Internet Protocol (IP)

IPv4 Addressing
Network Address Translation

Several Solutions:
I statically configure NAT to forward incoming connection requests
to a server inside
I Universal Plug and Play (UPnP) Internet Gateway Device (IGD)
Protocol: local servers learn public IP address and use IGD to
configure NAT ports
I external relaying (bridging) entity; both parties establish a
connection to the relay

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 363 / 487
Network Layer Internet Protocol (IP)

IPv4 Addressing
Internet Control Message Protocol (ICMP)

I used by hosts and routers to communicate network-level


information
I e.g., error reporting: unreachable host, network, port, protocol
I e.g., echo request/reply (used by ping)
I network-layer above IP: ICMP msgs carried in IP datagrams
I ICMP message: type, code plus first 8 bytes of IP datagram
causing error

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 364 / 487
Network Layer Internet Protocol (IP)

IPv4 Addressing
Internet Control Message Protocol (ICMP)
Type Code Description
0 0 echo reply (to ping)
3 0 destination network unreachable
3 1 destination host unreachable
3 2 destination protocol unreachable
3 3 destination port unreachable
3 6 destination network unknown
3 7 destination host unknown
4 0 source quench (congestion control)
8 0 echo request
9 0 router advertisement
10 0 router discovery
11 0 TTL expired
12 0 IP header bad

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 365 / 487
Network Layer Internet Protocol (IP)

Traceroute
UDP and ICMP working together

I Source sends series of UDP segments to dest, first set has TTL
=1, second set has TTL=2, etc.
I When nth set of datagrams arrives to nth router:
I Router discards datagrams and sends source ICMP messages
(type 11, code 0, TTL expired)
I ICMP messages includes name of router and IP address
I When ICMP messages arrives, source records RTTs
I When UDP segment reaches destination, destination returns
ICMP message (type 3, code 3, destination port unreachable)

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 366 / 487
Network Layer Internet Protocol (IP)

Internet Protocol Version 6 (IPv6)


Why not 32 bit addresses

I 32-bit address space full


I new header format helps speed up processing and forwarding
I header changes to facilitate QoS

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 367 / 487
Network Layer Internet Protocol (IP)

Internet Protocol Version 6 (IPv6)


IPv6 Header

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 368 / 487
Network Layer Internet Protocol (IP)

Internet Protocol Version 6 (IPv6)


Migration

I not all routers can be upgraded simultaneously


I mixed IPv4 and IPv6 routers
I Solution?

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 369 / 487
Network Layer Internet Protocol (IP)

Internet Protocol Version 6 (IPv6)


Migration: Header Conversion

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 370 / 487
Network Layer Internet Protocol (IP)

Internet Protocol Version 6 (IPv6)


Migration: Tunneling

Tunneling
IPv6 datagram is carried as payload in IPv4 datagram among IPv4
routers

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 371 / 487
Network Layer Internet Protocol (IP)

Internet Protocol Version 6 (IPv6)


Migration: Tunneling

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 372 / 487
Network Layer Internet Protocol (IP)

Ticket to Retention (TtR) Question


IP Addressing

Consider the network shown below. Each of the subnets A-D contains
at most 30 hosts; subnet E connects routers R1 and R2.

1. Assign network addresses to the five subnets


2. What is the network prefix advertised by router R1 to the public
Internet?

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 373 / 487
Network Layer Internet Protocol (IP)

Ticket to Retention (TtR) Question


IP Addressing - Answers

1. Each subnet needs to address up to 30 hosts, using the rightmost


5 bits of the address. The five subnet addresses are x.y.z.0/27,
x.y.z.32/27, x.y.z.64/27, x.y.z.96/27, and x.y.z.128/27 in dotted
decimal notation. Other answers with different bit values in bits 25,
26, and 27 are also possible, as long as the five three-bit patterns
used are unique.
2. x.y.z./24

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 374 / 487
Network Layer Routing Algorithms

Routing Algorithms
Interplay between Routing and Forwarding: Revisited

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 375 / 487
Network Layer Routing Algorithms

Routing Algorithms
Abstract Graph Model of Computer Network

Graph G = (N, E) where N = {u, v, w, x, y, z} is the set of routers and


E = {(u, v), (u, x), (v, x), (v, w), (x, w), (x, y), (w, y), (w, z), (y, z)} is the
set of links.
Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 376 / 487
Network Layer Routing Algorithms

Routing Algorithms
Abstract Graph Model of Computer Network

c(x, x0 ) is the cost of the link (x, x0 ) c(x1 , x2 , . . . , xn ) is the cost of the
path and is equal to c(x1 , x2 ) + c(x2 , x3 ), . . . , c(xn−1 , xn ).
What is the least-cost path between u and z?
Algorithm that finds the least-cost path is called as routing algorithm.
Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 377 / 487
Network Layer Routing Algorithms

Routing Algorithms
Classification

Global, link-state algorithms


All the routers have complete (all) topology and link cost information.
The network graph is present in all nodes.

Decentralized, distance vector algorithms


Routers know only physically connected neighbors and costs of only
those links. The calculation of the least-cost path is carried out in an
iterative, distributed manner. No node has complete information about
the costs of all network links.

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 378 / 487
Network Layer Routing Algorithms

Link-state Routing Algorithm


For source node u

I D(v): cost of the least-cost path from the source node to


destination v as of this iteration of the algorithm.
I p(v): previous node (neighbor of v) along the current least-cost
path from the source to v.
I N 0 : subset of nodes; v is in N 0 if the least-cost path from the
source to v is definitively known.

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 379 / 487
Network Layer Routing Algorithms

Link-state Routing Algorithm


For source node u

Complexity O n2 or O n log n when there are n nodes


 

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 380 / 487
Network Layer Routing Algorithms

Link-state Routing Algorithm


For source node u

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 381 / 487
Network Layer Routing Algorithms

Link-state Routing Algorithm


For source node u

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 382 / 487
Network Layer Routing Algorithms

Link-state Routing Algorithm


Pathological Case: Oscillation when cost=link load

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 383 / 487
Network Layer Routing Algorithms

Link-state Routing Algorithm


Pathological Case: Oscillation when cost=link load

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 384 / 487
Network Layer Routing Algorithms

Distance Vector Routing Algorithm


Difference from Link-State Routing

Difference from Link-State Routing


Whereas the LS algorithm is an algorithm using global information, the
distance- vector (DV) algorithm is iterative, asynchronous, and
distributed.

I Distributed: each node receives some information from one or


more of its directly attached neighbors, performs a calculation, and
then distributes the results of its calculation back to its neighbors.
I Iterative this process continues on until no more information is
exchanged between neighbors (self-terminating)
I Asynchronous does not require all of the nodes to operate in
lockstep with each other.

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 385 / 487
Network Layer Routing Algorithms

Distance Vector Routing Algorithm


At each node x

Let dx (y) be the least-cost path from x to y, then

dx (y) = min {c(x, v) + dv (y)} (1)


v

I This is Bellman-Ford Equation (dynamic programming).


I From time to time, each node sends out its distance vector
estimate.
I When a node receives a distance vector, it updates its own
distance vector using Eq. 1

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 386 / 487
Network Layer Routing Algorithms

Distance Vector Routing Algorithm


At each node x

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 387 / 487
Network Layer Routing Algorithms

Distance Vector Routing Algorithm


At each node x

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 388 / 487
Network Layer Routing Algorithms

Distance Vector Routing Algorithm


At each node x

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 389 / 487
Network Layer Routing Algorithms

Distance Vector Routing - Recap

Routing tables of each node


e.g., it takes 3 to reach C from A and the next hop is B

1 2
A B C
Dest. Next Metric … Dest. Next Metric … Dest. Next Metric …
A A 0 A A 1 A B 3
B B 1 B B 0 B B 2
C B 3 C C 2 C C 0

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 390 / 487
Network Layer Routing Algorithms

Distance Vector Routing - Recap

Event: BC link weight changes to 1 from 2


B broadcasts the new
routing information
to his neighbors
Routing table (A, 1) (A, 1)
is updated (B, 0) (B, 0)
(C, 1) (C, 1)

1 1
A B C
Dest. Next Metric … Dest. Next Metric … Dest. Next Metric …
A A 0 A A 1 A B 3 2
B B 1 B B 0 B B 1
C B 3 2 C C 1 C C 0

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 390 / 487
Network Layer Routing Algorithms

Distance Vector Routing - Recap

Event: New node D joins the network

broadcasts to update
tables of C, B, A with new entry for D

(A, 1) (A, 2)
(B, 0) (B, 1)
(C, 1) (C, 0)
(D, 2) (D, 1) (D, 0)

1 1 1
A B C D
Dest. Next Metric … Dest. Next Metric … Dest. Next Metric …
A A 0 A A 1 A B 2
B B 1 B B 0 B B 1
C B 2 C C 1 C C 0
D B 3 D C 2 D D 1

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 390 / 487
Network Layer Routing Algorithms

Distance Vector Routing - Recap

Event: node D leaves the network

1 1 1
A B C D
Dest. Next Metric … Dest. Des
Dest. Nex
Next Metr
Metric …
Next Metric …
c
… …
… … … … … … t. … t …
ic
D B 3 D C 2 D …
… D …
D B 1

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 390 / 487
Network Layer Routing Algorithms

Distance Vector Routing - Recap

Event: node D leaves the network


Loop starts

(D, 2) (D, 2)

1 1 1
A B C D
Dest. Next Metric … Dest. Next Metric … Dest. Next Metric …
… … … … … … … … …
D B 3 D C 2 D B 3

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 390 / 487
Network Layer Routing Algorithms

Distance Vector Routing - Recap

Event: node D leaves the network


Count to infinity

(D,5)
(D,4) (D,4)
(D,3)
(D,2) (D,2)

1 1 1
A B C D
Dest. Next Metric … Dest. Dest. Next Metric …
Next Metric …
c
… … … … … … … … …
D B 3, 5, … D C 2,4,6… 3, 5,
D B

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 390 / 487
Network Layer Routing Algorithms

Hierarchical Routing
Assumptions up to now

I All routers identical


I Topology is flat
These assumptions are not true in real life
I Does not scale to 232 interfaces
I Cannot store all destinations in routing table
I Updates will swamp capacity
Solution: the title of the slide

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 391 / 487
Network Layer Routing Algorithms

Hierarchical Routing
Scalability solution

Autonomous System (AS)


Aggregate routers into regions

I Intra-AS routing: routers in same AS run same routing protocol


I Routers in different AS can run different intra-AS routing protocols
I Gateway router: at the edge of AS, has link to router in another AS

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 392 / 487
Network Layer Routing Algorithms

Hierarchical Routing
Example

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 393 / 487
Network Layer Routing Algorithms

Hierarchical Routing
Inter-AS Tasks

Scenario
Suppose router in AS1 receives datagram destined outside of AS1. It
should forward the packet to the gateway router, but which one?

The tasks of inter-AS routing:


I AS1 must learn which destinations are reachable through AS2
and AS3
I Propagate this reachability information to all routers in AS1

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 394 / 487
Network Layer Routing Algorithms

Hierarchical Routing
Question
Question
Subnet x is in AS3 and not reachable from AS2. How does router 1d
know this?

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 395 / 487
Network Layer Routing Algorithms

Hierarchical Routing
Question

Question
Subnet x is in AS3 and not reachable from AS2. How does router 1d
know this?

Solution
Suppose AS1 learns via Inter-AS protocol that subnet x is reachable
via AS3 over gateway 1c but not via AS2. This information is propagate
to all nodes in AS2. Router 1d determines from Intra-AS routing that its
interface connected to 1a is on the least cost path to 1c. Updates its
routing table accordingly.

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 395 / 487
Network Layer Routing Algorithms

Hierarchical Routing
Question
Question
Subnet x is in AS3 and also reachable from AS2. How does router 1d
know this?

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 396 / 487
Network Layer Routing Algorithms

Hierarchical Routing
Question

Question
Subnet x is in AS3 and also reachable from AS2. How does router 1d
know this?

Solution: Hot potato routing


Send packet towards closes of two routers.

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 396 / 487
Network Layer Routing Algorithms

Routing in the Internet


Examples

Intra-AS Routing or Interior Gateway Protocols (IDP)


The most common Intra-AS routing protocols are
I RIP: Routing Information Protocols
I OSPF: Open Shortest Path First
I IGRP: Interior Gateway Routing Protocol (CISCO)

Inter-AS Routing
The glue that holds the Internet together
I BGP: Border Gateway Protocol

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 397 / 487
Network Layer Routing Algorithms

Routing in the Internet


Why Inter- and Intra-AS routing?

I inter-AS: admin wants control over how its traffic routed, who
routes through its net.
I intra-AS: single admin, so no policy decisions needed
I hierarchical routing saves table size, reduced update traffic
(scalability)
I intra-AS: can focus on performance
I inter-AS: policy may dominate over performance

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 398 / 487
Network Layer Routing Algorithms

Routing in the Internet


RIP: Routing Information Protocol

I Distance vector algorithm


I Distance metric: number of hops (max 15), each link has cost 1
I Distance vectors exchanged every 30 seconds (advertisement)
I Each advertisement contains up to 25 destination subnets

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 399 / 487
Network Layer Routing Algorithms

Routing in the Internet


RIP: Routing Information Protocol

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 400 / 487
Network Layer Routing Algorithms

Routing in the Internet


RIP: Routing Information Protocol

Routing table
Dr. Ertan Onur ofLab)
(WINS D before receiving A’s advertisement
CENG435 2017-2018 Fall 401 / 487
Network Layer Routing Algorithms

Routing in the Internet


RIP: Routing Information Protocol

A’s advertisement
Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 402 / 487
Network Layer Routing Algorithms

Routing in the Internet


RIP: Routing Information Protocol

Routing table of D after receiving A’s advertisement


Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 403 / 487
Network Layer Routing Algorithms

Routing in the Internet


RIP: Routing Information Protocol

If no advertisement heard after 180 sec then neighbor/link is declared


down
I routes via neighbor invalidated
I new advertisements sent to neighbors
I neighbors in turn send out new advertisements (if tables changed)
I link failure info quickly (?) propagates to entire net
I poison reverse used to prevent ping-pong loops (infinite distance
= 16 hops)

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 404 / 487
Network Layer Routing Algorithms

Routing in the Internet


RIP: Routing Information Protocol

Implementation of RIP as route-d daemon.


Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 405 / 487
Network Layer Routing Algorithms

Routing in the Internet


OSPF: Open Shortest Path First

I Link-state (LS) algorithm


I LS packet dissemination
I Topology map at each node
I Route computation: Dijkstra’s shortest path algorithm
I OSPF advertisements carries one entry per neighbor in an IP
datagram that is flooded to network

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 406 / 487
Network Layer Routing Algorithms

Routing in the Internet


OSPF: Open Shortest Path First

I Security: all OSPF authenticated


I Multiple same-cost routes allowed
I Multiple cost metrics for different ToS
I Integrated uni- and multi-cast

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 407 / 487
Network Layer Routing Algorithms

Routing in the Internet


Hierarchical OSPF

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 408 / 487
Network Layer Routing Algorithms

Routing in the Internet


Hierarchical OSPF

I two-level hierarchy: local area, backbone.


I link-state advertisements only in area
I each nodes has detailed area topology; only know direction
(shortest path) to nets in other areas.
I area border routers: summarize distances to nets in own area,
advertise to other Area Border routers.
I backbone routers: run OSPF routing limited to backbone.
I boundary routers: connect to other AS’s.

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 409 / 487
Network Layer Routing Algorithms

Routing in the Internet


Inter-AS Routing, BGP: Border Gateway Protocol

I glue that holds the Internet together


I eBGP: obtain subnet reachability information from neighboring
ASs.
I iBGP: propagate reachability information to all AS-internal routers.
I determine good routes to other networks based on reachability
information and policy.
I allows subnet to advertise its existence to rest of Internet: “I am
here”

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 410 / 487
Network Layer Routing Algorithms

Routing in the Internet


Inter-AS Routing, BGP: Border Gateway Protocol

I Two BGP routers (peers) exchange BGP messages


I Advertising paths to different destination network prefixes over
TCP

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 411 / 487
Network Layer Routing Algorithms

Routing in the Internet


Inter-AS Routing, BGP: Border Gateway Protocol

When AS3 advertises a prefix to AS1


I AS3 promises it will forward datagrams towards that prefix
I AS3 can aggregate prefixes in its advertisement

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 412 / 487
Network Layer Routing Algorithms

Routing in the Internet


Inter-AS Routing, BGP: Border Gateway Protocol

I advertised prefix includes BGP attributes prefix + attributes =


“route”
I AS-PATH: contains ASs through which prefix advertisement has
passed: e.g., AS 67, AS 17
I NEXT-HOP: indicates specific internal-AS router to next-hop AS.
(may be multiple links from current AS to next-hop-AS)
I gateway router receiving route advertisement uses import policy
to accept/decline; e.g., never route through ASx

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 413 / 487
Network Layer Routing Algorithms

Routing in the Internet


Inter-AS Routing, BGP: Border Gateway Protocol

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 414 / 487
Network Layer Routing Algorithms

Routing in the Internet


Inter-AS Routing, BGP: Border Gateway Protocol

A router may learn about more than 1 route to destination AS, selects
route based on:
I local preference value attribute: policy decision
I shortest AS-PATH
I closest NEXT-HOP router: hot potato routing
I additional criteria

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 415 / 487
Network Layer Routing Algorithms

Routing in the Internet


Inter-AS Routing, BGP: Border Gateway Protocol

BGP messages:
I OPEN: opens TCP connection to peer and authenticates sender
I UPDATE: advertises new path (or withdraws old)
I KEEPALIVE: keeps connection alive in absence of UPDATES;
also ACKs OPEN request
I NOTIFICATION: reports errors in previous msg; also used to close
connection

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 416 / 487
Network Layer Routing Algorithms

Routing in the Internet


Inter-AS Routing, BGP: Border Gateway Protocol

I A,B,C are provider networks


I X,W,Y are customer (of provider networks)
I X is dual-homed: attached to two networks
I X does not want to route from B via X to C
I .. so X will not advertise to B a route to C

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 417 / 487
Network Layer Routing Algorithms

Routing in the Internet


Inter-AS Routing, BGP: Border Gateway Protocol

I A advertises path AW to B
I B advertises path BAW to X
I Should B advertise path BAW to C?
I No way! B gets no “revenue” for routing CBAW since neither W nor
C are B’s customers
I B wants to force C to route to W via A
I B wants to route only to/from its customers!
Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 418 / 487
Network Layer Routing Algorithms

Ticket to Retention (TtR) Question

1. Forwarding versus routing: What is relationship between


forwarding and routing?
2. Difference from Transport Layer Connection Setup: What is most
important difference between TCP 3-way handshake and virtual
circuit connection setup?
3. Datagram versus Virtual-circuits Compare?
4. What is inside a router?
5. LS or DV? Compare link state routing protocols with distance
vector protocols?

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 419 / 487
Data Link Layer

Section 7

Data Link Layer


Data Link Layer

Objectives of the Lecture

At the end of this lecture, you will be able to


describe the basic functions and principles of data link layer and
instantiation thereof

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 420 / 487
Data Link Layer

Overview and Compulsory Reading

I Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5.1
I Error detection and correction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5.2
I Multiple access protocols . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5.3
I Switched local area networks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5.4
I Link virtualization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5.5
I Data center networking . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5.6

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 421 / 487
Data Link Layer Introduction

Data Link Layer


Introduction

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 422 / 487
Data Link Layer Introduction

Data Link Layer


Introduction

Data link layer


has responsibility of transferring datagram from one node to physically
adjacent node over a link

I Node: hosts or routers


I Link: communication channels that connect adjacent nodes along
communication path (wired, wireless)
I Frame: layer-2 packet that encapsulates datagram

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 423 / 487
Data Link Layer Introduction

Data Link Layer Services I


Framing and link access
I encapsulate datagram into frame, adding header, trailer channel
access if shared medium
I Medium Access Control (MAC) addresses used in frame headers
to identify source, destination (different from IP address)

Reliable delivery between adjacent nodes


I Remember transport layer discussions
I Seldom used on low bit-error link (fiber, some twisted pair)
I Wireless links: high error rates

Flow control
pacing between adjacent sending and receiving nodes

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 424 / 487
Data Link Layer Introduction

Data Link Layer Services II

Error detection
Bit errors caused by signal attenuation, noise, fading etc. Receiver
detects presence of errors and signals sender for retransmission or
drops frame

Error correction
receiver identifies and corrects bit error(s) without resorting to
retransmission

Half- or full-duplex
with half duplex, nodes at both ends of link can transmit, but not at
same time

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 425 / 487
Data Link Layer Introduction

Data Link Layer


Where is the link layer implemented?

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 426 / 487
Data Link Layer Introduction

Data Link Layer


Communication

Sending side
I encapsulates datagram in frame
I adds error checking bits, reliable data transfer, flow control, etc.

Receiving side
I looks for errors, reliable data transfer, flow control, etc
I extracts datagram, passes to upper layer at receiving side

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 427 / 487
Data Link Layer Introduction

Ticket to Retention (TtR) Questions

1. Reliable data transfer: What are the mechanisms for reliable data
transfer and how do you use them?

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 428 / 487
Data Link Layer Error Detection and Correction

Error Detection and Correction


D: Data, EDC: Error detection and correction bits

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 429 / 487
Data Link Layer Error Detection and Correction

Error Detection and Correction


Parity Checks

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 430 / 487
Data Link Layer Error Detection and Correction

Error Detection and Correction


Parity Checks

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 431 / 487
Data Link Layer Error Detection and Correction

Error Detection and Correction


Internet Checksum

Goal
detect ”errors” (e.g., flipped bits) in transmitted packet (note: used at
transport layer only)

I Sender
I treat segment contents as sequence of 16-bit integers
I checksum: addition of segment contents and then 1’s complement
of the sum
I sender puts checksum value into UDP checksum field
I Receiver
I treat segment contents as sequence of 16-bit integers
I expected result = addition of segment contents and the checksum
sent in the header
I if expected result = all 1’s then everything is ok
I Otherwise, the segment is corrupt
Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 432 / 487
Data Link Layer Error Detection and Correction

Error Detection and Correction


Cyclic Redundancy Check (CRC)

I view data bits, D, as a binary number


I choose r + 1 bit pattern (generator), G
I choose CRC bits R (of length r) such that
I D||R is divisible by G modulo 2
I receiver knows G, divides D||R by G. Non-zero remainders
indicates error
I Ethernet, 802.11, WiFi, ATM

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 433 / 487
Data Link Layer Error Detection and Correction

Error Detection and Correction


Cyclic Redundancy Check (CRC)

D × 2r ⊕ R = nG
D × 2r = nG ⊕ R
D × 2r
 
R = Remainder
G

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 434 / 487
Data Link Layer Medium Access Control

Medium Access Control (MAC)


Multiple Access Channels

Point-to-point
consists of a single sender at one end of the link and a single receiver
at the other end of the link.

Broadcast link
can have multiple sending and receiving nodes all connected to the
same, single, shared broadcast channel. The term broadcast is used
here because when any one node transmits a frame, the channel
broadcasts the frame and each of the other nodes receives a copy.

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 435 / 487
Data Link Layer Medium Access Control

Medium Access Control (MAC)


Multiple Access Problem

Problem
How to coordinate the access of multiple sending and receiving nodes
to a shared broadcast channel

Collision
Because all nodes are capable of transmitting frames, more than two
nodes can transmit frames at the same time. When this happens, all of
the nodes receive multiple frames at the same time; that is, the
transmitted frames collide at all of the receivers. Typically, when there
is a collision, none of the receiving nodes can make any sense of any
of the frames that were transmitted; in a sense, the signals of the
colliding frames become inextricably tangled together.

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 436 / 487
Data Link Layer Medium Access Control

Medium Access Control (MAC)


Multiple Access Channels

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 437 / 487
Data Link Layer Medium Access Control

Medium Access Control (MAC)


Multiple Access Channels

Multiple Access Protocols


is distributed algorithm that determines how nodes share channel, i.e.,
determine when node can transmit communication about channel
sharing must use channel itself! No out-of-band channel for
coordination

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 438 / 487
Data Link Layer Medium Access Control

Medium Access Control (MAC)


An Ideal Multiple Access Protocol

I Given: a broadcast channel of rate R bps


I Desired rate:
1. when one node wants to transmit, it can send at rate R.
2. when M nodes want to transmit, each can send at average rate R/M
3. fully decentralized:
I no special node to coordinate transmissions
I no synchronization of clocks, slots
4. simple

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 439 / 487
Data Link Layer Medium Access Control

Medium Access Control (MAC)


Taxonomy

Channel partitioning
divide channel into smaller pieces (time slots, frequency, code) and
allocate piece to node for exclusive use

Random access
channel is not divided, allow collisions and we have to recover from
collisions

Taking turns
nodes take turns, but nodes with more to send can take longer turns

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 440 / 487
Data Link Layer Medium Access Control

Channel Partitioning
TDMA and FDMA

I TDMA: Time Division Multiple Access


I Access to channels in rounds
I Stations get fixed length slots (packet transmission time)
I Unused slots do idle
I FDMA: Frequency Division Multiple Access
I Spectrum divided into frequency bands
I Stations get fixed frequency bands
I Unused bands go idle

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 441 / 487
Data Link Layer Medium Access Control

Channel Partitioning
TDMA and FDMA

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 442 / 487
Data Link Layer Medium Access Control

Random Access Protocols

I when node has packet to send


I transmit at full channel data rate R.
I no a priori coordination among nodes
I two or more transmitting nodes, then collision,
I random access MAC protocol specifies:
I how to detect collisions
I how to recover from collisions (e.g., via delayed retransmissions)
I Examples: ALOHA, slotted ALOHA, CSMA, CSMA/CD, CSMA/CA

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 443 / 487
Data Link Layer Medium Access Control

Random Access Protocols


Slotted ALOHA

I Assumptions
I all frames same size
I time divided into equal size slots (time to transmit 1 frame)
I nodes start to transmit only slot beginning
I nodes are synchronized
I if 2 or more nodes transmit in slot, all nodes detect collision
I Operation: when node obtains fresh frame, transmits in next slot
I if no collision: node can send new frame in next slot
I if collision: node retransmits frame in each subsequent slot with
prob. p until success

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 444 / 487
Data Link Layer Medium Access Control

Random Access Protocols


Slotted ALOHA

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 445 / 487
Data Link Layer Medium Access Control

Random Access Protocols


Advantages/Disadvantage of Slotted ALOHA

Pros
I single active node can continuously transmit at full rate of channel
I highly decentralized: only slots in nodes need to be in sync
I simple

Cons
I collisions, wasting slots
I idle slots
I nodes may be able to detect collision in less than time to transmit
packet
I clock synchronization

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 446 / 487
Data Link Layer Medium Access Control

Random Access Protocols


Advantages/Disadvantage of Slotted ALOHA

Efficiency
long-run fraction of successful slots (many nodes, all with many frames
to send)

I Suppose N nodes with many frames to send, each node transmits


in a slot with probability p
I Probability that a given node has success in a slot is p(1 − p)N −1
I Probability that any node has a success is N p(1 − p)N −1
I Max efficiency: find p that maximizes N p(1 − p)N −1
I As N → ∞, max efficiency = 1/e = .37 or (37%)

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 447 / 487
Data Link Layer Medium Access Control

Random Access Protocols


Pure (Unslotted) ALOHA
I Simpler, no synchronization
I When frame arrives, transmit immediately
I Probability that a given node has a success is N p(1 − p)2(N −1)
I As N → ∞, max efficiency = 1/(2e) = .18 or (18%)

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 448 / 487
Data Link Layer Medium Access Control

Random Access Protocols


CSMA: Carrier Sense Multiple Access
I Listen before transmit
I If channel is idle, transmit entire frame
I If channel is busy, defer (delay) transmission

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 449 / 487
Data Link Layer Medium Access Control

Random Access Protocols


CSMA/CD: Carrier Sense Multiple Access/Collision Detection

I Listen before transmit


I If channel is idle, transmit entire frame
I If channel is busy, defer (delay) transmission
I Collisions can be detected within short time
I Wired: measure signal strength, compare transmitted and
received signals
I Wireless: not that easy

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 450 / 487
Data Link Layer Medium Access Control

Random Access Protocols


CSMA/CD: Carrier Sense Multiple Access/Collision Detection

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 451 / 487
Data Link Layer Medium Access Control

Random Access Protocols


Ethernet CSMA/CD

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 452 / 487
Data Link Layer Medium Access Control

Random Access Protocols


Ethernet CSMA/CD, Binary Exponential Back-off

Why random amount of time after collisions?


if two nodes transmitted frames at the same time and then both waited
the same fixed amount of time, they would continue colliding forever?

Question: How to choose how much to back off?


Answer: BEB (Binary Exponential Back-off)
I after mth collision, node chooses K at random from
0, 1, 2, . . . , 2m−1 . Node waits K × 512 bit times, returns channel


sensing
I longer back-off interval with more collisions

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 453 / 487
Data Link Layer Medium Access Control

Random Access Protocols


Ethernet CSMA/CD, Binary Exponential Back-off

Efficiency
Let dp be maximum propagation delay between two nodes and dt be
the time to transmit maximum size frame. Then, efficiency of
CSMA/CD is
1
ECSMA/CD = d
.
1 + 5 dpt
Check the limits,
lim ECSMA/CD → 1,
dp →0

and
lim ECSMA/CD → 1.
dt →∞

Better performance than ALOHA.

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 454 / 487
Data Link Layer Medium Access Control

Taking-turns Protocols
Polling

I master node invites slave nodes to transmit in turn


I typically used with ”dumb” slave devices
I concerns:
I polling overhead
I latency
I single point of failure (master)

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 455 / 487
Data Link Layer Medium Access Control

Taking-turns Protocols
Token Passing

I control token passed from one node to next sequentially.


I token message
I concerns:
I token overhead
I latency
I single point of failure (token)

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 456 / 487
Data Link Layer Medium Access Control

Taking-turns Protocols
Example: Cable Access Network (DOCSIS)

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 457 / 487
Data Link Layer Switched Local Area Networks

Switched Local Area Networks


Example

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 458 / 487
Data Link Layer Switched Local Area Networks

Switched Local Area Networks


Link Layer Addressing

I MAC Addresses (LAN, physical, Ethernet addresses) are locally


used to get frame from one interface to another physically
connected interface
I 48 bit MAC address (for most LANs) burned in NIC ROM, also
sometimes software settable
I e.g.: 1A-2F-BB-76-09-AD
I MAC address allocation administered by IEEE
I manufacturer buys portion of MAC address space (to assure
uniqueness)
I MAC flat address facilitates portability: can move LAN card from
one LAN to another

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 459 / 487
Data Link Layer Switched Local Area Networks

Switched Local Area Networks


Link Layer Addressing

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 460 / 487
Data Link Layer Switched Local Area Networks

Switched Local Area Networks


Address Resolution Protocol (ARP)

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 461 / 487
Data Link Layer Switched Local Area Networks

Switched Local Area Networks


Address Resolution Protocol (ARP)

I ARP table: each IP node (host, router) on LAN has table


I IP/MAC address mappings for some LAN nodes: IP address;
MAC address; TTL¿
I TTL (Time To Live): time after which address mapping will be
forgotten (typically 20 min)

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 462 / 487
Data Link Layer Switched Local Area Networks

Switched Local Area Networks


Address Resolution Protocol (ARP)

I A wants to send datagram to B


I B’s MAC address not in A’s ARP table.
I A broadcasts ARP query packet, containing B’s IP address
I Destination MAC address is FF-FF-FF-FF-FF-FF
I B receives ARP packet, replies to A with its (B’s) MAC address
I frame sent to A’s MAC address (unicast)
I A caches (saves) IP-to-MAC address pair in its ARP table until
information becomes old (times out)
I ARP is plug-and-play: nodes create their ARP tables without
intervention from network administrator

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 463 / 487
Data Link Layer Switched Local Area Networks

Switched Local Area Networks


Address Resolution Protocol (ARP)

I walkthrough: send datagram from A to B via R


I A knows R’s MAC address (how?)

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 464 / 487
Data Link Layer Switched Local Area Networks

Switched Local Area Networks


Ethernet
Bus
popular through mid 90s; all nodes in same collision domain (can
collide with each other)

Star
prevails today; active switch in center; each spoke runs a (separate)
Ethernet protocol (nodes do not collide with each other)

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 465 / 487
Data Link Layer Switched Local Area Networks

Switched Local Area Networks


Ethernet

I connectionless: no handshaking between sending and receiving


NICs
I unreliable: receiving NIC doesnt send acks or nacks to sending
NIC: data in dropped frames recovered only if initial sender uses
higher layer rdt (e.g., TCP), otherwise dropped data lost
I Ethernet’s MAC protocol: unslotted CSMA/CD wth binary backoff

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 466 / 487
Data Link Layer Switched Local Area Networks

Switched Local Area Networks


Ethernet

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 467 / 487
Data Link Layer Switched Local Area Networks

Switched Local Area Networks


Ethernet Switch

I link-layer device: takes an active role


I store, forward Ethernet frames
I examine incoming frame’s MAC address, selectively forward
frame to one-or-more outgoing links when frame is to be
forwarded on segment, uses CSMA/CD to access segment
I transparent: hosts are unaware of presence of switches
I plug-and-play, self-learning: switches do not need to be configured

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 468 / 487
Data Link Layer Switched Local Area Networks

Switched Local Area Networks


Ethernet Switch

switching: A-to-A’ and B-to-B’ can transmit simultaneously, without


collisions
Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 469 / 487
Data Link Layer Switched Local Area Networks

Switched Local Area Networks


Ethernet Switch

Question
How does a switch know A’ is reachable via interface 4?

I The switch has a switch table


I Entry: MAC address of host, interface to reach host, time stamp
I How to populate switch table: when frames received, switch
learns location of sender and stores this piece of information

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 470 / 487
Data Link Layer Switched Local Area Networks

Switched Local Area Networks


Ethernet Switch: Frame Forwarding

I record incoming link, MAC address of sending host


I index switch table using MAC destination address
I if entry found for destination then
I if destination on segment from which frame arrived then
I drop frame
I else
I forward frame on interface indicated by entry
I else
I flood: forward on all interfaces except arriving interface

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 471 / 487
Data Link Layer Switched Local Area Networks

Switched Local Area Networks


Ethernet Switches

Sending from A to G?

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 472 / 487
Data Link Layer Switched Local Area Networks

Switched Local Area Networks


Switches, Routers, Hosts

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 473 / 487
Data Link Layer Switched Local Area Networks

Switched Local Area Networks


Virtual Local Area Networks

Virtual Local Area Network


Switch(es) supporting VLAN capabilities can be configured to define
multiple virtual LANS over single physical LAN infrastructure.

Port-based VLAN
switch ports grouped (by switch management software) so that single
physical switch operates as multiple virtual switches

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 474 / 487
Data Link Layer Switched Local Area Networks

Switched Local Area Networks


Virtual Local Area Networks

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 475 / 487
Data Link Layer Switched Local Area Networks

Switched Local Area Networks


Virtual Local Area Networks

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 476 / 487
Data Link Layer Switched Local Area Networks

Switched Local Area Networks


Virtual Local Area Networks: 802.1Q VLAN Frame Format

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 477 / 487
Data Link Layer Link Virtualization

Link Virtualization: MPLS


MPLS: Multi-protocol Label Switching
Goal
high-speed IP forwarding using fixed length label (instead of IP
address)
I fast lookup using fixed length identifier (rather than shortest prefix
matching)
I borrowing ideas from Virtual Circuit (VC) approach
I but IP datagram still keeps IP address!

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 478 / 487
Data Link Layer Link Virtualization

Link Virtualization: MPLS


MPLS: Multi-protocol Label Switching

I a.k.a. label-switched router


I forward packets to outgoing interface based only on label value
(don’t inspect IP address)
I MPLS forwarding table distinct from IP forwarding tables
I flexibility: MPLS forwarding decisions can differ from those of IP
I use destination and source addresses to route flows to same
destination differently (traffic engineering)
I re-route flows quickly if link fails: pre-computed backup paths
(useful for VoIP)

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 479 / 487
Data Link Layer Link Virtualization

Link Virtualization: MPLS


MPLS Signaling

I modify OSPF, IS-IS link-state flooding protocols to carry info used


by MPLS routing, e.g., link bandwidth, amount of ”reserved” link
bandwidth
I entry MPLS router uses RSVP-TE signaling protocol to set up
MPLS forwarding at downstream routers

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 480 / 487
Data Link Layer Link Virtualization

Link Virtualization: MPLS


MPLS Forwarding Tables

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 481 / 487
Data Link Layer Data Center Networks

Data Center Networks

I 10’s to 100’s of thousands of hosts, often closely coupled, in close


proximity
I multiple applications, each serving massive numbers of clients
I managing/balancing load, avoiding processing, networking, data
bottlenecks

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 482 / 487
Data Link Layer Data Center Networks

Data Center Networks


Load Balancing

I receives external client requests


I directs workload within data center
I returns results to external client (hiding data center internals from
client)

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 483 / 487
Data Link Layer Data Center Networks

Data Center Networks


Load Balancing

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 484 / 487
Data Link Layer Data Center Networks

Data Center Networks


Rich Interconnection

I increased throughput between racks (multiple routing paths


possible)
I increased reliability via redundancy

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 485 / 487
Data Link Layer Data Center Networks

Ticket to Retention (TtR) Discussion


Summary - Main Learning Points

I principles behind data link layer services:


I error detection, correction
I sharing a broadcast channel: multiple access
I link layer addressing
I instantiation and implementation of various link layer technologies
I Ethernet
I switched LANS, VLANs
I virtualized networks as a link layer: MPLS

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 486 / 487
Data Link Layer Data Center Networks

References I

Kurose, James F. and Keith W. Ross (2013). Computer Networking.


Pearson.
Stallings, William (2013). Data and computer communications.
Vol. 10. Prentice Hall.
Tanenbaum, Andrew S. and David J. Wetherall (2011). Computer
networks. Vol. 5. Prentice-Hall Englewood Cliffs (NY).

Dr. Ertan Onur (WINS Lab) CENG435 2017-2018 Fall 487 / 487

You might also like