UDP
UDP
UDP
An unreliable, connectionless transport layer protocol UDP format. See picture Two additional functions beyond IP:
Demultiplexing: deliver to different upper layer entities such as DNS, RTP, SNMP based on the destination port # in the header. i.e., UDP can support multiple applications in the same end systems. (Optionally) check the integrity of entire UDP. (recall IP only checks the integrity of IP header.)
If source does not want to compute checksum, fill checksum with all 0s. If compute checksum and the checksum happens to be 0s, then fill all 1s. UDP checksum computation is similar to IP checksum, with two more:
Add extra 0s to entire datagram if not multiple of 16 bits. Add pseudoheader to the beginning of datagram. UDP pseudoheader
1
UDP datagram
31
UDP pseudoheader
0 8 16 Source IP Address Destination IP Address 00000000 Protocol = 17 UDP Length 31
1.Pseudoheader is to ensure that the datagram has indeed reached the correct destination host and port. 2. The padding of 0s and pseudoheader is only for the computation of checksum and not be transmitted.
3
Figure 8.17
TCP establishes connection by setting up variables that are used in two peer TCP entities. Most important variables are initial sequence numbers. TCP uses Selective Repeat ARQ. TCP terminates each direction of connection independently, allowing data to continue flowing in one direction after closing the other direction. TCP does not keep messages boundaries and treats data as byte stream. e.g, when source sends out two chunks of data with length 400 and 600 bytes, the receiver may receive data in chunks of 300, 400, and 300 bytes, or 100 and 900 bytes.
TCP operations
1. TCP delivers byte stream.See picture 2. TCP deals with old packets from old connections by several methods. See picture 3. TCP uses sliding-window to implement reliable transfer of byte stream. See picture 4. TCP uses advertised window for flow control. 5. Adaptive timer:
1. 2. 3. tout = tRTT+4dRTT , tRTT(new) = tRTT(old) +(1-)n , dRTT(new)=dRTT(old) + (1-)(n-tRTT) Where n is the time from transmitting a segment until receiving its ACK. , are in 0 to 1 with being 7/8 and being typically. tRTT is mean roundtrip-time, dRTT is average of deviation.
byte stream
ACKs
6
Figure 8.18
-- set a timer at the end of a connection to clear all lost packets from this connection.
As a result, that an old packet from an old connection conflicts with packets in current connection is very low!!
7
Figure 8.23
...
Rnext
Rnew
Srecent
Slast+WA-1
Advertised window Rlast highest-numbered octet not yet read Slast oldest unacknowledged octet by the application Srecent highest-numbered transmitted octet Rnext next expected octet Slast+WA-1 highest-numbered octet that Rnew highest numbered octet received can be transmitted correctly Slast+WS-1 highest-numbered octet that Rlast+WR-1 highest-numbered octet that can be accepted from the application can be accommodated in receive buffer
Note: 1. Rnew highest bytes received correctly, which are out-of sequence bytes. 2. Advertised window WA: Srecent Slast WA =WR ( Rnew Rlast)
8
Figure 8.19
15
Congestion window 10 Slow start
Threshold
0 Round-trip times
9
Figure 7.63
TCP protocol
TCP segment See Segment format
TCP pseudoheader. See pseudoheader
31
Header Length
Reserved Checksum
U A P R S F R C S S Y I GKH T N N
Options Data
Padding
1.SYN: request to set a connection. 2. RST: tell the receiver to abort the connection. 3. FIN: tell receiver this is the final segment, no more data, i.e, close the connection in this direction 4. ACK: tell the receiver (or sender) that the value is the field of acknowledgment number is valid 5. PSH: tell the receiving TCP entity to pass the data to the application immediately. 6. URG: tell the receiver that the Urgent Pointer is valid. Urgent Pointer: this pointer added to the sequence number points to the last byte of the Urgent Data, (the data that needs immediately delivery).
11
Figure 8.20
The padding of 0s and pseudoheader is only used in computation of checksum but not be transmitted, as in UDP checksum.
12
Figure 8.21
1. 2.
Random initial SN Initial SNs in two directions are different 3. Initial SNs for two connections are different. 4. It should be clear here that what setting up connection means: both A and B know that they will exchange data, and go into ready state to send and receive data. Most important is that they agree upon the initial SNs.
Host A
Host B
t0
t1
t2
t3
t4
15
Figure 8.25
Question: is termination easier than establishment? Or to say, is it possible that a connection is closed when both of two parties confirm with each other?
16
Figure 8.27
Thick lines: normal client states Dashed lines: normal server states
SYN_RCVD
applic. close, send FIN
SYN_SENT
ESTABLISHED
LAST_ACK
FIN_WAIT_2
TIME_WAIT
17
Figure 8.28
Sequence number wraparound and timestamps Original TCP specification for MSL (Maximum Segment Lifetime) is 2 minutes. How long will it take to wrap around 32 bit sequence number when 232=4,294,967,296 bytes have been sent (maximum window size=231)
T-1 line, (2328)/(1.544 106) = 6 hours T-3 line, (2328)/(45 106) = 12 minutes OC-48 line, (2328)/(2.4 109) = 14 seconds !!!
When sequence number wrap around, the wraparounded sequence number will confuse with previous sequence number. Solution: optional timestamp field (32 bits) in TCP header, thus, 232232=264 is big enough right now.
18
RIP-2 contains more information: subnet mask, next hop, routing domain, authentication, CIDR
21
8
Version Address Family Identifier
16
Zero Zero Zero Zero Metric
31
IP Address
...
1. Command: 1: request other routers to send routing information 2: a response containing its routing information 2. Version: 1 or 2 3. Up to 25 routing information message 3.1 Family identifier: only 2 for IP address 3.2 IP address: can be a host address or a network address 3.3 Metric: 115. 16 indicates infinity Problems of RIP: not scalable, slow convergence, counting-to-infinity 22 therefore replaced By OSPF in 1979. Figure 8.32
Internet multicast
A packet is to be sent to multiple hosts with the same multicast address Class D multicast addresses: e.g., 224.0.0.1 all systems on a LAN 224.0.0.2 all routers on a LAN 224.0.0.5 all OSPF routers on a LAN 224.0.0.6 all designated OSPF routers on a LAN It is not efficient to implement multicast by unicast, i.e., the source sends a separate copy for every destination. Reverse-path broadcasting / multicasting, each packet is transmitted once per link IGMP (Internet Group Management Protocol): allow a user to join a multicast group and let routers collect multicast group membership information.
23
Multicasting
G1
1 2 3
G1 7 2
3 2 1 8 4 3 4 1 5 2
2 4
1
5
4
G1
G1
1 1 3 5 4
2
1 2 1
3
3
6 3
4
G2
G3
G3
Multicast routing useful when a source wants to transmit its packets to several destinations simultaneously Relying on unicast routing by transmitting each copy of packet separately works, but can be very inefficient if number of destinations is large Typical applications is multi-party conferencing over the Internet Example: Multicast Backbone (MBONE) uses reverse path multicasting
25
Multicast Routing
G1 7 2
3 4 1 5 2
2 4
1 1
5
4
3 1
G1 G1
8
4
1 3
2
1
5 4 2 4 3 1
1 2
6 3
4
3
3
G2
G3
G3
Spanning tree of shortest paths to node S and parent 27 ports are shown in blue
3 1 5 2
G1
1
4
7 2
3
2 4
1 1
5
4
3 1
G1 G1
8
4
1 3
2
1
5 4 2 4 3 1
1 2
6 3
4
3
3
G2
G3
G3
S sends a packet to node 1 Node 1 forwards to all ports, except parent port
28
3 1 5 2
G1
1
4
7 2
3
2 4
1 1
5
4
3 1
G1 G1
8
4
1 3
2
1
5 4 2 4 3 1
1 2
6 3
4
3
3
G2
G3
G3
Nodes 2, 3, 4, and 5 broadcast, except on parent ports 29 All nodes, not only G1, receive packets
G1 7 2
3 4 1 5 2
2 4
1 1
5
4
3 1
G1 G1
8
4
1 3
2
1
5 4 2 4 3 1
1 2
6 3
4
3
3
G2
G3
G3
Truncated RPB (TRPB): Leaf routers do not broadcast if none of its attached hosts belong to packets multicast group 30
Each multicast router periodically sends an IGMP query message to check whether there are hosts belonging to multicast groups
Hosts respond with list of multicast groups they belong to Hosts randomize response time; cancel response if other hosts reply with same membership
Routers determine which multicast groups are associated with a certain port Routers only forward packets on ports that have hosts belonging to the multicast group
31
Multicast programming
2.1 Multicast addresses.
224.0.0.0---247.255.255.255
Multicast functions
int getsockopt(int s, int level, int optname, void* optval, int* optlen); int setsockopt(int s, int level, int optname, const void* optval, int optlen); setsockopt() getsockopt()
IP_MULTICAST_LOOP IP_MULTICAST_TTL IP_MULTICAST_IF IP_ADD_MEMBERSHIP yes IP_DROP_MEMBERSHIP yes yes yes yes no no yes yes yes
http://www.ibiblio.org/pub/Linux/docs/HOWTO/o ther-formats/html_single/MulticastHOWTO.html#ss2.1
33
IPv6 (IPng): IPv4 is very successful but the victim of its own success.
Flexible support for options: more efficient and flexible options encoded in optional extension headers Flow label capability: flow label to identify a packet flow that requires a certain QoS Security: built-in authentication and confidentiality Large packets: supports payloads that are longer than 64 K bytes, called jumbo payloads. Fragmentation at source only: source should check the minimum MTU along the path No checksum field: removed to reduce packet 35 processing time in a router
Version
Traffic Class
Payload Length
Flow Label
Next Header Hop Limit
Source Address
Destination Address
Version field same size, same location Traffic class to support differentiated services Flow: sequence of packets from particular source to particular 36 destination for which source requires special handling
Version
Traffic Class
Payload Length
Flow Label
Next Header Hop Limit
Source Address
Destination Address
Payload length: length of data excluding header, up to 65535 B Next header: type of extension header that follows basic header Hop limit: # hops packet can travel before being dropped by a router
37
Address Categories
IPv6 Addressing
Unicast: single network interface Multicast: group of network interfaces, typically at different locations. Packet sent to all. Anycast: group of network interfaces. Packet sent to only one interface in group, e.g. nearest.
Hexadecimal notation
Groups of 16 bits represented by 4 hex digits Separated by colons
4BF5:AA12:0216:FEBC:BA5F:039A:BE9A:2176
Shortened forms:
4BF5:0000:0000:0000:BA5F:039A:000A:2176 To 4BF5:0:0:0:BA5F:39A:A:2176 To 4BF5::BA5F:39A:A:2176
Mixed notation:
::FFFF:128.155.12.198
38
Example
39
0000 010
0000 011 0000 1 0001 001 010 011 100 101 110 1110
0.78
0.78 3.12 6.25 12.5 12.5 12.5 12.5 12.5 12.5 6.25
1111 0
1111 10 1111 110 1111 1110 0 1111 1110 10 1111 1110 11
Unassigned
Unassigned Unassigned Unassigned Link local use addresses Site local use addresses
3.12
1.56 0.78 0.2 0.098 0.098
40
Provider-based Addresses: 010 prefix Assigned by providers to their customers Hierarchical structure promotes aggregation Registry ID: ARIN, RIPE, APNIC ISP Subscriber ID: subnet ID & interface ID Local Addresses: do not connect to global Internet Link-local: for single link Site-local: for single site Designed to facilitate transition to connection to Internet
41
43
IPv4 header
IPv6 network
Source Link
Destination
DHCP (Dynamic Host Configuration Protocol) A host broadcasts a DHCP discovery message in its physical network for an IP address. Server(s) reply with DHCP offer message The host selects one IP address and broadcasts a DHCP request message including the IP address The selected server allocates the IP address and sends back a DHCP ACK message with a lease time T, two thresholds T1 (=0.5T), T2(=0.875T)
when T1 expires, the host asks the server for extension. If T2 expire, the host broadcasts DHCP request to any server on the network If T expires, the host relinquishes the IP address and reapply from scratch.
45
Mobile IP
Mobile host, home agent, foreign agent If mobile host is currently at the same network with HA (home agent), the packet to the mobile host will be broadcast to it. If mobile host moves to another network, the mobile host will register itself with FA (foreign agent) and gets a new care-of IP address. Then packet is sent to HA, which will forward to the FA and FA continues to forward to destination.
46
Deliver packets to mobile host through home agent and foreign agent
Foreign network Home network Foreign agent 2 Home agent Internet 3 1 Correspondent host
Mobile host
47
Figure 8.29