TCP/IP Lecture 2 cs193i – Internet Technologies Summer 2004 Stanford University

Preview:

Citation preview

TCP/IPTCP/IPLecture 2Lecture 2

cs193i – Internet cs193i – Internet TechnologiesTechnologies

Summer 2004Summer 2004

Stanford UniversityStanford University

AnnouncementsAnnouncements

Lab #1 due WednesdayLab #1 due Wednesday HW #1 assignedHW #1 assigned Extra perl session tomorrowExtra perl session tomorrow

Tuesday, June 29, 2:15-3:05pm, Skilling Tuesday, June 29, 2:15-3:05pm, Skilling 193193

Broadcast live on E2, Stanford OnlineBroadcast live on E2, Stanford Online Silas’ Thursday office hours moved to Silas’ Thursday office hours moved to

Wednesday this weekWednesday this week Sweet Hall, 6:30-8:30pmSweet Hall, 6:30-8:30pm

Communicating with Communicating with AnyoneAnyone

Token-ring

mar@cs.washington.edu

kashaw@cs.stanford.edu

How’s theweather inSeattle, Mar?

MSN Messenger

Network

Ethernet

Local Area Network Local Area Network (LAN)(LAN)

High speed, data High speed, data network over small network over small regionregion Few thousand metersFew thousand meters

Network Network technologies:technologies: EthernetEthernet FDDIFDDI Token ringToken ring

Data link layer Data link layer Packets routed based Packets routed based

on physical address on physical address (MAC)(MAC)

Ethernet

Token-ring

LAN 1

LAN 2

Local Area Network Local Area Network (LAN)(LAN)

High speed, data High speed, data network over small network over small regionregion Few thousand metersFew thousand meters

Network Network technologies:technologies: EthernetEthernet FDDIFDDI Token ringToken ring

Data link layer Data link layer Packets routed based Packets routed based

on physical address on physical address (MAC)(MAC)

Ethernet

Token-ring

LAN 1

LAN 2

?

Connecting Below Connecting Below Internet LevelInternet Level

HubHub Center of star topologyCenter of star topology In Ethernet, multiport In Ethernet, multiport

repeater or concentratorrepeater or concentrator BridgeBridge

Connects 2 networks of Connects 2 networks of same technology – same technology – extended LANextended LAN

Filters/forwards/floods Filters/forwards/floods based on MAC based on MAC

Link layer - framesLink layer - frames SwitchSwitch

Connects 2+ networks – Connects 2+ networks – packet-switched packet-switched networknetwork

Reduces collisionsReduces collisions

Ethernet Ethernet

Hub

Bridge

Switch

Ethernet Ethernet

CISCOSYSTEMS

CISCOSYSTEMS CISCOSYSTEMS

T3 STS-N

Connecting at the Connecting at the Internet LevelInternet Level

RouterRouter Originally gatewayOriginally gateway Forwards packets Forwards packets

based on network based on network layer info layer info (IP)(IP)

Separate broadcast Separate broadcast domainsdomains

In each domain, IP In each domain, IP packet encapsulated packet encapsulated in domain-specific in domain-specific packetpacket

Token-ring

CISCOSYSTEMS

Ethernet

CISCOSYSTEMS

Ethernet

CISCOSYSTEMS

Router

Internet SocietyInternet Society

Governing body for Internet since 1992Governing body for Internet since 1992 http://www.isoc.orghttp://www.isoc.org

Domain names and addresses assignedDomain names and addresses assigned Upper level: Internet Assigned Numbers Upper level: Internet Assigned Numbers

AuthorityAuthority Regional: Regional:

Latin America / CaribbeanLatin America / Caribbean Asia PacificAsia Pacific AmericaAmerica EuropeEurope

How Does Everyone Work How Does Everyone Work Together?Together?

NetworksNetworks MCI Worldcom, Sprint, Earthlink, …MCI Worldcom, Sprint, Earthlink, … Exchange points provide connections between Exchange points provide connections between

networksnetworks Network Access Points – open access policiesNetwork Access Points – open access policies

Network Service Provider Network Service Provider Build national or global networksBuild national or global networks Lease space at NAPsLease space at NAPs Sell bandwidth to regional NSPsSell bandwidth to regional NSPs Regional NSP sell bandwidth to ISPRegional NSP sell bandwidth to ISP

Internet Service Provider sells bandwidth to Internet Service Provider sells bandwidth to end usersend users

How Does Everyone Work How Does Everyone Work Together?Together?

OSI Reference Model OSI Reference Model for Network Designfor Network Design

Application (Layer 7)Presentation

SessionTransportNetworkData Link

Physical (Layer 1)

OSI vs. TCP/IP StackOSI vs. TCP/IP Stack

Layering: FTP Example

Network

Link

Transport

Application

Presentation

Session

Transport

Network

Link

Physical

The 7-layer OSI Model The 4-layer Internet model

ApplicationFTP

ASCII/Binary

IP

TCP

Ethernet

Internet ProtocolInternet Protocol

App

Transport

Network

Link

TCP / UDP

IP

Data Hdr

Data Hdr

TCP Segment

IP Datagram

Protocol Stack

IP DatagramIP Datagram

Header

10101011101010101010010101010100101010100110100101010100101011111110100000111011111010000101110101010011010101111010000010100100000000010101000011010000111111010101......... 1011011001010100011001001010110

Data

IP AddressesIP Addresses 4 8-bit numbers (Hierarchical)4 8-bit numbers (Hierarchical)

Specifies both network and hostSpecifies both network and host Number of bits allocated to specify network Number of bits allocated to specify network

variesvaries Three classes:Three classes:

0 net host

1 7 24 bits

110 net host

3 21 8 bits

1 0 net host

2 14 16 bits

A B C

18.26.0.1

network 32-bits host

IP AddressesIP Addresses

IP (Version 4) Addresses are 32 bits IP (Version 4) Addresses are 32 bits longlong

IP Addresses Assigned Statically or IP Addresses Assigned Statically or Dynamically (DHCP)Dynamically (DHCP)

IPv6 addresses are 128 bits longIPv6 addresses are 128 bits long

IP Address SpaceIP Address Space

Originally, 3 ClassesOriginally, 3 Classes A, B, CA, B, C

ProblemProblem Classes too rigid (C too small, B too Classes too rigid (C too small, B too

big)big) SolutionSolution

Subnetting (e.g. within Stanford)Subnetting (e.g. within Stanford) Classless Interdomain Routing (CIDR)Classless Interdomain Routing (CIDR)

SubnettingSubnetting

IP Address plus subnet mask (netmask)IP Address plus subnet mask (netmask) IP Addr: 171.64.15.82IP Addr: 171.64.15.82

Netmask: 0xFFFFFF00 Netmask: 0xFFFFFF00 (111...1100000000)(111...1100000000) First 24 bits are the Subnet ID (the First 24 bits are the Subnet ID (the

neighborhood)neighborhood) Last 8 bits are Host ID (the street address)Last 8 bits are Host ID (the street address)

Can be written as “Prefix + Length”Can be written as “Prefix + Length” 171.64.15.0/24 or 171.64.15/24171.64.15.0/24 or 171.64.15/24

Subnetting at StanfordSubnetting at Stanford

Gates-rtr171.64.74.58

171.64.74.0/24

171.64.1.178

yuba

border-rtr

dcl-rtr

bbr2-rtr

171.64.1.161

171.64.1.160/27171.64.0.0/16

Stanford Class BAddress

171.64.74.1

171.64.1.132To: cenic.net

To: cogentco.com

171.64.1.152

171.64.1.145

171.64.1.133

171.64.1.144/28

171.64.1.132/30

IP RoutingIP Routing

Routers are not omniscientRouters are not omniscient Next-HopNext-Hop

Hop-by-HopHop-by-Hop Thus IP makes no guaranteesThus IP makes no guarantees

except to try it’s best (”Best Effort”)except to try it’s best (”Best Effort”) packets may get there out of order, packets may get there out of order,

garbled, duplicatedgarbled, duplicated may not get there at all!may not get there at all! Unreliable datagram serviceUnreliable datagram service

IP Routing Hop-by-HopIP Routing Hop-by-Hop

128.9/16128.9.16/20

128.9.176/20

128.9.19/24128.9.25/24

142.12/19

65/8

Prefix Port

3227213

128.17.14.1128.17.14.1

128.17.20.1

128.17.10.1128.17.14.1

128.17.16.1

128.17.16.1

Next-hop

R1

R2

R3

R4

12

3

128.17.20.1

128.17.16.1

e.g. 128.9.16.14 => Port 2

Forwarding/routing table

How a Router Forwards Datagrams

Classless Interdomain Classless Interdomain Routing (CIDR)Routing (CIDR)

0 232-1

Classless Interdomain Classless Interdomain Routing (CIDR)Routing (CIDR)

0 232-1

128.9/16

128.9.0.0

216

142.12/19

65/8

128.9.16.14

Classless Interdomain Classless Interdomain Routing (CIDR)Routing (CIDR)

0 232-1

128.9/16

128.9.16.14

128.9.16/20128.9.176/20

128.9.19/24

128.9.25/24

Classless Interdomain Classless Interdomain Routing (CIDR)Routing (CIDR)

0 232-1

128.9/16

128.9.16.14

128.9.16/20128.9.176/20

128.9.19/24

128.9.25/24

Five Minute Break Five Minute Break

Network ProgramsNetwork Programs

hosthost pingping traceroutetraceroute nslookupnslookup

Summary of IPSummary of IP

Connectionless/DatagramConnectionless/Datagram Unreliable/Best EffortUnreliable/Best Effort

Transmission Control Transmission Control ProtocolProtocol

App

Transport

Network

Link

TCP / UDP

IP

Data Hdr

Data Hdr

TCP Segment

IP Datagram

Protocol Stack

CharacteristicsCharacteristics

Connection-OrientedConnection-Oriented ReliableReliable Byte-StreamByte-Stream Flow Control Flow Control

(aka Congestion Control)(aka Congestion Control)

Three PhasesThree Phases

Establish ConnectionEstablish Connection Data TransferData Transfer Terminate ConnectionTerminate Connection

Establishing the Establishing the ConnectionConnection

Connection Setup3-way handshake

(Active)Client

(Passive)Server

Syn

Syn + Ack

Ack

Data TransferData Transfer

Byte 0

Byte 1

Byte 2

Byte 3

Byte 0

Byte 1

Byte 2

Byte 3

Host A

Host B

Byte 80

Byte 80

Data TransferData Transfer

Byte 0

Byte 1

Byte 2

Byte 3

Byte 0

Byte 1

Byte 2

Byte 3

Host A

Host B

Byte 80

TCP Data

TCP DataB

yte 80

Maintaining the Maintaining the “Connection”“Connection”

IP HdrIP Data

TCP HdrTCP Data

Src port Dst port

Sequence #

Ack Sequence #

HLEN

4

RSVD

6 UR

GA

CK

PS

HR

ST

SYN

FIN

FlagsWindow Size

Checksum Urg Pointer

(TCP Options)

0 15 31

TCP Data

Src/dst port numbersand IP addresses

uniquely identify socket

Terminating the Terminating the ConnectionConnection

Connection Close/Teardown2 x 2-way handshake

(Active)Client

(Passive)Server

Fin

(Data +) Ack

Fin

Ack

Connection-OrientedConnection-Oriented ReliableReliable Byte-StreamByte-Stream Flow Control Flow Control

(aka Congestion Control)(aka Congestion Control)

Reliability & Flow ControlReliability & Flow Control

Sequence numbers & Sequence numbers & Acknowledgements (ACKs)Acknowledgements (ACKs) Receiver detects Corrupt, Lost, Duplicated, Receiver detects Corrupt, Lost, Duplicated,

Out-of-order Out-of-order Tell sender which packets it has received Tell sender which packets it has received

correctlycorrectly Sender can resendSender can resend

In Flight Window (Window Size)In Flight Window (Window Size) Sender only has N unacknowledged Sender only has N unacknowledged

packets “inpackets “in

Sending a MessageSending a Message

Network Layer

Link Layer

Ron Leslie

Leland.Stanford.edu Arachne.Berkeley.eduApplication Layer

Transport Layer

O.S. O.S.HeaderData HeaderData

HD

HD

HD

HD HD

HD

Connection-OrientedConnection-Oriented ReliableReliable Byte-StreamByte-Stream Flow Control Flow Control

(aka Congestion Control)(aka Congestion Control)

UDPUDP

App

Transport

Network

Link

TCP / UDP

IP

Data Hdr

Data Hdr

TCP Segment

IP Datagram

Protocol Stack

User Datagram Protocol User Datagram Protocol (UDP)(UDP)

Like TCP, in the Transport LayerLike TCP, in the Transport Layer CharacteristicsCharacteristics

Connectionless, Datagram, UnreliableConnectionless, Datagram, Unreliable Adds only Adds only application application

multiplexing/demultiplexingmultiplexing/demultiplexing and and checksummingchecksumming to IP to IP

Good for Streaming Media, Real-Good for Streaming Media, Real-time Multiplayer Networked time Multiplayer Networked Games, VoIPGames, VoIP

SummarySummary

IP is the basis of InternetworkingIP is the basis of Internetworking TCP builds on top of IPTCP builds on top of IP

adds reliable, congestion-controlled, adds reliable, congestion-controlled, connection-oriented byte-stream.connection-oriented byte-stream.

UDP builds on top of IPUDP builds on top of IPallows access to IP functionalityallows access to IP functionality

Recommended