You are on page 1of 43

TCP/IP

Lecture 2

cs193i – Internet Technologies


Summer 2004
Stanford University
Announcements
 Lab #1 due Wednesday
 HW #1 assigned
 Extra perl session tomorrow
 Tuesday, June 29, 2:15-3:05pm, Skilling 193
 Broadcast live on E2, Stanford Online

 Silas’ Thursday office hours moved to


Wednesday this week
 Sweet Hall, 6:30-8:30pm
Communicating with Anyone
How’s the
weather in
Seattle, Mar?

kashaw@cs.stanford.edu
Ethernet

Network

mar@cs.washington.edu
Token-
ring

MSN Messenger
Local Area Network (LAN)
 High speed, data LAN 1
network over small
region
 Few thousand meters Ethernet
 Network technologies:
 Ethernet
 FDDI
Token-
 Token ring ring

 Data link layer


 Packets routed based on
physical address (MAC)
LAN 2
Local Area Network (LAN)
 High speed, data LAN 1
network over small
region
 Few thousand meters Ethernet
 Network technologies:


Ethernet
FDDI
?
Token-
 Token ring ring

 Data link layer


 Packets routed based on
physical address (MAC)
LAN 2
Connecting Below Internet Level
 Hub
 Center of star topology
 In Ethernet, multiport repeater
or concentrator
Hub
 Bridge
 Connects 2 networks of same
technology – extended LAN Ethernet Ethernet

 Filters/forwards/floods based
on MAC Bridge
 Link layer - frames
 Switch Ethernet Ethernet

 Connects 2+ networks – CIS C OSY S TEM S

T3
CIS COSY ST EM S

packet-switched network
CISCO SYSTEMS
STS-N

 Reduces collisions Switch


Connecting at the Internet Level
 Router
 Originally gateway
Ethernet Ethernet

 Forwards packets based CISCO SYSTEMS CISCO SYSTEMS

on network layer info


(IP)
Router
 Separate broadcast
domains
 In each domain, IP CISCOS YSTEMS

packet encapsulated in
Token-
ring

domain-specific packet
Internet Society
 Governing body for Internet since 1992
 http://www.isoc.org
 Domain names and addresses assigned
 Upper level: Internet Assigned Numbers Authority
 Regional:
 Latin America / Caribbean
 Asia Pacific

 America

 Europe
How Does Everyone Work
Together?
 Networks
 MCI Worldcom, Sprint, Earthlink, …
 Exchange points provide connections between networks
 Network Access Points – open access policies
 Network Service Provider
 Build national or global networks
 Lease space at NAPs
 Sell bandwidth to regional NSPs
 Regional NSP sell bandwidth to ISP
 Internet Service Provider sells bandwidth to end users
How Does Everyone Work
Together?
OSI Reference Model
for Network Design

Application (Layer 7)
Presentation
Session
Transport
Network
Data Link
Physical (Layer 1)
OSI vs. TCP/IP Stack
Layering: FTP Example
Application
FTP Application
Presentation ASCII/Binary

Session
TCP Transport
Transport
Network IP Network
Link
Ethernet Link
Physical

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


Internet Protocol

Protocol Stack

App

Transport TCP / UDP Data Hdr TCP Segment

Network IP Data Hdr IP Datagram

Link
IP Datagram

Header

10101011101010101010010101010100101010100
11010010101010010101111111010000011101111
10100001011101010100110101011110100000101
00100000000010101000011010000111111010101
......... 1011011001010100011001001010110
Data
IP Addresses
 4 8-bit numbers (Hierarchical)
18.26.0.1

network 32-bits host

 Specifies both network and host


 Number of bits allocated to specify network varies
 Three classes:
A B C

0 net host 1 0 net host 110 net host

1 7 24 bits 2 14 16 bits 3 21 8 bits


IP Addresses
 IP (Version 4) Addresses are 32 bits long
 IP Addresses Assigned Statically or
Dynamically (DHCP)
 IPv6 addresses are 128 bits long
IP Address Space
 Originally, 3 Classes
 A, B, C
 Problem
 Classes too rigid (C too small, B too big)
 Solution
 Subnetting (e.g. within Stanford)
 Classless Interdomain Routing (CIDR)
Subnetting
 IP Address plus subnet mask (netmask)
 IP Addr: 171.64.15.82
Netmask: 0xFFFFFF00 (111...1100000000)
 First 24 bits are the Subnet ID (the
neighborhood)
 Last 8 bits are Host ID (the street address)

 Can be written as “Prefix + Length”


 171.64.15.0/24 or 171.64.15/24
Subnetting at Stanford

To: cenic.net
dcl-rtr 171.64.1.132 171.64.74.0/24
171.64.1.132/30
171.64.1.133

171.64.1.161 171.64.1.178 171.64.74.1


Stanford Class B
Address bbr2-rtr Gates-rtr
171.64.74.58
171.64.1.160/27
171.64.0.0/16
yuba
171.64.1.152
171.64.1.144/28
To: cogentco.com border-rtr
171.64.1.145
IP Routing
 Routers are not omniscient
 Next-Hop
 Hop-by-Hop
 Thus IP makes no guarantees
 except to try it’s best (”Best Effort”)
 packets may get there out of order, garbled,
duplicated
 may not get there at all!

 Unreliable datagram service


IP Routing Hop-by-Hop
128.17.20.1 e.g. 128.9.16.14 => Port 2
R2
Prefix Next-hop Port
65/8 128.17.16.1 3
1 128.9/16 128.17.14.1 2
R1 2 R3 128.9.16/20 128.17.14.1 2
3
128.9.19/24 128.17.10.1 7
128.9.25/24 128.17.14.1 2
128.9.176/20 128.17.20.1 1
R4
142.12/19 128.17.16.1 3
128.17.16.1
Forwarding/routing table

How a Router Forwards Datagrams


Classless Interdomain Routing
(CIDR)

0 232-1
Classless Interdomain Routing
(CIDR)
128.9.0.0
142.12/19
65/8
128.9/16

0 232 -1
216

128.9.16.14
Classless Interdomain Routing
(CIDR)

128.9.19/24
128.9.25/24

128.9.16/20 128.9.176/20

128.9/16

0 232 -1

128.9.16.14
Classless Interdomain Routing
(CIDR)

128.9.19/24
128.9.25/24

128.9.16/20 128.9.176/20

128.9/16

0 232 -1

128.9.16.14
Five Minute Break
Network Programs
 host
 ping
 traceroute
 nslookup
Summary of IP
 Connectionless/Datagram
 Unreliable/Best Effort
Transmission Control Protocol

Protocol Stack

App

Transport TCP / UDP Data Hdr TCP Segment

Network IP Data Hdr IP Datagram

Link
Characteristics
 Connection-Oriented
 Reliable
 Byte-Stream
 Flow Control
(aka Congestion Control)
Three Phases
 Establish Connection
 Data Transfer
 Terminate Connection
Establishing the Connection
(Active) (Passive)
Client Server
Syn

Syn + Ack

Ack

Connection Setup
3-way handshake
Data Transfer

Byte 80
Byte 3
Byte 2
Byte 1
Byte 0
Byte 80
Byte 3
Byte 2
Byte 1
Host A Byte 0

Host B
Data Transfer

Byte 80

TCP Data
Byte 3
Byte 2
Byte 1
Byte 0
Byte 80

TCP Data
Byte 3
Byte 2
Byte 1
Host A Byte 0

Host B
Maintaining the “Connection”
IP Data
TCP Data TCP Hdr IP Hdr

0 15 31
Src port Dst port

Sequence #
Src /dst port numbers
Ack Sequence #
and IP addresses
Flags
Window Size uniquely identify socket
HLEN RSVD
SYN
URG

PSH
RST
ACK

FIN

4 6

Checksum Urg Pointer

(TCP Options)

TCP Data
Terminating the Connection
(Active) (Passive)
Client Server
Fin

(Data +) Ack

Fin

Ack

Connection Close/Teardown
2 x 2-way handshake
 Connection-Oriented
 Reliable
 Byte-Stream
 Flow Control
(aka Congestion Control)
Reliability & Flow Control
 Sequence numbers & Acknowledgements
(ACKs)
 Receiver detects Corrupt, Lost, Duplicated, Out-
of-order
 Tell sender which packets it has received correctly

 Sender can resend

 In Flight Window (Window Size)


 Sender only has N unacknowledged packets “in
Sending a Message

Leland.Stanford.edu Arachne.Berkeley.edu
Application Layer

Ron Leslie

Transport Layer

O.S. Data Header Data Header


O.S.
Network Layer D H
D H

D H D H D H

D H Link Layer
 Connection-Oriented
 Reliable
 Byte-Stream
 Flow Control
(aka Congestion Control)
UDP

Protocol Stack

App

Transport TCP / UDP Data Hdr TCP Segment

Network IP Data Hdr IP Datagram

Link
User Datagram Protocol (UDP)
 Like TCP, in the Transport Layer
 Characteristics
 Connectionless, Datagram, Unreliable

 Adds only application


multiplexing/demultiplexing and
checksumming to IP
 Good for Streaming Media, Real-time
Multiplayer Networked Games, VoIP
Summary
 IP is the basis of Internetworking
 TCP builds on top of IP
adds reliable, congestion-controlled,
connection-oriented byte-stream.
 UDP builds on top of IP
allows access to IP functionality

You might also like