79
Network Protocol Network Protocol

Network Protocol. 2 Application layer protocol Transport layer protocol Network layer protocol Link layer protocol

Embed Size (px)

Citation preview

Page 1: Network Protocol. 2 Application layer protocol Transport layer protocol Network layer protocol Link layer protocol

Network ProtocolNetwork Protocol

Page 2: Network Protocol. 2 Application layer protocol Transport layer protocol Network layer protocol Link layer protocol

2

Network ProtocolNetwork Protocol• Application layer protocol• Transport layer protocol• Network layer protocol• Link layer protocol

Page 3: Network Protocol. 2 Application layer protocol Transport layer protocol Network layer protocol Link layer protocol

3

Application LayerApplication Layer

• conceptual, implementation aspects of network application protocols– transport-layer

service models– client-server

paradigm– peer-to-peer

paradigm

• learn about protocols by examining popular application-level protocols– HTTP– FTP– SMTP / POP3 /

IMAP– DNS

Page 4: Network Protocol. 2 Application layer protocol Transport layer protocol Network layer protocol Link layer protocol

4

Application architecturesApplication architectures• Client-server• Peer-to-peer (P2P)• Hybrid of client-server and P2P

Page 5: Network Protocol. 2 Application layer protocol Transport layer protocol Network layer protocol Link layer protocol

5

Client-server archictureClient-server archictureserver:

– always-on host– permanent IP address– server farms for scaling

clients:– communicate with

server– may be intermittently

connected– may have dynamic IP

addresses– do not communicate

directly with each other

Page 6: Network Protocol. 2 Application layer protocol Transport layer protocol Network layer protocol Link layer protocol

6

Pure P2P architecturePure P2P architecture• no always on server• arbitrary end systems

directly communicate• peers are intermittently

connected and change IP addresses

• example: Gnutella

Highly scalable

But difficult to manage

Page 7: Network Protocol. 2 Application layer protocol Transport layer protocol Network layer protocol Link layer protocol

7

Processes communicatingProcesses communicatingProcess: program

running within a host.• within same host, two

processes communicate using inter-process communication (defined by OS).

• processes in different hosts communicate by exchanging messages

Client process: process that initiates communication

Server process: process that waits to be contacted

• Note: applications with P2P architectures have client processes & server processes

Page 8: Network Protocol. 2 Application layer protocol Transport layer protocol Network layer protocol Link layer protocol

8

SocketsSockets

• process sends/receives messages to/from its socket

• socket analogous to door– sending process shoves

message out door– sending process relies on

transport infrastructure on other side of door which brings message to socket at receiving process

process

TCP withbuffers,variables

socket

host orserver

process

TCP withbuffers,variables

socket

host orserver

Internet

controlledby OS

controlled byapp developer

Page 9: Network Protocol. 2 Application layer protocol Transport layer protocol Network layer protocol Link layer protocol

9

Addressing processesAddressing processes

• For a process to receive messages, it must have an identifier

• A host has a unique32-bit IP address

• Q: does the IP address of the host on which the process runs suffice for identifying the process?

• Answer: No, many processes can be running on same host

• Identifier includes both the IP address and port numbers associated with the process on the host.

• Example port numbers:– HTTP server: 80– Mail server: 25

Page 10: Network Protocol. 2 Application layer protocol Transport layer protocol Network layer protocol Link layer protocol

10

App-layer protocol definesApp-layer protocol defines• Types of messages exchanged, eg, request &

response messages• Syntax of message types: what fields in

messages & how fields are delineated• Semantics of the fields, ie, meaning of

information in fields• Rules for when and how processes send &

respond to messages

Page 11: Network Protocol. 2 Application layer protocol Transport layer protocol Network layer protocol Link layer protocol

11

Internet transport protocols Internet transport protocols servicesservices

TCP service:• connection-oriented: setup

required between client and server processes

• reliable transport between sending and receiving process

• flow control: sender won’t overwhelm receiver

• congestion control: throttle sender when network overloaded

• does not provide: timing, minimum bandwidth guarantees

UDP service:• unreliable data transfer

between sending and receiving process

• does not provide: connection setup, reliability, flow control, congestion control, timing, or bandwidth guarantee

Q: why bother? Why is there a UDP?

Page 12: Network Protocol. 2 Application layer protocol Transport layer protocol Network layer protocol Link layer protocol

12

Web and HTTPWeb and HTTPFirst some jargon• Web page consists of objects• Object can be HTML file, JPEG image, Java applet,

audio file,…• Web page consists of base HTML-file which

includes several referenced objects• Each object is addressable by a URL• Example URL:

www.someschool.edu/someDept/pic.gif

host name path name

Page 13: Network Protocol. 2 Application layer protocol Transport layer protocol Network layer protocol Link layer protocol

13

HTTP overviewHTTP overviewHTTP: 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 14: Network Protocol. 2 Application layer protocol Transport layer protocol Network layer protocol Link layer protocol

14

HTTP request messageHTTP 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.edu User-agent: Mozilla/4.0Connection: close Accept-language:fr

(extra carriage return, line feed)

request line(GET, POST,

HEAD commands)

header lines

Carriage return, line feed

indicates end of message

Page 15: Network Protocol. 2 Application layer protocol Transport layer protocol Network layer protocol Link layer protocol

15

HTTP request message: general HTTP request message: general formatformat

Page 16: Network Protocol. 2 Application layer protocol Transport layer protocol Network layer protocol Link layer protocol

16

HTTP response messageHTTP 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)

header lines

data, e.g., requestedHTML file

Page 17: Network Protocol. 2 Application layer protocol Transport layer protocol Network layer protocol Link layer protocol

17

FTP: the file transfer protocolFTP: the file transfer protocol

• transfer file to/from remote host• client/server model

– client: side that initiates transfer (either to/from remote)

– server: remote host• ftp: RFC 959• ftp server: port 21

file transfer FTPserver

FTPuser

interface

FTPclient

local filesystem

remote filesystem

user at host

Page 18: Network Protocol. 2 Application layer protocol Transport layer protocol Network layer protocol Link layer protocol

18

FTP: separate control, data FTP: separate control, data connectionsconnections

• FTP client contacts FTP server at port 21, specifying TCP as transport protocol

• Client obtains authorization over control connection

• Client browses remote directory by sending commands over control connection.

• When server receives a command for a file transfer, the server opens a TCP data connection to client

• After transferring one file, server closes connection.

FTPclient

FTPserver

TCP control connection

port 21

TCP data connectionport 20

• Server opens a second TCP data connection to transfer another file.

• Control connection: “out of band”

• FTP server maintains “state”: current directory, earlier authentication

Page 19: Network Protocol. 2 Application layer protocol Transport layer protocol Network layer protocol Link layer protocol

19

Electronic MailElectronic MailThree major components: • user agents • mail servers • simple mail transfer protocol:

SMTP

User Agent• a.k.a. “mail reader”• composing, editing, reading

mail messages• e.g., Eudora, Outlook, elm,

Netscape Messenger• outgoing, incoming

messages stored on server

user mailbox

outgoing message queue

mailserver

useragent

useragent

useragent

mailserver

useragent

useragent

mailserver

useragent

SMTP

SMTP

SMTP

Page 20: Network Protocol. 2 Application layer protocol Transport layer protocol Network layer protocol Link layer protocol

20

Electronic Mail: mail serversElectronic Mail: mail serversMail Servers • mailbox contains incoming

messages for user• message queue of outgoing

(to be sent) mail messages• SMTP protocol between mail

servers to send email messages– client: sending mail

server– “server”: receiving mail

server

mailserver

useragent

useragent

useragent

mailserver

useragent

useragent

mailserver

useragent

SMTP

SMTP

SMTP

Page 21: Network Protocol. 2 Application layer protocol Transport layer protocol Network layer protocol Link layer protocol

21

Electronic Mail: SMTP Electronic Mail: SMTP [RFC [RFC 2821]2821]

• uses TCP to reliably transfer email message from client to server, port 25

• direct transfer: sending server to receiving server

• three phases of transfer– handshaking (greeting)– transfer of messages– closure

Page 22: Network Protocol. 2 Application layer protocol Transport layer protocol Network layer protocol Link layer protocol

22

Scenario: Alice sends Scenario: Alice sends message to Bobmessage to Bob

1) Alice uses UA to compose message and “to” [email protected]

2) Alice’s UA sends message to her mail server; message placed in message queue

3) Client side of SMTP opens TCP connection with Bob’s mail server

4) SMTP client sends Alice’s message over the TCP connection

5) Bob’s mail server places the message in Bob’s mailbox

6) Bob invokes his user agent to read message

useragent

mailserver

mailserver user

agent

1

2 3 4 56

Page 23: Network Protocol. 2 Application layer protocol Transport layer protocol Network layer protocol Link layer protocol

23

Mail message formatMail message formatSMTP: protocol for

exchanging email msgsRFC 822: standard for text

message format:• header lines, e.g.,

– To:– From:– Subject:

• body– the “message”, ASCII

characters only

header

body

blankline

Page 24: Network Protocol. 2 Application layer protocol Transport layer protocol Network layer protocol Link layer protocol

24

Message format: multimedia Message format: multimedia extensionsextensions

• MIME: multimedia mail extension, RFC 2045, 2056

• additional lines in msg header declare MIME content type

From: [email protected] To: [email protected] Subject: Picture of yummy crepe. MIME-Version: 1.0 Content-Transfer-Encoding: base64 Content-Type: image/jpeg

base64 encoded data ..... ......................... ......base64 encoded data

multimedia datatype, subtype,

parameter declaration

method usedto encode data

MIME version

encoded data

Page 25: Network Protocol. 2 Application layer protocol Transport layer protocol Network layer protocol Link layer protocol

25

Mail access protocolsMail access protocols

• SMTP: delivery/storage to receiver’s server• Mail access protocol: retrieval from server

– POP: Post Office Protocol [RFC 1939]• authorization (agent <-->server) and download

– IMAP: Internet Mail Access Protocol [RFC 1730]• more features (more complex)• manipulation of stored msgs on server

– HTTP: Hotmail , Yahoo! Mail, etc.

useragent

sender’s mail server

useragent

SMTP SMTP accessprotocol

receiver’s mail server

Page 26: Network Protocol. 2 Application layer protocol Transport layer protocol Network layer protocol Link layer protocol

26

DNS: Domain Name SystemDNS: Domain Name System

People: many identifiers:– SSN, name, passport

#Internet hosts, routers:

– IP address (32 bit) - used for addressing datagrams

– “name”, e.g., ww.yahoo.com - used by humans

Q: 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

Page 27: Network Protocol. 2 Application layer protocol Transport layer protocol Network layer protocol Link layer protocol

27

DNS 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 28: Network Protocol. 2 Application layer protocol Transport layer protocol Network layer protocol Link layer protocol

28

Root DNS Servers

com DNS servers org DNS servers edu DNS servers

poly.eduDNS servers

umass.eduDNS servers

yahoo.comDNS servers

amazon.comDNS servers

pbs.orgDNS servers

Distributed, Hierarchical DatabaseDistributed, Hierarchical Database

Client wants IP for www.amazon.com; 1st approx:• Client queries a root server to find com DNS

server• Client queries com DNS server to get

amazon.com DNS server• Client queries amazon.com DNS server to get

IP address for www.amazon.com

Page 29: Network Protocol. 2 Application layer protocol Transport layer protocol Network layer protocol Link layer protocol

29

Internet transport-layer Internet transport-layer protocolsprotocols

Page 30: Network Protocol. 2 Application layer protocol Transport layer protocol Network layer protocol Link layer protocol

30

Transport services and Transport services and protocolsprotocols

• provide logical communication between app processes running on different hosts

• transport protocols run in end systems – send side: breaks app

messages into segments, passes to network layer

– rcv side: reassembles segments into messages, passes to app layer

• more than one transport protocol available to apps– Internet: TCP and UDP

application

transportnetworkdata linkphysical

application

transportnetworkdata linkphysical

networkdata linkphysical

networkdata linkphysical

networkdata linkphysical

networkdata linkphysicalnetwork

data linkphysical

logical end-end transport

Page 31: Network Protocol. 2 Application layer protocol Transport layer protocol Network layer protocol Link layer protocol

31

Transport vs. network layerTransport vs. network layer• network layer: logical communication

between hosts• transport layer: logical communication

between processes – relies on, enhances, network layer

services

Page 32: Network Protocol. 2 Application layer protocol Transport layer protocol Network layer protocol Link layer protocol

32

Internet transport-layer protocolsInternet transport-layer protocols

• reliable, in-order delivery (TCP)– congestion control – flow control– connection setup

• unreliable, unordered delivery: UDP– no-frills extension of

“best-effort” IP• services not available:

– delay guarantees– bandwidth guarantees

application

transportnetworkdata linkphysical

application

transportnetworkdata linkphysical

networkdata linkphysical

networkdata linkphysical

networkdata linkphysical

networkdata linkphysicalnetwork

data linkphysical

logical end-end transport

Page 33: Network Protocol. 2 Application layer protocol Transport layer protocol Network layer protocol Link layer protocol

33

Multiplexing/demultiplexingMultiplexing/demultiplexing

application

transport

network

link

physical

P1 application

transport

network

link

physical

application

transport

network

link

physical

P2P3 P4P1

host 1 host 2 host 3

= process= socket

delivering received segmentsto correct socket

Demultiplexing at rcv host:gathering data from multiplesockets, enveloping data with header (later used for demultiplexing)

Multiplexing at send host:

Page 34: Network Protocol. 2 Application layer protocol Transport layer protocol Network layer protocol Link layer protocol

34

How demultiplexing worksHow demultiplexing works

• host receives IP datagrams– each datagram has source IP

address, destination IP address– each datagram carries 1

transport-layer segment– each segment has source,

destination port number host uses IP addresses & port numbers to direct segment to appropriate socket

source port # dest port #

32 bits

applicationdata

(message)

other header fields

TCP/UDP segment format

Page 35: Network Protocol. 2 Application layer protocol Transport layer protocol Network layer protocol Link layer protocol

35

Connectionless demultiplexingConnectionless demultiplexing• Create sockets with port

numbers:

DatagramSocket mySocket1 = new DatagramSocket(99111);

DatagramSocket mySocket2 = new DatagramSocket(99222);

• UDP socket identified by two-tuple:

(dest IP address, dest port number)

• When host receives UDP segment:– checks destination port

number in segment– directs UDP segment to

socket with that port number

• IP datagrams with different source IP addresses and/or source port numbers directed to same socket

Page 36: Network Protocol. 2 Application layer protocol Transport layer protocol Network layer protocol Link layer protocol

36

Connectionless demux Connectionless demux (cont)(cont)

DatagramSocket serverSocket = new DatagramSocket(6428);

ClientIP:B

P2

client IP: A

P1P1P3

serverIP: C

SP: 6428

DP: 9157

SP: 9157

DP: 6428

SP: 6428

DP: 5775

SP: 5775

DP: 6428

SP provides “return address”

Page 37: Network Protocol. 2 Application layer protocol Transport layer protocol Network layer protocol Link layer protocol

37

UDP: User Datagram Protocol [RFC UDP: User Datagram Protocol [RFC 768]768]

• “best effort” service, UDP segments may be:– lost– delivered out of order

to app• connectionless:

– no handshaking between UDP sender, receiver

– each UDP segment handled independently of others

Why is there a UDP?• no connection

establishment (which can add delay)

• simple: no connection state at sender, receiver

• small segment header• no congestion control: UDP

can blast away as fast as desired

Page 38: Network Protocol. 2 Application layer protocol Transport layer protocol Network layer protocol Link layer protocol

38

UDP: moreUDP: more

• often used for streaming multimedia apps– loss tolerant– rate sensitive

• reliable transfer over UDP: add reliability at application layer– application-

specific error recovery!

source port # dest port #

32 bits

Applicationdata

(message)

UDP segment format

length checksumLength, in

bytes of UDPsegment,including

header

Page 39: Network Protocol. 2 Application layer protocol Transport layer protocol Network layer protocol Link layer protocol

39

UDP checksumUDP checksum

Sender:• treat segment contents

as sequence of 16-bit integers

• checksum: addition (1’s complement sum) of segment contents

• sender puts checksum value into UDP checksum field

Receiver:• compute checksum of

received segment• check if computed checksum

equals checksum field value:– NO - error detected– YES - no error detected.

But maybe errors nonetheless? More later ….

Goal: detect “errors” (e.g., flipped bits) in transmitted segment

Page 40: Network Protocol. 2 Application layer protocol Transport layer protocol Network layer protocol Link layer protocol

40

Internet Checksum ExampleInternet Checksum Example

• Note– When adding numbers, a carryout from the most

significant bit needs to be added to the result

• Example: add two 16-bit integers

1 1 1 1 0 0 1 1 0 0 1 1 0 0 1 1 01 1 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1

1 1 0 1 1 1 0 1 1 1 0 1 1 1 0 1 1

1 1 0 1 1 1 0 1 1 1 0 1 1 1 1 0 01 0 1 0 0 0 1 0 0 0 1 0 0 0 0 1 1

wraparound

sumchecksum

Page 41: Network Protocol. 2 Application layer protocol Transport layer protocol Network layer protocol Link layer protocol

41

The Internet Network layerThe Internet Network layer

Page 42: Network Protocol. 2 Application layer protocol Transport layer protocol Network layer protocol Link layer protocol

42

The Internet Network layerThe Internet Network layer

forwardingtable

Host, router network layer functions:

Routing protocols•path selection•RIP, OSPF, BGP

IP protocol•addressing conventions•datagram format•packet handling conventions

ICMP protocol•error reporting•router “signaling”

Transport layer: TCP, UDP

Link layer

physical layer

Networklayer

Page 43: Network Protocol. 2 Application layer protocol Transport layer protocol Network layer protocol Link layer protocol

43

IP datagram formatIP datagram format

ver length

32 bits

data (variable length,typically a TCP

or UDP segment)

16-bit identifier

Internet checksum

time tolive

32 bit source IP address

IP protocol versionnumber

header length (bytes)

max numberremaining hops

(decremented at each router)

forfragmentation/reassembly

total datagramlength (bytes)

upper layer protocolto deliver payload to

head.len

type ofservice

“type” of data flgsfragment

offsetupper layer

32 bit destination IP address

Options (if any) E.g. timestamp,record routetaken, specifylist of routers to visit.

Page 44: Network Protocol. 2 Application layer protocol Transport layer protocol Network layer protocol Link layer protocol

44

NAT: Network Address NAT: Network Address TranslationTranslation

10.0.0.1

10.0.0.2

10.0.0.3

10.0.0.4

138.76.29.7

local network(e.g., home network)

10.0.0/24

rest ofInternet

Datagrams with source or destination in this networkhave 10.0.0/24 address for

source, destination (as usual)

All datagrams leaving localnetwork have same single source

NAT IP address: 138.76.29.7,different source port numbers

Page 45: Network Protocol. 2 Application layer protocol Transport layer protocol Network layer protocol Link layer protocol

45

NAT: Network Address NAT: Network Address TranslationTranslation

• Motivation: local network uses just one IP address as far as outside word is concerned:– no need to be allocated range of addresses from

ISP: - just one IP address is used for all devices– can change addresses of devices in local network

without notifying outside world– can change ISP without changing addresses of

devices in local network– devices inside local net not explicitly

addressable, visible by outside world (a security plus).

Page 46: Network Protocol. 2 Application layer protocol Transport layer protocol Network layer protocol Link layer protocol

46

NAT: Network Address NAT: Network Address TranslationTranslation

Implementation: NAT router must:

– outgoing datagrams: replace (source IP address, port #) of every outgoing datagram to (NAT IP address, new port #)

. . . remote clients/servers will respond using (NAT IP address, new port #) as destination addr.

– remember (in NAT translation table) every (source IP address, port #) to (NAT IP address, new port #) translation pair

– incoming datagrams: replace (NAT IP address, new port #) in dest fields of every incoming datagram with corresponding (source IP address, port #) stored in NAT table

Page 47: Network Protocol. 2 Application layer protocol Transport layer protocol Network layer protocol Link layer protocol

47

NAT: Network Address TranslationNAT: Network Address Translation

10.0.0.1

10.0.0.2

10.0.0.3

S: 10.0.0.1, 3345D: 128.119.40.186, 80

1

10.0.0.4

138.76.29.7

1: host 10.0.0.1 sends datagram to 128.119.40, 80

NAT translation tableWAN side addr LAN side addr

138.76.29.7, 5001 10.0.0.1, 3345…… ……

S: 128.119.40.186, 80 D: 10.0.0.1, 3345

4

S: 138.76.29.7, 5001D: 128.119.40.186, 80

2

2: NAT routerchanges datagramsource addr from10.0.0.1, 3345 to138.76.29.7, 5001,updates table

S: 128.119.40.186, 80 D: 138.76.29.7, 5001

3

3: Reply arrives dest. address: 138.76.29.7, 5001

4: NAT routerchanges datagramdest addr from138.76.29.7, 5001 to 10.0.0.1, 3345

Page 48: Network Protocol. 2 Application layer protocol Transport layer protocol Network layer protocol Link layer protocol

48

ICMP: Internet Control Message ICMP: Internet Control Message ProtocolProtocol

• used by hosts & routers to communicate network-level information– error reporting:

unreachable host, network, port, protocol

– echo request/reply (used by ping)

• network-layer “above” IP:– ICMP msgs carried in IP

datagrams• ICMP message: type, code

plus first 8 bytes of IP datagram causing error

Type Code description0 0 echo reply (ping)3 0 dest. network unreachable3 1 dest host unreachable3 2 dest protocol unreachable3 3 dest port unreachable3 6 dest network unknown3 7 dest host unknown4 0 source quench (congestion control - not used)8 0 echo request (ping)9 0 route advertisement10 0 router discovery11 0 TTL expired12 0 bad IP header

Page 49: Network Protocol. 2 Application layer protocol Transport layer protocol Network layer protocol Link layer protocol

49

IPv6IPv6• Initial motivation: 32-bit address

space soon to be completely allocated.

• Additional motivation:– header format helps speed

processing/forwarding– header changes to facilitate QoS IPv6 datagram format: – fixed-length 40 byte header– no fragmentation allowed

Page 50: Network Protocol. 2 Application layer protocol Transport layer protocol Network layer protocol Link layer protocol

50

IPv6 Header (Cont)IPv6 Header (Cont)Priority: identify priority among datagrams in flowNext header: identify upper layer protocol for data

Page 51: Network Protocol. 2 Application layer protocol Transport layer protocol Network layer protocol Link layer protocol

51

Other Changes from IPv4Other Changes from IPv4• Checksum: removed entirely to

reduce processing time at each hop• Options: allowed, but outside of

header, indicated by “Next Header” field

• ICMPv6: new version of ICMP– additional message types, e.g. “Packet

Too Big”– multicast group management functions

Page 52: Network Protocol. 2 Application layer protocol Transport layer protocol Network layer protocol Link layer protocol

52

Transition From IPv4 Transition From IPv4 To IPv6To IPv6

• Not all routers can be upgraded simultaneous– no “flag days”– How will the network operate with mixed

IPv4 and IPv6 routers?

• Tunneling: IPv6 carried as payload in IPv4 datagram among IPv4 routers

Page 53: Network Protocol. 2 Application layer protocol Transport layer protocol Network layer protocol Link layer protocol

53

TunnelingTunneling

B-to-C:IPv6 inside

IPv4

D-to-E:IPv6 inside

IPv4

A B E F

IPv6 IPv6 IPv6 IPv6

tunnelLogical view:

Physical view:A B E F

IPv6 IPv6 IPv6 IPv6

C D

IPv4 IPv4

Flow: XSrc: ADest: F

data

Flow: XSrc: ADest: F

data

Flow: XSrc: ADest: F

data

Src:BDest: E

Flow: XSrc: ADest: F

data

Src:BDest: E

A-to-B:IPv6

E-to-F:IPv6

Page 54: Network Protocol. 2 Application layer protocol Transport layer protocol Network layer protocol Link layer protocol

54

Link Layer ProtocolLink Layer Protocol

Page 55: Network Protocol. 2 Application layer protocol Transport layer protocol Network layer protocol Link layer protocol

55

Multiple Access Links and Multiple Access Links and ProtocolsProtocols

Two types of “links”:• point-to-point

– PPP for dial-up access– point-to-point link between Ethernet switch and

host• broadcast (shared wire or medium)

– traditional Ethernet– 802.11 wireless LAN

Page 56: Network Protocol. 2 Application layer protocol Transport layer protocol Network layer protocol Link layer protocol

56

Multiple Access protocolsMultiple Access protocols

• single shared broadcast channel • two or more simultaneous transmissions by nodes:

interference – collision if node receives two or more signals at

the same timemultiple access protocol• 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

Page 57: Network Protocol. 2 Application layer protocol Transport layer protocol Network layer protocol Link layer protocol

57

Ideal Multiple Access ProtocolIdeal Multiple Access Protocol

Broadcast channel of rate R bps1. 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/M3. Fully decentralized:

– no special node to coordinate transmissions– no synchronization of clocks, slots

4. Simple

Page 58: Network Protocol. 2 Application layer protocol Transport layer protocol Network layer protocol Link layer protocol

58

MAC Protocols: a MAC Protocols: a taxonomytaxonomy

Three broad classes:• Channel Partitioning

– divide channel into smaller “pieces” (time slots, frequency, code)

– allocate piece to node for exclusive use

• Random Access– channel not divided, allow collisions– “recover” from collisions

• “Taking turns”– Nodes take turns, but nodes with more to

send can take longer turns

Page 59: Network Protocol. 2 Application layer protocol Transport layer protocol Network layer protocol Link layer protocol

59

Channel Partitioning Channel Partitioning MAC protocols: TDMAMAC protocols: TDMA

TDMA: time division multiple access • access to channel in "rounds" • each station gets fixed length slot (length = pkt trans time) in each round • unused slots go idle • example: 6-station LAN, 1,3,4 have pkt, slots 2,5,6 idle

• TDM (Time Division Multiplexing): channel divided into N time slots, one per user; inefficient with low duty cycle users and at light load.

• FDM (Frequency Division Multiplexing): frequency subdivided.

Page 60: Network Protocol. 2 Application layer protocol Transport layer protocol Network layer protocol Link layer protocol

60

Channel Partitioning MAC Channel Partitioning MAC protocols: FDMAprotocols: FDMA

FDMA: frequency division multiple access • channel spectrum divided into frequency bands• each station assigned fixed frequency band• unused transmission time in frequency bands go idle • example: 6-station LAN, 1,3,4 have pkt, frequency bands

2,5,6 idle • FDM (Frequency Division Multiplexing): frequency

subdivided.

frequ

ency

bands time

Page 61: Network Protocol. 2 Application layer protocol Transport layer protocol Network layer protocol Link layer protocol

61

Random Access ProtocolsRandom Access Protocols

• When node has packet to send– transmit at full channel data rate R.– no a priori coordination among nodes

• two or more transmitting nodes ➜ “collision”,• random access MAC protocol specifies:

– how to detect collisions– how to recover from collisions (e.g., via delayed

retransmissions)• Examples of random access MAC protocols:

– slotted ALOHA– ALOHA– CSMA, CSMA/CD, CSMA/CA

Page 62: Network Protocol. 2 Application layer protocol Transport layer protocol Network layer protocol Link layer protocol

62

Slotted ALOHASlotted ALOHAAssumptions• all frames same size• time is divided into

equal size slots, time to transmit 1 frame

• nodes start to transmit frames only at beginning of slots

• nodes are synchronized• if 2 or more nodes

transmit in slot, all nodes detect collision

Operation• when node obtains fresh

frame, it transmits in next slot

• no collision, node can send new frame in next slot

• if collision, node retransmits frame in each subsequent slot with prob. p until success

Page 63: Network Protocol. 2 Application layer protocol Transport layer protocol Network layer protocol Link layer protocol

63

Slotted ALOHASlotted ALOHA

Pros• single active node can

continuously transmit at full rate of channel

• highly decentralized: only slots in nodes need to be in sync

• simple

Cons• collisions, wasting

slots• idle slots• nodes may be able to

detect collision in less than time to transmit packet

• clock synchronization

Page 64: Network Protocol. 2 Application layer protocol Transport layer protocol Network layer protocol Link layer protocol

64

Slotted Aloha efficiencySlotted Aloha efficiency

• Suppose N nodes with many frames to send, each transmits in slot with probability p

• prob that node 1 has success in a slot = p(1-p)N-1

• prob that any node has a success = Np(1-p)N-1

• For max efficiency with N nodes, find p* that maximizes Np(1-p)N-1

• For many nodes, take limit of Np*(1-p*)N-1 as N goes to infinity, gives 1/e = .37

Efficiency is the long-run fraction of successful slots when there are many nodes, each with many frames to send

At best: channelused for useful transmissions 37%of time!

Page 65: Network Protocol. 2 Application layer protocol Transport layer protocol Network layer protocol Link layer protocol

65

Pure (unslotted) ALOHAPure (unslotted) ALOHA

• unslotted Aloha: simpler, no synchronization• when frame first arrives

– transmit immediately • collision probability increases:

– frame sent at t0 collides with other frames sent in [t0-1,t0+1]

Page 66: Network Protocol. 2 Application layer protocol Transport layer protocol Network layer protocol Link layer protocol

66

CSMA (Carrier Sense CSMA (Carrier Sense Multiple Access)Multiple Access)

CSMA: listen before transmit:If channel sensed idle: transmit entire frame• If channel sensed busy, defer transmission

• Human analogy: don’t interrupt others!

Page 67: Network Protocol. 2 Application layer protocol Transport layer protocol Network layer protocol Link layer protocol

67

CSMA collisionsCSMA collisions

collisions can still occur:propagation delay means two nodes may not heareach other’s transmissioncollision:entire packet transmission time wasted

spatial layout of nodes

note:role of distance & propagation delay in determining collision probability

Page 68: Network Protocol. 2 Application layer protocol Transport layer protocol Network layer protocol Link layer protocol

68

CSMA/CD (Collision CSMA/CD (Collision Detection)Detection)

CSMA/CD: carrier sensing, deferral as in CSMA– collisions detected within short time– colliding transmissions aborted, reducing

channel wastage • collision detection:

– easy in wired LANs: measure signal strengths, compare transmitted, received signals

– difficult in wireless LANs: receiver shut off while transmitting

• human analogy: the polite conversationalist

Page 69: Network Protocol. 2 Application layer protocol Transport layer protocol Network layer protocol Link layer protocol

69

CSMA/CD collision detectionCSMA/CD collision detection

Page 70: Network Protocol. 2 Application layer protocol Transport layer protocol Network layer protocol Link layer protocol

70

““Taking Turns” MAC Taking Turns” MAC protocolsprotocols

channel partitioning MAC protocols:– share channel efficiently and fairly at high load– inefficient at low load: delay in channel access,

1/N bandwidth allocated even if only 1 active node!

Random access MAC protocols– efficient at low load: single node can fully utilize

channel– high load: collision overhead

“taking turns” protocolslook for best of both worlds!

Page 71: Network Protocol. 2 Application layer protocol Transport layer protocol Network layer protocol Link layer protocol

71

““Taking Turns” MAC Taking Turns” MAC protocolsprotocols

Polling: • master node “invites”

slave nodes to transmit in turn

• concerns:– polling overhead – latency– single point of

failure (master)

Token passing:• control token passed from one

node to next sequentially.• token message• concerns:

– token overhead – latency– single point of failure

(token)

Page 72: Network Protocol. 2 Application layer protocol Transport layer protocol Network layer protocol Link layer protocol

72

Summary of MAC protocolsSummary of MAC protocols• What do you do with a shared media?

– Channel Partitioning, by time, frequency or code• Time Division, Frequency Division

– Random partitioning (dynamic), • ALOHA, S-ALOHA, CSMA, CSMA/CD• carrier sensing: easy in some technologies (wire),

hard in others (wireless)• CSMA/CD used in Ethernet• CSMA/CA used in 802.11

– Taking Turns• polling from a central site, token passing

Page 73: Network Protocol. 2 Application layer protocol Transport layer protocol Network layer protocol Link layer protocol

73

MAC Addresses and ARPMAC Addresses and ARP• 32-bit IP address:

– network-layer address– used to get datagram to destination IP subnet

• MAC (or LAN or physical or Ethernet) address: – used to get datagram from one interface to

another physically-connected interface (same network)

– 48 bit MAC address (for most LANs) burned in the adapter ROM

Page 74: Network Protocol. 2 Application layer protocol Transport layer protocol Network layer protocol Link layer protocol

74

LAN Addresses and ARPLAN Addresses and ARP

Each adapter on LAN has unique LAN address

Broadcast address =FF-FF-FF-FF-FF-FF

= adapter

1A-2F-BB-76-09-AD

58-23-D7-FA-20-B0

0C-C4-11-6F-E3-98

71-65-F7-2B-08-53

LAN(wired orwireless)

Page 75: Network Protocol. 2 Application layer protocol Transport layer protocol Network layer protocol Link layer protocol

75

LAN Address (more)LAN Address (more)

• MAC address allocation administered by IEEE• manufacturer buys portion of MAC address space (to assure

uniqueness)• Analogy: (a) MAC address: like Social Security Number (b) IP address: like postal address• MAC flat address ➜ portability

– can move LAN card from one LAN to another• IP hierarchical address NOT portable

– depends on IP subnet to which node is attached

Page 76: Network Protocol. 2 Application layer protocol Transport layer protocol Network layer protocol Link layer protocol

76

ARP: Address Resolution ARP: Address Resolution ProtocolProtocol

• Each IP node (Host, Router) on LAN has ARP table

• ARP Table: IP/MAC address mappings for some LAN nodes

< IP address; MAC address; TTL>– TTL (Time To Live): time

after which address mapping will be forgotten (typically 20 min)

Question: how to determineMAC address of Bknowing B’s IP address?

1A-2F-BB-76-09-AD

58-23-D7-FA-20-B0

0C-C4-11-6F-E3-98

71-65-F7-2B-08-53

LAN

237.196.7.23

237.196.7.78

237.196.7.14

237.196.7.88

Page 77: Network Protocol. 2 Application layer protocol Transport layer protocol Network layer protocol Link layer protocol

77

ARP protocol: Same LAN ARP protocol: Same LAN (network)(network)

• A wants to send datagram to B, and B’s MAC address not in A’s ARP table.

• A broadcasts ARP query packet, containing B's IP address – Dest MAC address = FF-

FF-FF-FF-FF-FF– all machines on LAN

receive ARP query • B receives ARP packet,

replies to A with its (B's) MAC address– frame sent to A’s MAC

address (unicast)

• A caches (saves) IP-to-MAC address pair in its ARP table until information becomes old (times out) – soft state: information that

times out (goes away) unless refreshed

• ARP is “plug-and-play”:– nodes create their ARP

tables without intervention from net administrator

Page 78: Network Protocol. 2 Application layer protocol Transport layer protocol Network layer protocol Link layer protocol

78

Routing to another LANRouting to another LAN• walkthrough: send datagram from A to B via R assume A knows B IP address

• Two ARP tables in router R, one for each IP network (LAN)• In ARP table at source, find MAC address E6-E9-00-17-BB-4B, etc• In routing table at source Host, find router 111.111.111.110

A

R

B

Page 79: Network Protocol. 2 Application layer protocol Transport layer protocol Network layer protocol Link layer protocol

79

• A creates datagram with source A, destination B • A uses ARP to get R’s MAC address for 111.111.111.110• A creates link-layer frame with R's MAC address as dest, frame

contains A-to-B IP datagram• A’s adapter sends frame • R’s adapter receives frame • R removes IP datagram from Ethernet frame, sees its destined

to B• R uses ARP to get B’s MAC address • R creates frame containing A-to-B IP datagram sends to B

A

RB