A Client Server Transaction: Instructors
A Client Server Transaction: Instructors
A Client‐Server Transaction
1. Client sends request
Client Server
Resource
Introduction to Computer Systems 4. Client
process
3. Server sends response
process
2. Server
15‐213/18‐243, fall 2009 handles handles
18th Lecture, Nov. 3rd response request
Note: clients and servers are processes running on hosts
(can be the same or different hosts)
Instructors:
Roger Dannenberg and Greg Ganger Most network applications are based on the client‐server
model:
A server process and one or more client processes
Server manages some resource
Server provides service by manipulating resource for clients
Server activated by request from client (vending machine analogy)
Hardware Organization of a Network Host Computer Networks
CPU chip
register file A network is a hierarchical system of boxes and wires
organized by geographical proximity
ALU
Data center networks: spans cluster or machine room
system bus memory bus Switched Ethernet, Infiniband, …
LAN (Local Area Network) spans a building or campus
I/O main Ethernet is most prominent example
MI
bridge memory
WAN (Wide Area Network) spans country or world
Typically high‐speed point‐to‐point phone lines
Expansion slots
An internetwork (internet) is an interconnected set of
I/O bus
networks
USB graphics disk network The Global IP Internet (uppercase “I”) is the most famous example
controller adapter controller adapter of an internet (lowercase “i”)
Lowest Level: Ethernet Segment Next Level: Bridged Ethernet Segment
host host host A B
host host host host host
100 Mb/s 100 Mb/s
hub X
hub 100 Mb/s bridge 100 Mb/s hub
port
1 Gb/s
host host
Ethernet segment consists of a collection of hosts connected
by wires (twisted pairs) to a hub 100 Mb/s 100 Mb/s
hub bridge hub
Spans room or floor in a building Y
host host host host host
Operation C
Each Ethernet adapter has a unique 48‐bit address (MAC address)
Hosts send bits to any other host in chunks called frames Spans building or campus
Hub slavishly copies each bit from each port to every other port
Every host sees every bit Bridges cleverly learn which hosts are reachable from which
Note: Hubs are on their way out. Bridges (switches, routers) became cheap enough
to replace them (means no more broadcasting)
ports and then selectively copy frames from port to port
Carnegie Mellon Carnegie Mellon
Conceptual View of LANs Next Level: internets
For simplicity, hubs, bridges, and wires are often shown as a Multiple incompatible LANs can be physically connected by
collection of hosts attached to a single wire: specialized computers called routers
The connected networks are called an internet
LAN LAN
router router router
WAN WAN
LAN 1 and LAN 2 might be completely different, totally incompatible
(e.g., Ethernet and Wifi, 802.11*, T1‐links, DSL, …)
Logical Structure of an internet The Notion of an internet Protocol
host How is it possible to send bits across incompatible LANs
router
host router router
and WANs?
router
Solution:
router
router protocol software running on each host and router
smooths out the differences between the different networks
Ad hoc interconnection of networks
Implements an internet protocol (i.e., set of rules)
No particular topology
governs how hosts and routers should cooperate when they
Vastly different router & link capacities transfer data from network to network
Send packets from source to destination by hopping through TCP/IP is the protocol for the global IP Internet
networks
Router forms bridge from one network to another
Different packets may take different routes
What Does an internet Protocol Do? Transferring Data Over an internet
LAN1 Host A Host B LAN2
Provides a naming scheme client server
An internet protocol defines a uniform format for host addresses
Each host (and router) is assigned at least one of these internet (1) data (8) data
protocol
PH: Internet packet header software
FH: LAN frame header
Carnegie Mellon Carnegie Mellon
Other Issues Global IP Internet
We are glossing over a number of important questions: Most famous example of an internet
What if different networks have different maximum frame sizes?
(segmentation) Based on the TCP/IP protocol family
How do routers know where to forward frames? IP (Internet protocol) :
How are routers informed when the network topology changes? Provides basic naming scheme and unreliable delivery capability
What if packets get lost? of packets (datagrams) from host‐to‐host
UDP (Unreliable Datagram Protocol)
Uses IP to provide unreliable datagram delivery from
These (and other) questions are addressed by the area of process‐to‐process
systems known as computer networking TCP (Transmission Control Protocol)
Uses IP to provide reliable byte streams from process‐to‐process
over connections
Accessed via a mix of Unix file I/O and functions from the
sockets interface
Hardware and Software Organization Naming and Communicating on the Internet
of an Internet Application Original Idea
Every node on Internet would have unique IP address
Everyone would be able to talk directly to everyone
Internet client host Internet server host No secrecy or authentication
Client User code Server Messages visible to routers and hosts on same LAN
Sockets interface Possible to forge source field in packet header
(system calls)
TCP/IP Kernel code TCP/IP
Doesn’t always work this way
Hardware interface
(interrupts) We may talk about some evolution, if time allows
Network Hardware Network See slides at end (for fun), if not
adapter and firmware adapter
Global IP Internet
A Programmer’s View of the Internet IP Addresses
32‐bit IP addresses are stored in an IP address struct
Hosts are mapped to a set of 32‐bit IP addresses
IP addresses are always stored in memory in network byte order
128.2.203.179 (big‐endian byte order)
True in general for any integer transferred in a packet header from one
The set of IP addresses is mapped to a set of identifiers machine to another.
called Internet domain names E.g., the port number used to identify an Internet connection.
Dotted Decimal Notation Dotted Decimal Notation
By convention, each byte in a 32‐bit IP address is represented By convention, each byte in a 32‐bit IP address is represented
by a string: decimal values for bytes, separated by a period by a string: decimal values for bytes, separated by a period
IP address: 0x8002C2F2 = 128.2.194.242
Blackboard? IP address: 0x8002C2F2 = 128.2.194.242
Functions for converting between binary IP addresses and
dotted decimal strings:
inet_aton: dotted decimal string → IP address in network byte order
inet_ntoa: IP address in network byte order → dotted decimal string
“n” denotes network representation
“a” denotes application representation
IP Address Structure Internet Domain Names
IP (V4) Address space divided into classes: unnamed root
0 1 2 3 8 16 24 31
Class A 0 Net ID Host ID
Class B .net .edu .gov .com First‐level domain names
10 Net ID Host ID
Class C 110 Net ID Host ID
Class D 1110 Multicast address mit cmu berkeley amazon Second‐level domain names
Class E 1111 Reserved for experiments
Domain Naming System (DNS) Properties of DNS Host Entries
The Internet maintains a mapping between IP addresses and Each host entry is an equivalence class of domain names and
domain names in a huge worldwide distributed DNS database IP addresses
Conceptually, programmers can view the DNS database as a collection of
millions of host entry structures: Each host has a locally defined domain name localhost
which always maps to the loopback address 127.0.0.1
/* DNS host entry structure */
struct hostent {
char *h_name; /* official domain name of host */
Different kinds of mappings are possible:
char **h_aliases; /* null-terminated array of domain names */ Simple case: one‐to‐one mapping between domain name and IP address:
int h_addrtype; /* host address type (AF_INET) */
int h_length; /* length of an address, in bytes */
kittyhawk.cmcl.cs.cmu.edu maps to 128.2.194.242
char **h_addr_list; /* null-terminated array of in_addr structs
*/ Multiple domain names mapped to the same IP address:
}; eecs.mit.edu and cs.mit.edu both map to 18.62.1.6
Multiple domain names mapped to multiple IP addresses:
Functions for retrieving host entries from DNS: aol.com and www.aol.com map to multiple IP addresses
gethostbyname: query key is a DNS domain name
Some valid domain names don’t map to any IP address:
gethostbyaddr: query key is an IP address for example: cmcl.cs.cmu.edu
Carnegie Mellon Carnegie Mellon
A Program That Queries DNS Querying DNS from the Command Line
int main(int argc, char **argv) { /* argv[1] is a domain name */
char **pp; /* or dotted decimal IP addr */ Domain Information Groper (dig) provides a scriptable
struct in_addr addr;
struct hostent *hostp;
command line interface to DNS
Internet Connections Putting it all Together:
Clients and servers communicate by sending streams of bytes Anatomy of an Internet Connection
over connections:
Point‐to‐point, full‐duplex (2‐way communication), and reliable.
Client socket address Server socket address
A socket is an endpoint of a connection 128.2.194.242:51213 208.216.181.15:80
Socket address is an IPaddress:port pair
Server
Client
Connection socket pair (port 80)
A port is a 16‐bit integer that identifies a process: (128.2.194.242:51213, 208.216.181.15:80)
Ephemeral port: Assigned automatically on client when client makes a
Client host address Server host address
connection request
128.2.194.242 208.216.181.15
Well‐known port: Associated with some service provided by a server
(e.g., port 80 is associated with Web servers)
51213 is an ephemeral port 80 is a well‐known port
A connection is uniquely identified by the socket addresses allocated by the kernel associated with Web servers
of its endpoints (socket pair)
(cliaddr:cliport, servaddr:servport)
Naming and Communicating on the Internet Evolution of Internet: Dynamic IP addresses
(again) Dynamic address assignment
Most hosts don't need to have known address
Original Idea Only those functioning as servers
Every node on Internet would have unique IP address DHCP (Dynamic Host Configuration Protocol)
Everyone would be able to talk directly to everyone Local ISP assigns address for temporary use
No secrecy or authentication
Messages visible to routers and hosts on same LAN
Example:
Possible to forge source field in packet header
My laptop at CMU
IP address 128.2.220.249 (bryant-tp3.cs.cmu.edu)
Shortcomings Assigned statically
There aren't enough IP addresses available My laptop at home
Don't want everyone to have access or knowledge of all other hosts IP address 205.201.7.7 (dhcp-7-7.dsl.telerama.com)
Security issues mandate secrecy & authentication Assigned dynamically by my ISP for my DSL service
Carnegie Mellon Carnegie Mellon
Evolution of Internet: Firewalls Virtual Private Networks
176.3.3.3
1
10.2.2.2 Firewall 2 10.x.x.x Firewall 10.6.6.6 198.3.3.3
4
3
216.99.99.99
Corporation X Corporation X
Internet Internet
Firewalls
Hides organizations nodes from rest of Internet
Supporting road warrior
Use local IP addresses within organization Employee working remotely with assigned IP address 198.3.3.3
For external service, provides proxy service Wants to appear to rest of corporation as if working internally
From address 10.6.6.6
1. Client request: src=10.2.2.2, dest=216.99.99.99
Gives access to internal services (e.g., ability to send mail)
2. Firewall forwards: src=176.3.3.3, dest=216.99.99.99
3. Server responds: src=216.99.99.99, dest=176.3.3.3 Virtual Private Network (VPN)
4. Firewall forwards response: src=216.99.99.99, dest=10.2.2.2 Overlays private network on top of regular Internet