Presentation on theme: "UDP—User Datagram Protocol"— Presentation transcript:
1 UDP—User Datagram Protocol An unreliable, connectionless transport layer protocolUDP format. See pictureTwo 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
2 Back to UDP—User Datagram Protocol UDP datagramSource Port Destination PortUDP Length UDP ChecksumDataBack to UDP—User Datagram ProtocolFigure 8.16
3 Back to UDP—User Datagram Protocol UDP pseudoheaderSource IP AddressDestination IP AddressProtocol = UDP Length1.Pseudoheader is to ensure that the datagram has indeedreached the correct destination host and port.2. The padding of 0s and pseudoheader is only for thecomputation of checksum and not be transmitted.Figure 8.17
4 TCP—transmission control protocol TCP functionalityProvides connection-oriented, reliable, in-sequence, byte-stream serviceProvides a logical full-duplex (two way) connectionProvides flow-control by advertised window.Provides congestion control by congestion window.Support multiple applications in the same end systems.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.
5 TCP operations TCP delivers byte stream.See picture TCP deals with old packets from old connections by several methods. See pictureTCP uses sliding-window to implement reliable transfer of byte stream. See pictureTCP uses advertised window for flow control.Adaptive timer: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 round-trip-time, dRTT is average of deviation.TCP uses congestion window for congestion control. See picture
7 An old segment could not be distinguished from current ones Host AHost BSYN, Seq_no = nSYN, Seq_no = n, ACK, Ack_no = n+1Seq_no = n+1, ACK, Ack_no = n+1Delayed segment withSeq_no = n+2will be acceptedQuestion: How does TCP prevent old packets of old connections?Using long (32 bit) sequence numberRandom initial sequence number-- 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!!Back to TCP operationsFigure 8.23
8 Back to TCP operations TCP uses Selective-Repeat ARQ … … … ReceiverTransmitterReceive WindowSend WindowRlast+WR+1Slast+WS-1Rlast……….........Octetstransmittedand ACKedRnextRnewSlastSlast+WA-1SrecentAdvertised windowRlast highest-numbered octet not yet read by the applicationRnext next expected octetRnew highest numbered octet receivedcorrectlyRlast+WR-1 highest-numbered octet that can be accommodated in receive bufferSlast oldest unacknowledged octetSrecent highest-numbered transmitted octetSlast+WA-1 highest-numbered octet that can be transmittedSlast+WS-1 highest-numbered octet that can be accepted from the applicationNote: 1. Rnew highest bytes received correctly, which are out-of sequence bytes.2. Advertised window WA: Srecent – Slast WA =WR – ( Rnew – Rlast)Back to TCP operationsFigure 8.19
9 Dynamics of TCP congestion window Congestion occursCongestion20avoidance15CongestionwindowThreshold10Slowstart5Round-trip timesBack to TCP operationsFigure 7.63
10 TCP protocol TCP segment See Segment format TCP pseudoheader. See pseudoheaderTCP connection establishment. See establishmentClient-server application See socketTCP Data transferSliding window with window sliding on byte basisFlow control and piggybacking See flow controlTCP connection terminationAfter receiving ACK for previous data, but no more data to send, the TCP will terminate the connection in its direction by issuing an FIN segment. Graceful terminationTCP state transition diagram
11 TCP segment format Back to TCP protocol Source Port Destination PortSequence NumberAcknowledgement NumberUAPRSFHeaderReservedRCSSYI(Advertised) Window SizeLengthGKHTNNChecksum Urgent PointerOptions PaddingData1.SYN: request to set a connection 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).Figure 8.20
12 Back to TCP protocol TCP pseudoheader Source IP AddressDestination IP AddressProtocol = TCP Segment LengthThe padding of 0s and pseudoheader is only used in computationof checksum but not be transmitted, as in UDP checksum.Figure 8.21
13 Three-way handshake to set up connection Back to TCP protocolHost AHost BRandom initial SNInitial SNs in twodirections are different3. Initial SNs for twoconnections are different.4. It should be clear here thatwhat setting up connectionmeans:both A and B know thatthey will exchange data,and go into ready state tosend and receive data.Most important is thatthey agree upon theinitial SNs.SYN, Seq_no = xSYN, Seq_no = y, ACK, Ack_no = x+1Seq_no = x+1, ACK, Ack_no = y+1Three-way handshake to set up connectionFigure 8.22
14 Back to TCP protocol Host B (Server) Host A (Client) socket bind listenaccept (blocks)socketconnect (blocks)SYN, Seq_no = xSYN, Seq_no = y, ACK, Ack_no = x+1connect returnsSeq_no = x+1, ACK, Ack_no = y+1writeread (blocks)accept returnsread (blocks)request messageread returnswriteread (blocks)reply messageread returnsFigure 8.24
15 TCP window flow control Host AHost Bt0Seq_no = 1, Ack_no = 2000, Win = 2048, No Datat1Seq_no = 2000, Ack_no = 1, Win = 1024, Data =t2Seq_no = 3024, Ack_no = 1, Win = 1024, Data =t3Seq_no = 1, Ack_no = 4048, Win = 512, Data = 1-128t4Seq_no = 4048, Ack_no = 129, Win = 1024, Data =Back to TCP protocolFigure 8.25
16 TCP graceful termination Back to TCP protocolTCP graceful terminationHost AHost BQuestion: is terminationeasier than establishment?Or to say, is it possiblethat a connection is closedwhen both of two partiesconfirm with each other?FIN, seq = 5086ACK = 5087Data (150 bytes), seq. = 303, ACK = 5087ACK = 453No, Saying goodbyeis hard to do.Famous blue-redarmies problem.FIN, seq. =453, ACK = 5087ACK = 454Figure 8.27
17 Thick lines: normal client states Dashed lines: normal server states CLOSEDpassive open,create TCBapplic.closeactive open,create TCBsend SYNreceive SYN,send SYN, ACKLISTENreceiveRSTsend SYNapplic. closeor timeout,delete TCBSYN_RCVDreceive SYN,send ACKSYN_SENTreceiveACKreceive SYN, ACK,send ACKapplic.close,sendFINESTABLISHEDreceive FIN,send ACKapplic. close,send FINCLOSE_WAITreceive FINsend ACKapplic. closesend FINFIN_WAIT_1CLOSINGreceiveACKLAST_ACKreceiveACKreceiveACKreceive FIN, ACKsend ACKreceive FINsend ACKBack to TCP protocol2MSL timeoutdelete TCBFIN_WAIT_2TIME_WAITFigure 8.28
18 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 hoursT-3 line, (2328)/(45 106) = 12 minutesOC-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.
19 Internet routing protocols Autonomous system (AS)A set of routers or networks technically administrated by a single organization.No restriction that an AS must run a single routing protocolOnly requirement is that from outside, an AS presents a consistent picture of which ASs are reachable through it.Three types of ASs:Stub AS: has only a single connection to outside.Multihomed AS: has multiple connections to outside, but refuses to carry out transit trafficTransit AS: multiple connections to outside and carry transit traffic.ASs need to be assigned globally unique AS number (ASN)
20 Classification of Internet routing protocols IGP (Interior Gateway Protocol):For routers to communicate within an AS and relies on IP address to construct paths.Provides a map of a county dealing with how to reach each building.RIP (Routing Information Protocol): distance vectorOSPF (Open Shortest Path First): link stateEGP (Exterior Gateway Protocol):For routers to communicate among different ASs and relies on AS numbers to construct AS paths.Provides a map of a country, connecting each county.BGP (Border Gateway Protocol): (distance) path vector
21 RIP—Routing Information Protocol Distance vectorOn top of UDP with port #520Metric is number of hopsMaximum number of hops is 15, 16 stands for infinityUsing split-horizon with poisoned reverse.May speed up convergence by triggered updates.Routers exchange distance vector every 30 secondsIf a router does not receive distance vector from its neighbor X within 180 seconds, the link to X is considered broken and the router sets the cost to X is 16 (infinity).RIP-2 contains more information: subnet mask, next hop, routing domain, authentication, CIDR
22 RIP message formatCommand VersionZeroAddress Family Identifier ZeroIP AddressMetric. . .Command: 1: request other routers to send routing information2: a response containing its routing information2. Version: 1 or 23. Up to 25 routing information message3.1 Family identifier: only 2 for IP address3.2 IP address: can be a host address or a network address3.3 Metric: 1— indicates infinityProblems of RIP: not scalable, slow convergence, counting-to-infinity,therefore replaced By OSPF in 1979.Figure 8.32
23 Internet multicastA packet is to be sent to multiple hosts with the same multicast addressClass D multicast addresses: e.g.,all systems on a LANall routers on a LANall OSPF routers on a LANall designated OSPF routers on a LANIt 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 linkIGMP (Internet Group Management Protocol): allow a user to join a multicast group and let routers collect multicast group membership information.
24 Multicasting Source S sends packets to multicast group G1 G1 7 2 5 8 S 345678G2Source S sends packets to multicast group G1
25 Multicast RoutingMulticast routing useful when a source wants to transmit its packets to several destinations simultaneouslyRelying on unicast routing by transmitting each copy of packet separately works, but can be very inefficient if number of destinations is largeTypical applications is multi-party conferencing over the InternetExample: Multicast Backbone (MBONE) uses reverse path multicasting
26 Reverse-Path Broadcasting (RPB) Fact: Set of shortest paths to the source node S forms a tree that spans the networkApproach: Follow paths in reverse directionAssume each router knows current shortest path to SUpon receipt of a multicast packet, router records the packet’s source address and the port it arrives onIf shortest path to source is through same port (“parent port”), router forwards the packet to all other portsElse, drops the packetLoops are suppressed; each packet forwarded by a router exactly onceImplicitly assume shortest path to source S is same as shortest path from sourceIf paths asymmetric, need to use link state info to compute shortest paths from S
27 Example: Shortest Paths from S G1G312345678G2Spanning tree of shortest paths to node S and parent ports are shown in blue
28 Example: S sends a packet G1G117232423421152533G14821S114G1354224136321134G23G3G3S sends a packet to node 1Node 1 forwards to all ports, except parent port
29 Example: Hop 1 nodes broadcast G1G117232423421152533G14821S141G1354224136321134G23G3G3Nodes 2, 3, 4, and 5 broadcast, except on parent portsAll nodes, not only G1, receive packets
30 Example: Broadcast continues G1G117232423421152533G14821S114G1354224136321134G23G3G3Truncated RPB (TRPB): Leaf routers do not broadcast if none of its attached hosts belong to packet’s multicast group
31 Internet Group Management Protocol (IGMP) Host can join a multicast group by sending an IGMP message to its routerEach multicast router periodically sends an IGMP query message to check whether there are hosts belonging to multicast groupsHosts respond with list of multicast groups they belong toHosts randomize response time; cancel response if other hosts reply with same membershipRouters determine which multicast groups are associated with a certain portRouters only forward packets on ports that have hosts belonging to the multicast group
32 Multicast programming 2.1 Multicast addresses.2.2 Levels of conformance.0: no, 1: sending, 2: receiving2.3 Sending Multicast Datagrams.Open UDP socket, and send to multicast addressTTL0 Restricted to the same host.1 Restricted to the same subnet.<32 Restricted to the same site, organization or department.<64 Restricted to the same region.<128 Restricted to the same continent.<255 Unrestricted in scope. Global.2.4 Receiving Multicast Datagrams.Joining multicast groupDrop multicast groupMapping of IP Multicast Addresses to Ethernet/FDDI addresses.
33 Multicast functionsint 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 yes yesIP_MULTICAST_TTL yes yesIP_MULTICAST_IF yes yesIP_ADD_MEMBERSHIP yes noIP_DROP_MEMBERSHIP yes no
34 Simplified header format: IPv6 (IPng): IPv4 is very successful but the victim of its own success.Longer address field:128 bits can support up to 3.4 x 1038 hostsSimplified header format:Simpler format to speed up processing of each headerAll fields are of fixed sizeIPv4 vs IPv6 fields:Same: VersionDropped: Header length, ID/flags/frag offset, header checksumReplaced:Datagram length by Payload lengthProtocol type by Next headerTTL by Hop limitTOS by traffic classNew: Flow label
35 Other IPv6 FeaturesFlexible support for options: more efficient and flexible options encoded in optional extension headersFlow label capability: “flow label” to identify a packet flow that requires a certain QoSSecurity: built-in authentication and confidentialityLarge 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 pathNo checksum field: removed to reduce packet processing time in a router
36 Payload Length Next Header Hop Limit IPv6 Header FormatVersion Traffic ClassFlow LabelPayload Length Next Header Hop LimitSource AddressDestination AddressVersion field same size, same locationTraffic class to support differentiated servicesFlow: sequence of packets from particular source to particular destination for which source requires special handling
37 Payload Length Next Header Hop Limit IPv6 Header FormatVersion Traffic ClassFlow LabelPayload Length Next Header Hop LimitSource AddressDestination AddressPayload length: length of data excluding header, up to BNext header: type of extension header that follows basic headerHop limit: # hops packet can travel before being dropped by a router
38 IPv6 Addressing Address Categories Hexadecimal notation Unicast: single network interfaceMulticast: 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 notationGroups of 16 bits represented by 4 hex digitsSeparated by colons4BF5:AA12:0216:FEBC:BA5F:039A:BE9A:2176Shortened forms:4BF5:0000:0000:0000:BA5F:039A:000A:2176To 4BF5:0:0:0:BA5F:39A:A:2176To 4BF5::BA5F:39A:A:2176Mixed notation:::FFFF:
40 Address Types based on Prefixes Binary prefixTypesPercentage of address spaceReserved0.39UnassignedISO network addresses0.78IPX network addresses0000 13.1200016.2500112.5010Provider-based unicast addresses011100Geographic-based unicast addresses10111011101111 01.560.2Link local use addresses0.098Site local use addressesMulticast addresses
41 Special Purpose Addresses 010 Registry ID Provider ID Subscriber ID Subnet ID Interface IDn bitsm bitso bitsp bits(125-m-n-o-p) bitsProvider-based Addresses: 010 prefixAssigned by providers to their customersHierarchical structure promotes aggregationRegistry ID: ARIN, RIPE, APNICISPSubscriber ID: subnet ID & interface IDLocal Addresses: do not connect to global InternetLink-local: for single linkSite-local: for single siteDesigned to facilitate transition to connection to Internet
42 Special Purpose Addresses Unspecified Address: 0::0Used by source station to learn own addressLoopback Address: ::1IPv4-compatible addresses: 96 0’s + IPv4For tunneling by IPv6 routers connected to IPv4 networks::IP-mapped addresses: 80 0’s ’s + IPv4Denote IPv4 hosts & routers that do not support IPv6
43 Migration from IPv4 to IPv6 Gradual transition from IPv4 to IPv6Dual IP stacks: routers run IPv4 & IPv6Type field used to direct packet to IP versionIPv6 islands can tunnel across IPv4 networksEncapsulate user packet insider IPv4 packetTunnel endpoint at source host, intermediate router, or destination hostTunneling can be recursive
44 Migration from IPv4 to IPv6 SourceDestinationIPv6 networkIPv4 networkTunnelTunnel head-endTunnel tail-endIPv6 headerIPv4 header(a)SourceDestinationIPv6 networkLink(b)
45 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 messageThe host selects one IP address and broadcasts a DHCP request message including the IP addressThe 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 networkIf T expires, the host relinquishes the IP address and reapply from scratch.
46 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.
47 Deliver packets to mobile host through home agent and foreign agent Foreign networkHome networkForeign agentMobile host2Home agentInternet31Correspondent hostFigure 8.29