UDP, TCP/IP, and IP Multicast: COM S 414 Sunny Gleason, Vivek Uppal Tuesday, October 23, 2001
UDP, TCP/IP, and IP Multicast: COM S 414 Sunny Gleason, Vivek Uppal Tuesday, October 23, 2001
UDP, TCP/IP, and IP Multicast: COM S 414 Sunny Gleason, Vivek Uppal Tuesday, October 23, 2001
COM S 414
Sunny Gleason, Vivek Uppal
Tuesday, October 23rd, 2001
In This Lecture
• We will build on understanding of IP (Internet
Protocol)
– UDP: User Datagram Protocol
• Unreliable, packet-based protocol
– TCP: Transmission Control Protocol
• Reliable, connection-oriented, stream-based protocol
– IP Multicast (if time allows…)
• Facilities for delivering datagrams to multiple recipients
– We won’t discuss ICMP (Internet Control Message
Protocol), but you can look it up if you want
Where To Find More Info
• For More “Practical” Information
– Network Programming in Java
• The Java Custom Networking Trail
http://java.sun.com/docs/books/tutorial/networking/sockets/
http://java.sun.com/docs/books/tutorial/networking/datagrams/
– Network Programming in C
• Books by W. Richard Stevens [HIGHLY recommended!]
– “TCP/IP Illustrated” Series
– UNIX Network Programming, Vol. 1
– Kernel Source – “Real” Protocol Stacks
• Linux TCP/IP Stack
– http://www.kernel.org/pub/linux/kernel/v2.4/
• OpenBSD TCP/IP Stack
– ftp://ftp.openbsd.org/pub/OpenBSD/src/sys/netinet/
Where to Find More Info
• Papers, Lecture Notes and RFC’s
– TCP Congestion Control
• Van Jacobson, “Congestion Avoidance and
Control”, 1988
• Internet RFC Series:
http://www.rfc-editor.org/
– CS514 - Fall 2000 Lecture Notes
– Birman, Kenneth. Building Secure and
Reliable Network Applications. 1995.
First, some definitions…
• Keep the OSI Layers in mind!
• Address
– An identifier, following an addressing convention,
which allows a machine to be uniquely identified
• MAC Address, or Hardware Address
– Numeric address used by Ethernet (data-link layer)
– Might look like: “00:02:2D:08:68:F8”
• IP Address
– Numeric address used by IP (network layer)
– Might look like: “128.84.133.221”
First, some definitions…
• Packet, or Datagram
– self-contained unit of information
– consists of a header and body
• Packet Header
– For now, realize that it includes source
address, destination address
– With layered model, “nesting” of headers
First, some definitions…
• Local Area Network (LAN)
– Group of machines sharing a common
communications medium (such as Ethernet)
– High data rates, “private wires”, shorter distances
• Wide Area Network (WAN)
– spans a greater geographic area, may depend on
publicly available network structures
(telephone system, leased lines, satellites…)
First, some definitions…
• Router
– Machine that moves packets from one network to a
network that is closer to the destination
– (Based on a routing table, which may change)
• Bridge
– A machine that “indiscriminantly” replicates packets
between two LANs
– typically “not as smart” but faster than a router
• Gateway
– A machine that routes packets from the LAN to the
WAN (What is a Firewall?)
First, some definitions…
• Port
– In UDP and TCP, a number which the kernel uses
to deliver datagrams to the appropriate
application
– For instance: HTTP is port 80, SMTP is port 25,
Telnet is port 23, DNS is port 53, FTP is port 21
• In this model, receivers agree to wait for
datagrams on a specified port
• Socket: {address, port}
The Internet
• A network based on the Internet
Protocol (IP)
= Router
The Internet
• Routes IP Datagrams from point A to
point B … [unreliably]
B: 128.84.154.132
A: 171.64.14.203
= Router
Unreliably?
• What good is that?
• Packet loss rate is extremely low (<<
1%)
• Packets usually dropped by overloaded
routers (as we’ll see later)
• This is good enough for us to build the
User Datagram Protocol (UDP)
UDP
• For applications where IP guarantees of
reliability are good-enough
– Streaming multimedia, stock quotes…
• Extends IP packet with source port,
destination port
• In addition, provides fragmentation
(and checksum)
Fragmentation in UDP
• Very simple: splits large UDP datagram into
multiple IP datagrams, each with a sequence
number
• Marks “fragmented” bit in the UDP header
• If one fragment is lost, the whole UDP packet
is discarded
• UDP datagrams are discarded if checksum
fails
The UDP API
• No-frills! Basically, you:
– Create a socket {address, port}
– Send data to a remote socket
– Receive data on a given socket
• No guarantees about reliability, or even
the ordering in which datagrams are
received
• How can we get around this?
Adding Reliability to UDP
• Timeouts & Acknowledgements
– Receiver sends acks of received datagrams
– If sender does not receive ack within a certain
time, retransmit the packet
• Sequence Numbers
– Sender marks datagrams with sequence numbers
– Receiver uses sequence numbers to restore order
to the datagrams, and ignore duplicates
• What if we have 100 or more concurrent
applications? Is this efficient?
TCP
• A TCP connection is defined by:
– { src_addr, src_port, dst_addr, dst_port }
– Note symmetry at both ends of connection
– Thus, sender is a receiver and vice-versa
• The goal: a reliable, stream-based, connection-
oriented protocol
– Reliable: data gets through [or connection breaks]
– Stream-based: imagine reading a file in-order
– Connection-oriented: point-to-point
• How is it all done?
Vivek Presents …
• The inner workings of the TCP
protocol…
• Any questions before we move on?
TCP
• TCP – Stream Protocol
• 3-way Handshake
• Closing a connection
• Acknowledgments
• Sliding Window
• Flow Control
• RED
TCP -- Stream Protocol
• Connection oriented
• like a telephone connection
• Needs set up before the transfer starts.
• Reliable, point to point communication.
• In order delivery
• No loss or duplication.
• Flow Control and error correction
• Duplex connections
3 Way Hand Shake
TCP is connection Oriented A
Syn B
Connection initiated by a
3 - way handshake Syn, Ack Of Syn
Takes 3 packets
Protection against duplicate Ack Of Syn
Syn Packets
Basic 3 Way Handshake
TCP A TCP B
SEQ ACK CTL
1. CLOSED LISTEN
Initially Empty
Initially Empty
Sliding Window
m[i]
m[i]
Empty
Sliding Window
ack
m[i] m[i+1]
Sliding Window
m[i] ack
m[i+1]
Have been acked
m[i+2] m[i+3]
TCP Congestion Control
• Dynamically adjust window size
• Sender should not swamp the receiver – both
sides advertise maximum window size
• Linear increase -- When packets are getting
through, increment the window size by 1.
• When a packet is dropped, halve the window
size, and double the retransmission timeouts
-- exponential backoff.
• Also called TCP fairness/friendliness
TCP Slow start
• Might take some time to get to the
maximum possible window size
Optimization:
• Exponential increase to start with.
• Then follow the linear increase
exponential back off when the first
packet is lost
RED
• Random Early Detection
• Idea is very simple
• Router senses that load is increasing
• It simply notices that it has less
available memory for buffering
• This is because packets are entering
faster than they can be forwarded
RED …
• Picks a packet at random and discards it
• Even though perhaps it could be forwarded
• Receiver detects the loss and sends a NACK
• The network isn’t completely overloaded yet
so the NACK gets through
• Sender chokes back
Sunny Presents
• IP Multicast …
• Any questions before we move on?
• Note: Slides were stolen from CS514
FA2000 Web site
Unicast to multiple hosts
Multicast to multiple hosts
“to group”
Why do multicast?
• Send to a group, not to individual hosts
– Reduces overhead in sender
– Reduces bandwidth consumption in
network
– Reduces latency seen by receivers (all
receive “at the same time”, in theory)
Logical addressing
• Multicast groups “handled by network”
• Senders, receivers do not need to know
each others’ identities
• Group persists as long as it has at least
one member
• a “rendezvous” mechanism
Applications
• Teleconferencing
• Distance learning
• Multimedia streaming
• Directory service lookup
• ...
Multicasting for resource
location
• Expanding-ring search
• We want to find an instance of a
resource (database, etc) which is close
by
• Use multicast with IP time-to-live (TTL)
values
Time-to-live and hop counts
• TTL is a counter in the packet header
– Decrement at each “hop” through a router
– When TTL reaches zero, the packet is
dropped
– special values for “global” and “regional”
TTL (use with care!)
Expanding-ring search
“Find me a database”, TTL=1
Expanding-ring search
“Find me a database”, TTL=2
wasted!
Internet
“Who is a member?”
IGMP
Internet
Internet