Title: Overview of Internet Concepts
1Overview of Internet Concepts
- Steven Czerwinski
- NGI Summer Research Program
- June 21, 2002
- UC Berkeley
- Information and slides from CS262 Spring 2002
lectures - By Kevin Lai and Ion Stoica
2Outline
- Internet architecture
- Networking concepts
- TCP/IP
- Traditional systems
- Next-generation concepts
3What is the Internet?
- What does it mean when a computer is on the
Internet? - Has an Internet Protocol (IP) address
- Transmits packets formatted in the IP standard
128.32.33.57
PACKET
4The Internet Protocol (IPv4)
- Defines how information is transmitted on
Internet - IP address
- Unique identifier for a communication end-point
- 32 bits long (255.255.255.255)
- IP packet
- Two parts headers and data payload
- Limited by Maximum Transmission Unit (MTU) size
- IP headers
- IP destination address identifiers where the
packet should go - IP source address identifiers who sent the
packet - TTL Time-to-live counter, used to avoid infinite
loops - Checksum verified the contents of the packet
- Headers are typically 20 bytes
5IP Packet
6The Internet abstraction
- Packet delivery mechanism
- Inject a packet at one end
- Comes out at the destination at the other end
- Delivery guarantee level best effort
- Unreliable (packets maybe be lost, never
delivered) - Unordered (packets may arrive in different order
then sent) - Arbitrary delay (packets may take a long time to
arrive)
1.1.1.1
4.3.1.2
Packet
DST 4.3.1.2 SRC 1.1.1.1
Data payload
7Internet components
Transit Stub Network
Routers
Interface
8Routers
- Building blocks of the Internet
- Connect networks together (each is an interface)
- Makes routing decisions
- When a packet arrives
- Placed in queue (finite length)
- If no room in queue, the packet is dropped (lost)
- Destination address compared against the routing
tables - Output onto the correct interface
- Routes are chosen by least number of hops
Incoming Packet
Queue
DST IP Of Next Packet
Network A
From Network C
DST IP Interface 2.3.X.X A 4.X.X.X B
Network B
Routing table
9Routing example
Fwd table
Fwd table
1.1.1.X R6
1.1.X.X R4
128.32.33.57
1.1.1.2
R4
R1
R3
R6
R2
R5
10Modeling packet transmissions
- Two major components
- Transmission time Latency BWpacket_size
- Latency fixed time delay to send a packet
- Bandwidth additional delay per byte sent
- Round Trip Time (RTT)
- Common metric to measure latency
- Time to send a packet to destination and then
back to source - RTT orders of magnitude
- Same subnet 10s 100s usecs
- Local area 1-10 millisecs
- Wide area 60-150 millisecs
- I2 across the country 90 millisecs
11Signpost
- Internet architecture
- Networking concepts
- TCP/IP
- Traditional systems
- Next-generation concepts
12ISO OSI Reference Model
- The acronyms
- ISO International Standard Organization
- OSI Open System Interconnection
- Common abstraction
- Seven layer model
- Physical how to send a bit on physical medium
- Datalink how to send a frame on physical medium
- Network how to send a packet to a remote host
- Transport how to send a group of packets
- Session how to use packets for a two-way
conversation - Presentation how to send data in the
conversation - Application how to provide a service
(7) (6) (5) (4) (3) (2) (1)
Application
Presentation
Session
Transport
Network
Datalink
Physical
13Internet protocols
- IP layer (layer 3)
- Defines packet headers
- Characteristics of physical medium hidden
- Transport protocols (layer 4)
- Unreliable Datagram Protocol (UDP)
- Transmission of packets, with no delivery
guarantees - Transmission Control Protocol (TCP/IP)
- Transmission of stream of bytes (ordered)
- Reliable delivery with congestion control
14TCP/IP
- Most commonly used protocol
- Guarantees in order, reliable packet delivery
- Packets marked by sequence number (ordering)
- All packets are acknowledged (ACKs)
- Fairly shares bandwidth among all clients
- Each clients bandwidth will be reduced to allow
other clients to use the network
15TCP/IP Reliable delivery
- Reliable delivery through ACKs
- Each packet assigned sequence number at sender
- Receiver sends an ACK message when packet arrives
- If ACK not received after some time, sender
retransmits
Data Packets
1
2
ACK 1
TIMEOUT
2
16TCP/IP Ordered delivery
- Ordered delivery through sequence numbers
- Sequence numbers are monotonically increasing
- Upon packet arrivals, just arrange by sequence
number - Delay giving packets to application if necessary
Data Packets
1
2
3
ACK 1-3
17TCP/IP Congestion control
- Network congestion definition
- Too many packets being sent, network cannot
handle it - Congestion control
- Clients reduce send rates automatically to share
network - Congestion is signaled through dropped packets
(routers cant handle the packet load)
Data Packets
Sending 3 packets per sec
Can only handle 3 packets per sec
3
2
1
Router
Client A
1
Client B
2
Sending 2 packets per sec
18TCP/IP Congestion control cont
- Implicit congestion signal
- Packet loss/drop
- When notice congestion, need to decrease send
rate - All clients must reduce rate to play fairly
- TCP/IP congestion algorithms
- Adjust send rate by additive increase,
multiplicative decrease - Congest window
- Number of packets a client sends in one RTT
interval - Essentially their send rate
- Has units of packets per second
- Control is all about how you change the window
size - How does TCP/IP change window size?
- Slow-start (increase send rate to find our
maximum) - Congestion avoidance (when get near limit,
increase slower) - Time-outs (when packet drops, cut window in half)
19TCP Congestion Control
- Maintains three variables
- cwnd congestion window (amount to send per RTT
) - flow_win flow window receiver advertised
window - ssthresh threshold size (used to update cwnd)
- For sending use win min(flow_win, cwnd)
20TCP Slow Start
- Goal discover congestion quickly
- How?
- quickly increase cwnd until network congested ?
get a rough estimate of the optimal of cwnd - Whenever starting traffic on a new connection, or
whenever increasing traffic after congestion was
experienced - Set cwnd 1
- Each time a segment is acknowledged increment
cwnd by one (cwnd). - Slow Start is not actually slow
- cwnd increases exponentially
21Slow Start Example
- The congestion window size grows very rapidly
- TCP slows down the increase of cwnd when cwnd gt
ssthresh
cwnd 2
cwnd 4
cwnd 8
22Congestion Avoidance
- Slow down Slow Start
- If cwnd gt ssthresh then each time a segment is
acknowledged increment cwnd by 1/cwnd (cwnd
1/cwnd). - So cwnd is increased by one only if all segments
have been acknowlegded.
23TCP Pseudocode
- Initially
- cwnd 1
- ssthresh infinite
- New ack received
- if (cwnd lt ssthresh)
- / Slow Start/
- cwnd cwnd 1
- else
- / Congestion Avoidance /
- cwnd cwnd 1/cwnd
- Timeout
- / Multiplicative decrease /
- ssthresh win/2
- cwnd 1
while (next lt unack win) transmit next
packet where win min(cwnd, flow_win)
unack
next
seq
win
24The Big Picture
cwnd
Timeout
Congestion Avoidance
Slow Start
Time
25Programming with TCP/IP
- Typical interaction client/server
- Server applications listens for connections
- Clients connect to server on using well-known
port - What are ports?
- Part of UDP and TCP protocols
- Ports are numbers
- Used to identify recipient/sender applications
- Source and destination ports are included in
headers
DST IP 4.3.2.1 SRC IP 1.1.1.1 DST
PORT 22 SRC PORT 6576
Data Packet
Client
Server
Listeningon port 22
DST IP 1.1.1.1 SRC IP 4.3.2.1 DST
PORT 6576 SRC PORT 22
1.1.1.1
4.3.2.1
26Network programming with Unix
- See
- Unix Network Programming by Stevens
- File descriptors (FDs)
- Represent input/output to your program
- Can either be files or network streams
- Network streams are called sockets
- Main commands
- Socket create FD that represents a socket
- Bind associate a socket FD with a given address
- Connect connect socket to remote host
- Listen server listens on socket for connections
- Accept server accepts connection, and
communicates
27Server in C
- server_socket_fd socket(AF_INET, SOCK_STREAM,
0) saddr.sin_family AF_INET
saddr.sin_addr.s_addr htonl(INADDR_ANY)
saddr.sin_port htons(server_port)
bind(server_socket_fd, (struct sockaddr )saddr,
sizeof(saddr)) while (1)
listen(server_socket_fd, 5)
from_client_socket_fd accept(server_socket_fd,
NULL, NULL) if (fork() 0)
close(server_socket_fd)
handle_client(from_client_socket_fd)
exit(0) else
close(from_client_socket_fd)
28Server in C cont.
- int handle_client(int from_client_socket_fd)
-
- while ((num_read read(from_client_socket_fd,
buffer, BUFFER_SIZE)) ! 0) - for (i 0 i lt num_read i)
- if (bufferi '.')
- done 1
- else
- bufferi toupper(bufferi)
- write(from_client_socket_fd, buffer,
num_read) - if (done 1)
- break
-
- close(from_client_socket_fd)
-
29Client in C
- to_server_socket_fd socket(AF_INET,
SOCK_STREAM, 0) - memset(saddr, 0, sizeof(saddr))
- saddr.sin_family AF_INET
- saddr.sin_port htons(server_port)
- inet_pton(AF_INET, "127.0.0.1", saddr.sin_addr)
- connect(to_server_socket_fd, (struct sockaddr )
saddr, sizeof(saddr)) -
- send_to_server(to_server_socket_fd, "Hi this is a
test\n") - send_to_server(to_server_socket_fd, "Saying
bye.\n") - read_from_server(to_server_socket_fd)
- close(to_server_socket_fd)
30Network programming with Java
- Important classes
- Java.net.Socket client connections
- Java.net.ServerSocket server sockets
- Java.net.InetAddress hostnames and IP addresses
- Sockets represent connections
- Have InputStream and OutputStream for
communication
31Server in Java
- Public static void main(String argv)
- int server_port 6656
-
- ServerSocket server_socket new
ServerSocket(server_port) - Socket client_socket
- server client_handler
- while (true)
- client_socket server_socket.accept()
- client_handler new server(client_socket)
- client_handler.start() // server
extends Thread class -
32Server in Java cont.
- public class server extends Thread
- public void run()
- InputStream from_client
client_socket.getInputStream() - OutputStream to_client
client_socket.getOutputStream() -
- while ((num_read from_client.read(buffer
)) ! 0) - for (int i 0 i lt num_read i)
- if (bufferi '.')
- done true
- else
- bufferi (byte)
Character.toUpperCase((char) bufferi) - to_client.write(buffer,0, num_read)
- if (done)
- break
-
- client_socket.close()
-
33Client in Java
- InetAddress server_address InetAddress.getByName
("127.0.0.1") - Socket to_server_socket new Socket(server_addres
s, 6656) - InputStream from_server to_server_socket.getInpu
tStream() - OutputStream to_server to_server_socket.getOutpu
tStream() - send_to_server(to_server, "Hi this is a test\n")
- send_to_server(to_server, "Saying bye.\n")
- read_from_server(from_server)
- to_server_socket.close()
34Signpost
- Internet architecture
- Networking concepts
- TCP/IP
- Traditional systems
- Next-generation concepts
35Service model Client-Server
TheInternet
- Classic client-server model
- Clients connect to servers over TCP/IP (specific
ports) - Clients send requests, servers do work, send
responses - Application-level protocol defines transmission
format - Examples
- SMTP (mail) and HTTP (web)
36Service model Server clusters
TheInternet
- Server cluster
- Better fault tolerance and scalability
- Client suffers when latency or BW constrained
- Single point of failure (incoming network link)
- Examples
- NOW, Ninja, Inktomi
37Example SMTP
- Simple Mail Transfer Protocol (SMTP)
- How mail messages are transferred
- Serves listen on port 25
- Trace of sending 1 message with 1 recipient
Client
Server
S 220 relay.EECS.Berkeley.EDU ESMTP C EHLO
eecs.berkeley.edu S 250-relay Hello batman,
250-EXPN C MAIL FROMltczerwin_at_eecs.berkeley.edugt
S 250 czerwin_at_eecs.berkeley.edu Sender ok C
RCPT TOltczerwin_at_eecs.berkeley.edugt S 250
czerwin_at_eecs.berkeley.edu Recipient ok C
DATA S 354 Enter mail, end with . on a line by
itself C ltMail contentgt S 250 0AA24025 Message
accepted for delivery C QUIT S 221
relay.EECS.Berkeley.EDU closing connection
38Example SMTP continued
Client
Server
39The Web
- Hypertext Transfer Protocol (HTTP)
- Application-level protocol that defines the web
- Servers listen on port 80
- Images and pages are just documents
- Commands are simple
- GET document
- PUT document
- POST document
- Documents are specified by path
- URL http//www.cs.berkeley.edu/czerwin/index.ht
ml - One piece missing
- How is the hostname resolved to an IP address? --
DNS
40DNS
- Domain Name Service (DNS)
- Implemented over UDP
- Provides mapping between names to IP addresses
- Each domain runs its own DNS server
- Responsible for knowing addresses for all hosts
in its domain - Root servers maintain pointers to domain servers
- Each client must know local DNS server
- Resolution scheme
- Clients ask local server first
- If local server doesnt know mapping, forwards to
root
ROOT DNS Server
.COM Server
.EDU Server
Yahoo.com Server
berkeley.edu Server
41Signpost
- Internet architecture
- Networking concepts
- TCP/IP
- Traditional systems
- Next-generation concepts
42Service model Proxies Caches
TheInternet
- Proxy cache solution
- Proxies augment server functionality
- Distribute load from the server
- Reduces client latency
- Examples
- Web caches
43Service model CDNs
TheInternet
Server cluster
- Content distribution network
- Edge proxies distribute content
- Great scalability
- Reduces client latency and system bandwidth
- Examples
- Akamai, Digital Island, etc.
44Multicast
- Enables 1-to-many communication
- Send the same message to N receivers
- More efficient then sending same message N times
- Requires cooperation of infrastructure/routers
- How to use
- Client joins a group
- Groups are defined by address (looks like IP
address) - Simply send to group
- Client does not need to know IP addresses of
receivers - Not widely deployed
- May work in your local area, not but across the
wide area
Router
Packet
Receivers
Router
Router
45Quality of Service
- Provides differentiated service levels
- Packets are treated differently based on type
- Which packet should a router drop?
- Which packet should a router service first?
- Service level examples
- Voice over IP route packets as quickly as
possible - File sharing software rate limit
- Requires support in infrastructure
- Everyone must agree to same service levels
46Conclusion
- The End
- See for more details
- http//inst.EECS.Berkeley.EDU/cs268/
- TCP/IP Illustrated Volume 1, by Wright Stevens
- Unix Network Programming by Stevens
- Sample code http//www.cs.berkeley.edu/czerwin/S
ample.tar.gz