CS4/MSc Computer Networking · • Each ISP (residential ISP, company, university) has one. –...

30
CS4/MSc Computer Networking Lecture 2: Layered Network Architectures Network API Application API

Transcript of CS4/MSc Computer Networking · • Each ISP (residential ISP, company, university) has one. –...

Page 1: CS4/MSc Computer Networking · • Each ISP (residential ISP, company, university) has one. – Also called “default name server” • When a host makes a DNS query, query is sent

CS4/MScComputer Networking

Lecture 2: Layered Network Architectures

Network API

Application API

Page 2: CS4/MSc Computer Networking · • Each ISP (residential ISP, company, university) has one. – Also called “default name server” • When a host makes a DNS query, query is sent

2

Layered Network Architectures

• Networks are very complex systems

• Need a overall plan, an architecture

• How does a comp. scientist deal with complexity?

Divide and conquer + Abstraction. The challenge is to provide a useful service to other components and be efficient to implement in the underlying system.

• Abstraction leads to layering, if you do it a few times

• Layering provides modularity (think OO programming):–“Upgrade” a layer without affecting the others

–Add a parallel functionality in a layer, an alternative service to the layer’s “user”

Page 3: CS4/MSc Computer Networking · • Each ISP (residential ISP, company, university) has one. – Also called “default name server” • When a host makes a DNS query, query is sent

3

• Service: manner in which information is transferred– Information: stream, block

– “Quality”: lossless, delay guarantees, ..

• Protocol: set of agreed rules that accomplishes a task/service– Corresponds to a layer

• Interface: interaction with other entities– Service interface – with higher level entities

– Peer interface – with equivalent entity at remote computer

Layering, Services, Protocols and Interfaces

Application programs

Process-to-process channels

Host-to-host connectivity

Hardware

Host 1 Host 2

Serviceinterface

Peer-to-peerinterface

High-levelobject

High-levelobject

Protocol Protocol

Page 4: CS4/MSc Computer Networking · • Each ISP (residential ISP, company, university) has one. – Also called “default name server” • When a host makes a DNS query, query is sent

4

Layer services, encapsulation

n+1entity

n-SAP

n+1entity

n-SAP

n entity n entity

n-SDU

n-SDU

n-SDU

H

H n-SDU

n-PDU

Service interface

Peer interface

Page 5: CS4/MSc Computer Networking · • Each ISP (residential ISP, company, university) has one. – Also called “default name server” • When a host makes a DNS query, query is sent

5

• Segmentation – SDU too large– Sequencing, out-of-order delivery,…

• Blocking – SDU too small– Merge SDU before sending off a PDU

• Multiplexing – multiple n+1 level entities active at any one time

Effect of external factors to services

n+1entity

n+1entity

n+1entity

n+1entity

n entity n entity

n-SDUn-SDU

n-SDUH

H n-SDUn-PDU

Page 6: CS4/MSc Computer Networking · • Each ISP (residential ISP, company, university) has one. – Also called “default name server” • When a host makes a DNS query, query is sent

6

The OSI 7-layer network architecture

ApplicationLayer

PresentationLayer

SessionLayer

TransportLayer

NetworkLayer

Data LinkLayer

PhysicalLayer

ApplicationLayer

PresentationLayer

SessionLayer

TransportLayer

NetworkLayer

Data LinkLayer

PhysicalLayer

NetworkLayer

Application

Data LinkLayer

PhysicalLayer

NetworkLayer

Data LinkLayer

PhysicalLayer

Application

Page 7: CS4/MSc Computer Networking · • Each ISP (residential ISP, company, university) has one. – Also called “default name server” • When a host makes a DNS query, query is sent

7

• Evolved from Arpanet and other packet networks in 1983

• Communication across multiple diverse networks (internetworking)

• Assumes minimum service from underlying network, so that it can operate over any network

– Basic packet exchange is connectionless unreliable

• Provides two common services to applications– TCP: reliable connection oriented byte stream

– UDP: best-effort (no promises!) connectionless block data

Overview of the Internet architecture

Page 8: CS4/MSc Computer Networking · • Each ISP (residential ISP, company, university) has one. – Also called “default name server” • When a host makes a DNS query, query is sent

8

• Application layer covers top three OSI layers

• A sub-network is treated as a link

• Clear separation of internet layer from technology-dependent network interface layer

• Layering is not strictly enforced

The Internet architecture and protocols

TCP UDP

IPNetwork

Application

Page 9: CS4/MSc Computer Networking · • Each ISP (residential ISP, company, university) has one. – Also called “default name server” • When a host makes a DNS query, query is sent

9

• Provides a standard set of functions that can be called by applications

• Bi-directional

• Berkeley Socket is the most common API

• Variations depending on the operating system

Application Programming Interface

Host A Host B

port number port number

• Application references a socket through a descriptor• Socket bound to a port number

Application 1

Socket

Socketinterface

User

Kernel

Application 2

User

Kernel

Underlying communication

protocols

Underlying communication

protocols

Communications network

Socket

Socketinterface

Page 10: CS4/MSc Computer Networking · • Each ISP (residential ISP, company, university) has one. – Also called “default name server” • When a host makes a DNS query, query is sent

The Application Layer

Page 11: CS4/MSc Computer Networking · • Each ISP (residential ISP, company, university) has one. – Also called “default name server” • When a host makes a DNS query, query is sent

11

Network Applications

• Examine a popular network application: Web–Client-server architecture

–The underlying protocol: HTTP

• and a commonly used internet service: DNS

• Purpose:–Learn how some common applications work

–See some protocols in action

• More applications and details in Ch2 of Kurose-Ross

Page 12: CS4/MSc Computer Networking · • Each ISP (residential ISP, company, university) has one. – Also called “default name server” • When a host makes a DNS query, query is sent

12

HTTP overview

HTTP: hypertext transfer protocol

• Web’s application layer protocol

• client/server model

– client: browser that requests, receives, “displays” Web objects

– server: Web server sends objects in response to requests

• HTTP 1.0: RFC 1945

• HTTP 1.1: RFC 2068

PC runningExplorer

Server running

Apache Webserver

Mac runningNavigator

HTTP request

HTTP request

HTTP response

HTTP response

Page 13: CS4/MSc Computer Networking · • Each ISP (residential ISP, company, university) has one. – Also called “default name server” • When a host makes a DNS query, query is sent

13

HTTP overview (continued)

Uses TCP:• client initiates TCP connection

(creates socket) to server, port 80

• server accepts TCP connection from client

• HTTP messages (application-layer protocol messages) exchanged between browser (HTTP client) and Web server (HTTP server)

• TCP connection closed

HTTP is “stateless”• server maintains no

information about past client requests

Protocols that maintain “state” are complex!

• past history (state) must be maintained

• if server/client crashes, their views of “state” may be inconsistent, must be reconciled

aside

Page 14: CS4/MSc Computer Networking · • Each ISP (residential ISP, company, university) has one. – Also called “default name server” • When a host makes a DNS query, query is sent

14

HTTP connections

Nonpersistent HTTP• At most one object is sent over a TCP connection.

• HTTP/1.0 uses nonpersistent HTTP

Persistent HTTP• Multiple objects can be sent over single TCP connection between

client and server.

• HTTP/1.1 uses persistent connections in default mode

Page 15: CS4/MSc Computer Networking · • Each ISP (residential ISP, company, university) has one. – Also called “default name server” • When a host makes a DNS query, query is sent

15

Response times

Definition of RTT: time to send a small packet to travel from client to server and back.

Response time:

• one RTT to initiate TCP connection

• one RTT for HTTP request and first few bytes of HTTP response to return

• file transmission time

total = 2RTT+transmit time

time to transmit file

initiate TCPconnection

RTTrequestfile

RTT

filereceived

time time

Page 16: CS4/MSc Computer Networking · • Each ISP (residential ISP, company, university) has one. – Also called “default name server” • When a host makes a DNS query, query is sent

16

Persistent HTTP

Nonpersistent HTTP issues:• requires 2 RTTs per object

• OS overhead for each TCP connection

• browsers often open parallel TCP connections to fetch referenced objects

Persistent HTTP• server leaves connection

open after sending response

• subsequent HTTP messages between same client/server sent over open connection

Persistent without pipelining:• client issues new request only

when previous response has been received

• one RTT for each referenced object

Persistent with pipelining:• default in HTTP/1.1

• client sends requests as soon as it encounters a referenced object

• as little as one RTT for all the referenced objects

Page 17: CS4/MSc Computer Networking · • Each ISP (residential ISP, company, university) has one. – Also called “default name server” • When a host makes a DNS query, query is sent

17

HTTP request message

• Two types of HTTP messages: request, response

• HTTP request message:– ASCII (human-readable format)

GET /somedir/page.html HTTP/1.1Host: www.someschool.eduUser-agent: Mozilla/4.0Connection: close Accept-language:fr

(extra carriage return, line feed)

request line(GET, POST,

HEAD commands)

headerlines

Carriage return, line feed

indicates end of message

Page 18: CS4/MSc Computer Networking · • Each ISP (residential ISP, company, university) has one. – Also called “default name server” • When a host makes a DNS query, query is sent

18

Uploading form input

Post method:• Web page often includes form input

• Input is uploaded to server in body of request message

URL method:• Uses GET method

• Input is uploaded in URL field of request line:www.google.com/search?monkeys&banana

Page 19: CS4/MSc Computer Networking · • Each ISP (residential ISP, company, university) has one. – Also called “default name server” • When a host makes a DNS query, query is sent

19

HTTP response message

HTTP/1.1 200 OK Connection closeDate: Thu, 06 Aug 1998 12:00:15 GMT Server: Apache/1.3.0 (Unix) Last-Modified: Mon, 22 Jun 1998 …... Content-Length: 6821 Content-Type: text/html

data data data data data ...

status line(protocol

status codestatus phrase)

headerlines

data, e.g., requestedHTML file

Page 20: CS4/MSc Computer Networking · • Each ISP (residential ISP, company, university) has one. – Also called “default name server” • When a host makes a DNS query, query is sent

20

Cookies: keeping “state”

client serverusual http request msg

usual http response +set-cookie: 1678

usual http request msgcookie: 1678

usual http response msg

usual http request msgcookie: 1678

usual http response msg

cookie-specificaction

cookie-spectificaction

servercreates ID

1678 for user

entry in backend

database

access

access

Cookie file

amazon: 1678ebay: 8734

Cookie file

ebay: 8734

Cookie file

amazon: 1678ebay: 8734

one week later:

Page 21: CS4/MSc Computer Networking · • Each ISP (residential ISP, company, university) has one. – Also called “default name server” • When a host makes a DNS query, query is sent

21

DNS: Domain Name System

Internet hosts, routers:• IP address (32 bit) - used by

computers, network equipment

• “name”, e.g., www.yahoo.com -used by humans

How to map between IP addresses and name ?

Domain Name System:• distributed database

implemented in hierarchy of many name servers

• application-layer protocol host, routers, name servers to communicate to resolve names (address/name translation)– note: core Internet function,

implemented as application-layer protocol

– complexity at network’s “edge”

Page 22: CS4/MSc Computer Networking · • Each ISP (residential ISP, company, university) has one. – Also called “default name server” • When a host makes a DNS query, query is sent

22

DNS

Why not centralize DNS?• single point of failure

• traffic volume

• distant centralized database

• maintenance

doesn’t scale!

DNS services• Hostname to IP address

translation

• Host aliasing– Canonical and alias names

• Mail server aliasing

• Load distribution– Replicated Web servers: set

of IP addresses for one canonical name

Page 23: CS4/MSc Computer Networking · • Each ISP (residential ISP, company, university) has one. – Also called “default name server” • When a host makes a DNS query, query is sent

23

Root DNS Servers

com DNS servers org DNS servers uk DNS servers

ac.ukDNS servers

co.ukDNS servers

yahoo.comDNS servers

amazon.comDNS servers

pbs.orgDNS servers

Distributed, Hierarchical Database

Top-level domain (TLD) servers: responsible for com, org, net, edu, etc, and all top-level country domains uk, fr, ca, jp.

Authoritative DNS servers: organization’s DNS servers, providing authoritative hostname to IP mappings for organization’s servers (e.g., Web and mail).– Can be maintained by organization or service provider

Page 24: CS4/MSc Computer Networking · • Each ISP (residential ISP, company, university) has one. – Also called “default name server” • When a host makes a DNS query, query is sent

24

Local Name Server

• Does not strictly belong to hierarchy

• Each ISP (residential ISP, company, university) has one.– Also called “default name server”

• When a host makes a DNS query, query is sent to its local DNS server– Acts as a proxy, forwards query into hierarchy.

Page 25: CS4/MSc Computer Networking · • Each ISP (residential ISP, company, university) has one. – Also called “default name server” • When a host makes a DNS query, query is sent

25

requesting hostmars.ed.ac.uk

crete.uch.gr

root DNS server

local DNS serverdns.ed.ac.uk

23

4

5

61

authoritative DNS serverdns.uch.gr

78

TLD DNS server

Example

Host mars.inf.ed.ac.uk wants IP address for crete.csd.uch.gr

Page 26: CS4/MSc Computer Networking · • Each ISP (residential ISP, company, university) has one. – Also called “default name server” • When a host makes a DNS query, query is sent

26

Speeding up DNS: caching and updating records

• Once (any) name server learns mapping, it caches the information– TLD servers typically cached in local name servers

» Thus root name servers not often visited

– cache entries timeout (disappear) after some time

Page 27: CS4/MSc Computer Networking · • Each ISP (residential ISP, company, university) has one. – Also called “default name server” • When a host makes a DNS query, query is sent

27

DNS records

DNS: distributed db storing resource records (RR)

• Type=NS– name is domain (e.g.

foo.com)– value is hostname of

authoritative name server for this domain

RR format: (name, value, type, ttl)

• Type=A– name is hostname

– value is IP address

• Type=CNAME– name is alias name for some

“canonical” (the real) namewww.ibm.com is reallyservereast.backup2.ibm.com

– value is canonical name

• Type=MX– value is name of mailserver

associated with name

Page 28: CS4/MSc Computer Networking · • Each ISP (residential ISP, company, university) has one. – Also called “default name server” • When a host makes a DNS query, query is sent

28

Inserting records into DNS

• Example: just created startup “Network Utopia”

• Register name networkuptopia.com at a registrar– Need to provide registrar with names and IP addresses of your

authoritative name server (primary and secondary)

– Registrar inserts two RRs into the com TLD server:

(networkutopia.com, dns1.networkutopia.com, NS)

(dns1.networkutopia.com, 212.212.212.1, A)

• Put in authoritative server Type A record for www.networkuptopia.com and Type MX record for networkutopia.com

Page 29: CS4/MSc Computer Networking · • Each ISP (residential ISP, company, university) has one. – Also called “default name server” • When a host makes a DNS query, query is sent

29

• Kurose, Ross– 2.2, 2.5

– also read 2.3, 2.4, 2.6 for other applications/services

• Leon-Garcia, Widjaja– 2.1, 2.5

Reading

Page 30: CS4/MSc Computer Networking · • Each ISP (residential ISP, company, university) has one. – Also called “default name server” • When a host makes a DNS query, query is sent

30

• Kurose, Ross– 1.7, 2.1 2.7, 2.8

• Leon-Garcia, Widjaja– Chapter 2, 5.1

• Tanenbaum– Chapter 1

• Stallings:– Chapters 1, 2

• Peterson & Davie– Sections 1.2-1.3

Reading