65
Networking III: The Transport Layer and Internet names and addresses

Networking III: The Transport Layer and Internet names and addresses

  • View
    216

  • Download
    1

Embed Size (px)

Citation preview

Page 1: Networking III: The Transport Layer and Internet names and addresses

Networking III:The Transport Layer and

Internet names and addresses

Page 2: Networking III: The Transport Layer and Internet names and addresses

2

Announcements• Homework 5 due next Tuesday, November 11th

• Prelim II will be Thursday, November 20th, in class– Topics: Everything after first prelim– Lectures 14-22, chapters 10-15 (8th ed)

• Nazrul will teach next Tuesday, November 11th

Page 3: Networking III: The Transport Layer and Internet names and addresses

3

Review: Hierarchical Networking • How can we build a network with millions of hosts (the Internet)?

– Hierarchy! Not every host connected to every other one– Use a network of Routers to connect subnets together

subnet1

subnet2

Router

Othersubnets

Router

Router

TranscontinentalLink

subnet3Othersubnets

Page 4: Networking III: The Transport Layer and Internet names and addresses

4

Review: OSI Levels• Physical Layer

– electrical details of bits on the wire

• Data Link Layer– sending “frames” of bits and error detection

• Network Layer– routing packets to the destination

• Transport Layer– reliable transmission of messages, disassembly/assembly, ordering,

retransmission of lost packets

• Session Layer– really part of transport, typically Not implemented

• Presentation Layer– data representation in the message

• Application– high-level protocols (mail, ftp, etc.)

Page 5: Networking III: The Transport Layer and Internet names and addresses

5

Review: OSI Levels

Presentation

Transport

Network

Data Link

Physical

Application

Presentation

Transport

Network

Data Link

Physical

ApplicationNode A Node B

Network

Session Session

Network

Data Link

Physical

Router

Page 6: Networking III: The Transport Layer and Internet names and addresses

6

Purpose of this layer• Interface end-to-end applications and protocols

– Turn best-effort IP into a usable interface

• Data transfer between processes:– Compared to end-to-end IP

• We will look at 2:– UDP (Unreliable Datagram Protocol)– TCP (Transmission Control Protocol)

application

transportnetworkdata linkphysical

application

transportnetworkdata linkphysical

networkdata linkphysical

networkdata linkphysical

networkdata linkphysical

networkdata linkphysicalnetwork

data linkphysical

logical end-end transport

Page 7: Networking III: The Transport Layer and Internet names and addresses

7

UDP

• Unreliable Datagram Protocol

• Best effort data delivery between processes– No frills, bare bones transport protocol

– Packet may be lost, out of order

• Connectionless protocol:– No handshaking between sender and receiver

– Each UDP datagram handled independently

Page 8: Networking III: The Transport Layer and Internet names and addresses

8

UDP Functionality• Multiplexing/Demultiplexing

– Using ports

• Checksums (optional)– Check for corruption

applicationtransportnetwork

MP2

applicationtransportnetwork

receiver

HtHnsegment

segment Mapplicationtransportnetwork

P1M

M MP4

segmentheader

application-layerdata

P3

Page 9: Networking III: The Transport Layer and Internet names and addresses

9

Multiplexing/Demultiplexing

• Multiplexing: – Gather data from multiple processes, envelope data with header – Header has src port, dest port for multiplexing

• Why not process id?

• Demultiplexing:– Separate incoming data in machine to different applications– Demux based on sender addr, src and dest port

source port # dest port #

32 bits

Applicationdata

(message)

UDP segment format

length checksumLength, in

bytes of UDPsegment,including

header

Page 10: Networking III: The Transport Layer and Internet names and addresses

10

Implementing Ports• As a message queue

– Append incoming message to the end– Much like a mailbox file

• If queue full, message can be discarded• When application reads from socket

– OS removes some bytes from the head of the queue

• If queue empty, application blocks waiting

Page 11: Networking III: The Transport Layer and Internet names and addresses

11

UDP Checksum• Over the headers and data

– Ensures integrity end-to-end– 1’s complement sum of segment contents

• Is optional in UDP• If checksum is non-zero, and receiver computes another

value:– Silently drop the packet, no error message detected

Page 12: Networking III: The Transport Layer and Internet names and addresses

12

UDP Discussion• Why UDP?

– No delay in connection establishment

– Simple: no connection state

– Small header size

– No congestion control: can blast packets

• Uses:– Streaming media, DNS, SNMP– Could add application specific error recovery

Page 13: Networking III: The Transport Layer and Internet names and addresses

13

TCP• Transmission Control Protocol

– Reliable, in-order, process-to-process, two-way byte stream

• Different from UDP– Connection-oriented– Error recovery: Packet loss, duplication, corruption, reordering

• A number of applications require this guarantee– Web browsers use TCP

Page 14: Networking III: The Transport Layer and Internet names and addresses

14

Handling Packet Loss

sender receiver

time

message

There are a number of reasons why the packet may get lost:- router congestion, lossy medium, etc.

How does sender know of a successful packet send?

Page 15: Networking III: The Transport Layer and Internet names and addresses

15

Lost Acks

sender receiver

time

message

ack

What if packet/ack is lost?

timeout

Page 16: Networking III: The Transport Layer and Internet names and addresses

16

Delayed ACKs

sender receiver

time

message

ack

timeout

What will happen here? Due to congestion, small timeout, …Delayed ACKs duplicate packets

message

Page 17: Networking III: The Transport Layer and Internet names and addresses

17

Delayed ACKs

sender receiver

time

m1

ack

timeout

m1

timeout

m2

ack

How to solve this scenario?

Page 18: Networking III: The Transport Layer and Internet names and addresses

18

Insertion of Packets

sender receiver

time

m1

ack1

m2

ack2

m2’

m2’ could be from an old expired session!

Page 19: Networking III: The Transport Layer and Internet names and addresses

19

Message Identifiers• Each message has <message id, session id>

– Message id: uniquely identifies message in sender– Session id: unique across sessions

• Message ids detect duplication, reordering• Session ids detect packet from old sessions• TCP’s sequence number has similar functionality:

– Initial number chosen randomly– Unique across packets– Incremented by length of data bytes

Page 20: Networking III: The Transport Layer and Internet names and addresses

20

TCP Packets

source port # dest port #

32 bits

applicationdata

(variable length)

sequence number

acknowledgement numberrcvr window size

ptr urgent datachecksum

FSRPAUheadlen

notused

Options (variable length)

URG: urgent data (generally not used)

ACK: ACK #valid

PSH: push data now(generally not used)

RST, SYN, FIN:connection estab(setup, teardown

commands)

# bytes rcvr willingto accept

countingby bytes of data(not segments!)

Internetchecksum

(as in UDP)

Page 21: Networking III: The Transport Layer and Internet names and addresses

21

TCP Connection Establishment

sender receiver

(ack x, seq # y)

(open, seq # x)

(ack y)

TCP is connection-oriented. Starts with a 3-way handshake.Protects against duplicate SYN packets.

Page 22: Networking III: The Transport Layer and Internet names and addresses

22

TCP Usage

sender

receiver

(ack x, seq # y)

(open, seq # x)

(ack y)Data

Data, ACK

Fin, ACK

Fin, ACK

Page 23: Networking III: The Transport Layer and Internet names and addresses

23

TCP timeouts• What is a good timeout period ?

– Want to improve throughput without unnecessary transmissions

• Timeout is thus a function of RTT and deviation

NewAverageRTT = (1 - ) OldAverageRTT + LatestRTTNewAverageDev = (1 - ) OldAverageDev + LatestDevwhere LatestRTT = (ack_receive_time – send_time), LatestDev = |LatestRTT – AverageRTT|, = 1/8, typically.Timeout = AverageRTT + 4*AverageDev

Page 24: Networking III: The Transport Layer and Internet names and addresses

24

TCP Windows

• Multiple outstanding packets can increase throughput

Page 25: Networking III: The Transport Layer and Internet names and addresses

25

TCP Windows• Can have more than one packet in

transit• Especially over fat pipes, e.g.

satellite connection• Need to keep track of all packets

within the window• Need to adjust window size

DATA, id=17DATA, id=18DATA, id=19DATA, id=20

ACK 17

ACK 18

ACK 19

ACK 20

Page 26: Networking III: The Transport Layer and Internet names and addresses

26

TCP Windows and Sequence Numbers

• Sender has three regions: – Sequence regions

• sent and ack’ed• Sent and not ack’ed• not yet sent

– Window (colored region) adjusted by sender• Receiver has three regions:

– Sequence regions• received and ack’ed (given to application)• received and buffered• not yet received (or discarded because out of order)

Sequence Numbers

Sentnot acked

Sentacked

Not yetsent Sender

Not yetreceived

ReceivedGiven to app

ReceivedBuffered Receiver

Page 27: Networking III: The Transport Layer and Internet names and addresses

27

TCP Congestion Control• How does the sender’s window size get chosen?

– Must be less than receiver’s advertised buffer size– Try to match the rate of sending packets with the rate that the

slowest link can accommodate– Sender uses an adaptive algorithm to decide size of N– Goal: fill network between sender and receiver– Basic technique: slowly increase size of window until

acknowledgements start being delayed/lost

• TCP increases its window size when no packets dropped

• It halves the window size when a packet drop occurs– A packet drop is evident from the acknowledgements

• Therefore, it slowly builds to the max bandwidth, and hover around the max– It doesn’t achieve the max possible though

– Instead, it shares the bandwidth well with other TCP connections

• This linear-increase, exponential backoff in the face of congestion is termed TCP-friendliness

Page 28: Networking III: The Transport Layer and Internet names and addresses

28

TCP Window Size

• Linear increase• Exponential backoff

• Assuming no other losses in the network except those due to bandwidth

Time

Ban

dwid

th

Max Bandwidth

Page 29: Networking III: The Transport Layer and Internet names and addresses

29

TCP Fairness

• Want to share the bottleneck link fairly between two flows

Bandwidth for Host B

Ban

dwid

th f

or H

ost A

B

A

BottleneckLink

D

Page 30: Networking III: The Transport Layer and Internet names and addresses

30

TCP Slow Start• Linear increase takes a long time to build up a window size

that matches the link bandwidth*delay

• Most file transactions are not long enough

• Consequently, TCP can spend a lot of time with small windows, never getting the chance to reach a sufficiently large window size

• Fix: Allow TCP to build up to a large window size initially by doubling the window size until first loss

Page 31: Networking III: The Transport Layer and Internet names and addresses

31

TCP Slow Start

• Initial phase of exponential increase

• Assuming no other losses in the network except those due to bandwidth

Time

Ban

dwid

th

Max Bandwidth

Page 32: Networking III: The Transport Layer and Internet names and addresses

32

TCP Summary• Reliable ordered message delivery

– Connection oriented, 3-way handshake

• Transmission window for better throughput– Timeouts based on link parameters

• Congestion control– Linear increase, exponential backoff

• Fast adaptation– Exponential increase in the initial phase

Page 33: Networking III: The Transport Layer and Internet names and addresses

34

Internet: Names and Addresses

Page 34: Networking III: The Transport Layer and Internet names and addresses

35

Naming in the Internet

• What are named? All Internet Resources.– Objects: www.cs.cornell.edu/courses/cs414/2007sp

– Services: weather.yahoo.com/forecast

– Hosts: planetlab1.cs.cornell.edu

• Characteristics of Internet Names– human recognizable

– unique

– persistent

• Universal Resource Names (URNs)

Page 35: Networking III: The Transport Layer and Internet names and addresses

36

Locating the resources

• Internet services and resources are provided by end-hosts– ex. web2.cs.cornell.edu hosts cs414’s home page.

• Names are mapped to Locations– Universal Resource Locators (URL)

– Embedded in the name itself: ex. weather.yahoo.com/forecast

• Semantics of Internet naming human recognizable

uniqueness

x persistent

Page 36: Networking III: The Transport Layer and Internet names and addresses

37

Locating the Hosts?

• Internet Protocol Addresses (IP Addresses)– ex. planetlab1.cs.cornell.edu 128.84.154.49

• Characteristics of IP Addresses– 32 bit fixed-length

– enables network routers to efficiently handle packets in the Internet

• Locating services on hosts– port numbers (16 bit unsigned integer) 65536 ports

– standard ports: HTTP 80, FTP 20, SSH 22, Telnet 20

Page 37: Networking III: The Transport Layer and Internet names and addresses

38

Mapping Not 1 to 1• One host may map to more than one name

– One server machine may be the web server (www.foo.com), mail server (mail.foo.com)etc.

• One host may have more than one IP address– IP addresses are per network interface

• But IP addresses are generally unique!– two globally visible machines should not have the same IP address– Anycast is an Exception:

• routers send packets dynamically to the closest host matching an anycast address

Page 38: Networking III: The Transport Layer and Internet names and addresses

39

How to get a name?• Naming in Internet is Hierarchical

– decreases centralization– improves name space management

• First, get a domain name then you are free to assign sub names in that domain– How to get a domain name coming up

• Example: weather.yahoo.com belongs to yahoo.com which belongs to .com– regulated by global non-profit bodies

Page 39: Networking III: The Transport Layer and Internet names and addresses

40

Domain name structure

ccTLDs

root (unnamed)

com milgovedu grorgnet fr ukus ......

cornell ustreas second level (sub-)domainslucent

gTLDs

gTLDs= Generic Top Level Domains ccTLDs = Country Code Top Level Domains

Page 40: Networking III: The Transport Layer and Internet names and addresses

41

Top-level Domains (TLDs)• Generic Top Level Domains (gTLDs)

– .com - commercial organizations– .org - not-for-profit organizations– .edu - educational organizations– .mil - military organizations– .gov - governmental organizations– .net - network service providers– New: .biz, .info, .name, …

• Country code Top Level Domains (ccTLDs)– One for each country

Page 41: Networking III: The Transport Layer and Internet names and addresses

42

How to get a domain name?

• In 1998, non-profit corporation, Internet Corporation for Assigned Names and Numbers (ICANN), was formed to assume responsibility from the US Government

• ICANN authorizes other companies to register domains in com, org and net and new gTLDs– Network Solutions is largest– (In transitional period between US Govt and ICANN had sole

authority to register domains in com, org and net)

Page 42: Networking III: The Transport Layer and Internet names and addresses

43

How to get an IP Address?

• Answer 1: Normally, answer is get an IP address from your upstream provider– This is essential to maintain efficient routing!

• Answer 2: If you need lots of IP addresses then you can acquire your own block of them.– IP address space is a scarce resource - must prove you have fully

utilized a small block before can ask for a larger one and pay $$ (Jan 2002 - $2250/year for /20 and $18000/year for a /14)

Page 43: Networking III: The Transport Layer and Internet names and addresses

44

How to get lots of IP Addresses? Internet Registries

RIPE NCC (Riseaux IP Europiens Network Coordination Centre) for Europe, Middle-East, Africa

APNIC (Asia Pacific Network Information Centre )for Asia and Pacific

ARIN (American Registry for Internet Numbers) for the Americas, the Caribbean, sub-saharan Africa

Note: Once again regional distribution is important for efficient routing!

Can also get Autonomous System Numnbers (ASNs from these registries

Page 44: Networking III: The Transport Layer and Internet names and addresses

45

Are there enough addresses?• Unfortunately No!

– 32 bits 4 billion unique addresses– but addresses are assigned in chunks– ex. cornell has four chunks of /16 addressed

• ex. 128.84.0.0 to 128.84.255.255

• 128.253.0.0, 128.84.0.0, 132.236.0.0, and 140.251.0.0

• Expanding the address space!– IPv6 128 bit addresses– difficult to deploy (requires cooperation and changes to the core of

the Internet)

Page 45: Networking III: The Transport Layer and Internet names and addresses

46

DHCP and NATs• Dynamic Host Control Protocol

– lease IP addresses for short time intervals– hosts may refresh addresses periodically only live hosts need valid IP addresses

• Network Address Translators– Hide local IP addresses from rest of the world– only a small number of IP addresses are visible outside solves address shortage for all practical purposes access is highly restricted

• ex. peer-to-peer communication is difficult

Page 46: Networking III: The Transport Layer and Internet names and addresses

47

NATs in operation• Translate addresses when packets traverse through NATs• Use port numbers to increase number of supportable flows

Page 47: Networking III: The Transport Layer and Internet names and addresses

48

DNS: Domain Name SystemDomain Name System:• distributed database implemented in hierarchy of many

name servers• application-layer protocol host, routers, name servers

communicate to resolve names (address/name translation)– note: core Internet function implemented as application-layer

protocol– complexity at network’s “edge”

Page 48: Networking III: The Transport Layer and Internet names and addresses

49

DNS name servers

Name server: process running on a host that processes DNS requests

local name servers:– each ISP, company has local

(default) name server

– host DNS query first goes to local name server

authoritative name server:– can perform name/address

translation for a specific domain or zone

How could we provide this service? Why not centralize DNS?

• single point of failure• traffic volume• distant centralized database• maintenance

doesn’t scale!

• no server has all name-to-IP address mappings

Page 49: Networking III: The Transport Layer and Internet names and addresses

50

Name Server Zone Structure

root

Structure based onadministrative issues.

lucent

com miledugov grorgnet fr ukus

ustreas

www

irs Zone: subtree with commonadministration authority.

Page 50: Networking III: The Transport Layer and Internet names and addresses

51

Name Servers (NS)

root

cornelllucent

com ...edugov

ustreas

customs

www

irsIRS NS

Ustreas NSLucent NS

Root NS

Page 51: Networking III: The Transport Layer and Internet names and addresses

52

Name Servers (NS)

• NSs are duplicated for reliability.

• Each domain must have a primary and secondary.

• Anonymous ftp from:

ftp.rs.internic.net, netinfo/root-server.txt,

domain/named.cache

gives the current root NSs (about 10).

• Each host knows the IP address of the local NS.

• Each NS knows the IP addresses of all root NSs.

Page 52: Networking III: The Transport Layer and Internet names and addresses

53

DNS: Root name servers• contacted by local name

server that can not resolve name

• root name server:– Knows the authoritative

name server for main domain

• ~ 60 root name servers worldwide– real-world application of

anycast

Page 53: Networking III: The Transport Layer and Internet names and addresses

54

Simple DNS examplehost surf.eurecom.fr wants IP

address of www.cit.cornell.edu

1. Contacts its local DNS server, dns.eurecom.fr

2. dns.eurecom.fr contacts root name server, if necessary

3. root name server contacts authoritative name server, dns.cit.cornell.edu, if necessary (what might be wrong with this?)

requesting hostsurf.eurecom.fr

www.cs.cornell.edu

root name server

authorititive name serverdns.cornell.edu

local name serverdns.eurecom.fr

1

23

4

5

6

Page 54: Networking III: The Transport Layer and Internet names and addresses

55

DNS example

Root name server:• may not know

authoritative name server• may know intermediate

name server: who to contact to find authoritative name server

requesting hostsurf.eurecom.fr

www.cs.cornell.edu

root name server

local name serverdns.eurecom.fr

1

23

4

authoritative name serverpenguin.cs.cornell.edu

intermediate name server

dns.cit.cornell.edu

7

10

56

.edu name server

89

Page 55: Networking III: The Transport Layer and Internet names and addresses

56

DNS Architecture• Hierarchical Namespace Management

– domains and sub-domains– distributed and localized authority

• Authoritative Nameservers– server mappings for specific sub-domains– more than one (at least two for failure resilience)

• Caching to mitigate load on root servers– time-to-live (ttl) used to delete expired cached mappings

Page 56: Networking III: The Transport Layer and Internet names and addresses

57

DNS: query resolution

iterated query:• contacted server replies

with name of server to contact

• “I don’t know this name, but ask this server”

• Takes burden off root servers

recursive query:• puts burden of name

resolution on contacted name server

• reduces latency

requesting hostsurf.eurecom.fr

www.cs.cornell.edu

root name server

local name serverdns.eurecom.fr

1

23

4

8 7

authoritative name serverpenguin.cs.cornell.edu

intermediate name serverdns.cit.cornell.edu

9

10

iterated query

56

.edu name server

recursive query

Page 57: Networking III: The Transport Layer and Internet names and addresses

58

DNS records: More than Name to IP Address

DNS: distributed db storing resource records (RR)

• Type=NS– name is domain (e.g. foo.com)– value is IP address of

authoritative name server for this domain

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

• Type=A– name is hostname– value is IP address– One we’ve been discussing;

most common

• Type=CNAME– name is an alias name for

some “cannonical” (the real) name

– value is cannonical name

• Type=MX– value is hostname of mailserver

associated with name

Page 58: Networking III: The Transport Layer and Internet names and addresses

59

nslookup• Use to query DNS servers (not telnet like with http – why?)• Examples:

– nslookup www.yahoo.com– nslookup www.yahoo.com dns.cit.cornell.edu

• specify which local nameserver to use

– nslookup –type=mx cs.cornell.edu• specify record type

Page 59: Networking III: The Transport Layer and Internet names and addresses

60

PTR Records• Pointer (PTR) record maps IP address to conanical name

– Does reverse mapping from IP address to name (reverse DNS lookup)

• Why is that hard? • Which name server is responsible for that mapping? • How do you find them?

• Answer: special root domain, arpa, for reverse lookups

Page 60: Networking III: The Transport Layer and Internet names and addresses

61

Arpa top level domain

root

com miledugov grorgnet fr ukusarpa

In-addr

128

30 33 1

ietf

www

1.33.30.128.in-addr.arpa.

www.ietf.org.

Want to know machine name for 128.30.33.1?Issue a PTR request for 1.33.30.128.in-addr.arpa

Page 61: Networking III: The Transport Layer and Internet names and addresses

62

Why is it backwards?• Notice that 1.30.33.128.in-addr.arpa is written in order of

increasing scope of authority just like www.cs.foo.edu• Edu largest scope of authority; foo.edu less, down to single

machine www.cs.foo.edu• Arpa largest scope of authority; in-addr.arpa less, down to

single machine 1.30.33.128.in-addr.arpa (or 128.33.30.1)

Page 62: Networking III: The Transport Layer and Internet names and addresses

63

In-addr.arpa domain• When an organization acquires a domain name, they

receive authority over the corresponding part of the domain name space.

• When an organization acquires a block of IP address space, they receive authority over the corresponding part of the in-addr.arpa space.

• Example: Acquire domain virginia.edu and acquire a class B IP Network ID 128.143

Page 63: Networking III: The Transport Layer and Internet names and addresses

64

DNS protocol, messages

DNS protocol : query and repy messages, both with same message format

msg header• identification: 16 bit # for query,

repy to query uses same #• flags:

– query or reply– recursion desired – recursion available– reply is authoritative– reply was truncated

Page 64: Networking III: The Transport Layer and Internet names and addresses

65

DNS protocol, messages

Name, type fields for a query

RRs in reponseto query

records forauthoritative servers

additional “helpful”info that may be used

Page 65: Networking III: The Transport Layer and Internet names and addresses

66

Summary• Hierarchical Namespace Management

– domains and sub-domains– distributed and localized authority

• Authoritative Nameservers– server mappings for specific sub-domains– more than one (at least two for failure resilience)

• Caching to mitigate load on root servers– time-to-live (ttl) used to delete expired cached mappings