unit iii ipv6 udp

47
1 UDP—User Datagram Protocol 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

Upload: sangusajjan

Post on 14-May-2015

495 views

Category:

Education


0 download

TRANSCRIPT

  • 1.UDPUser Datagram Protocol 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

2. UDP datagram 0 16 31Source PortDestination PortUDP Length UDP ChecksumDataBack to UDPUser Datagram Protocol2 Figure 8.16 3. Back to UDPUser Datagram ProtocolUDP pseudoheader08 1631 Source IP Address Destination IP Address00000000 Protocol = 17UDP 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 the computation of checksum and not be transmitted.3 Figure 8.17 4. TCPtransmission control protocol TCP functionality Provides connection-oriented, reliable, in-sequence, byte-stream service Provides a logical full-duplex (two way) connection Provides 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 TCPentities. Most important variables are initial sequence numbers. TCP uses Selective Repeat ARQ. TCP terminates each direction of connection independently, allowing data tocontinue flowing in one direction after closing the other direction. TCP does not keep messages boundaries and treats data as byte stream. e.g, whensource sends out two chunks of data with length 400 and 600 bytes, the receivermay receive data in chunks of 300, 400, and 300 bytes, or 100 and 900 bytes. 4 5. TCP operations1. TCP delivers byte stream.See picture2. TCP deals with old packets from old connections by several methods. See picture3. TCP uses sliding-window to implement reliable transfer of byte stream. See picture4. TCP uses advertised window for flow control.5. Adaptive timer: 1. tout = tRTT+4dRTT , 2. tRTT(new) = tRTT(old) +(1- ) n , dRTT(new)= dRTT(old) + (1- )( n-tRTT) 3. 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.6. TCP uses congestion window for congestion control. See picture 5 6. TCP byte streamApplication Applicationbyte streambyte stream segmentsTransmitter ReceiverSend bufferReceive buffer ACKs 6Figure 8.18 7. An old segment could not be distinguished from current ones Host A Host BDelayed segment withSeq_no = n+2will be acceptedQuestion: How does TCP prevent old packets of old connections? Using long (32 bit) sequence number Random 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!!7Back to TCP operations Figure 8.23 8. TCP uses Selective-Repeat ARQTransmitter ReceiverReceive WindowSend WindowSlast+WS- Rlast Rlast+WR+1......1 ... Octets Rnext Rnewtransmitted Slast SrecentSlast+WA-1and ACKed Advertised window Rlast highest-numbered octet not yet readSlast oldest unacknowledged octetby the applicationSrecent highest-numbered transmitted octet Rnext next expected octetSlast+WA-1 highest-numbered octet that Rnew highest numbered octet receivedcan be transmitted correctlySlast+WS-1 highest-numbered octet that Rlast+WR-1 highest-numbered octet thatcan 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)8Back to TCP operations Figure 8.19 9. Dynamics of TCP congestion window CongestionCongestion occurs 20avoidance 15Congestion windowThreshold 10Slowstart5 0Round-trip timesBack to TCP operations9 Figure 7.63 10. TCP protocol TCP segment See Segment format TCP pseudoheader. See pseudoheader TCP connection establishment. See establishment Client-server application See socket TCP Data transfer Sliding window with window sliding on byte basis Flow control and piggybacking See flow control TCP connection termination After 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 termination TCP state transition diagram 10 11. Back to TCP protocol TCP segment format0410162431Source PortDestination Port Sequence Number Acknowledgement NumberHeader U A P R S FLength ReservedR C S S Y I(Advertised) Window Size GKH T N N Checksum Urgent Pointer OptionsPadding Data1.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 direction4. ACK: tell the receiver (or sender) that the value is the field of acknowledgment number is valid5. 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 the11Urgent Data, (the data that needs immediately delivery).Figure 8.20 12. Back to TCP protocolTCP pseudoheader 08 1631Source IP AddressDestination IP Address 00000000 Protocol = 6 TCP Segment LengthThe padding of 0s and pseudoheader is only used in computationof checksum but not be transmitted, as in UDP checksum. 12Figure 8.21 13. Back to TCP protocol Host AHost B1. Random initial SN2. Initial SNs in two directions are different3. Initial SNs for two connections are different.4. It should be clear here that what setting up connection means:both A and B know thatthey will exchange data,and go into ready state tosend and receive data. Most important is thatthey agree upon the initial SNs. Three-way handshake to set up connection 13Figure 8.22 14. Back to TCP protocol Host A (Client) Host B (Server)socketbind socket listenconnect (blocks)accept (blocks)connect returnswriteread (blocks) accept returnsread (blocks) read returnswriteread (blocks) read returns14 Figure 8.24 15. TCP window flow control Host AHost Bt0 t1 t2t3 t415Back to TCP protocol Figure 8.25 16. Back to TCP protocol TCP graceful terminationHost A Host BQuestion: is terminationeasier than establishment?Or to say, is it possiblethat a connection is closedwhen both of two partiesconfirm with each other?No, Saying goodbyeis hard to do.Famous blue-redarmies problem. 16Figure 8.27 17. Thick lines: normal client statesDashed lines: normal server statesCLOSEDpassive open,applic.create TCB closeLISTEN applic. close or timeout,SYN_RCVD receive SYN,SYN_SENTdelete TCB send ACK applic.close,ESTABLISHED sendFIN CLOSE_WAITFIN_WAIT_1CLOSINGLAST_ACKTIME_WAIT 2MSL timeoutFIN_WAIT_2delete TCB 17Back to TCP protocol Figure 8.28 18. Sequence number wraparound and timestamps Original TCP specification for MSL (MaximumSegment Lifetime) is 2 minutes. How long will it take to wrap around 32 bitsequence number when 232=4,294,967,296 byteshave been sent (maximum window size=231) T-1 line, (232 8)/(1.544 106) = 6 hours T-3 line, (232 8)/(45 106) = 12 minutes OC-48 line, (232 8)/(2.4 109) = 14 seconds !!! When sequence number wrap around, thewraparounded sequence number will confuse withprevious sequence number. Solution: optional timestamp field (32 bits) in TCPheader, thus, 232 232=264 is big enough right now.18 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 protocol Only 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 traffic Transit AS: multiple connections to outside and carry transit traffic. ASs need to be assigned globally unique AS number(ASN) 19 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 vector OSPF (Open Shortest Path First): link state EGP (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 20 21. RIPRouting Information Protocol Distance vector On top of UDP with port #520 Metric is number of hops Maximum number of hops is 15, 16 stands for infinity Using split-horizon with poisoned reverse. May speed up convergence by triggered updates. Routers exchange distance vector every 30 seconds If 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, nexthop, routing domain, authentication, CIDR 21 22. RIP message format0 8 1631Command VersionZeroAddress Family IdentifierZeroIP Address Zero ZeroMetric...1. 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: 115. 16 indicates infinityProblems of RIP: not scalable, slow convergence, counting-to-infinity22therefore replaced By OSPF in 1979. Figure 8.32 23. 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 sourcesends a separate copy for every destination. Reverse-path broadcasting / multicasting, each packet is transmittedonce per link IGMP (Internet Group Management Protocol): allow a user to join amulticast group and let routers collect multicast group membershipinformation.23 24. MulticastingG1G113 7 22 42 4 2 31 15 52 33G12 4 1 8S 1 1 34 G1 5 42241 213 6 313 4 G23G3G3 Source S sends packets to multicast group G1 24 25. Multicast Routing Multicast routing useful when a source wants totransmit its packets to several destinationssimultaneously Relying on unicast routing by transmitting eachcopy of packet separately works, but can be veryinefficient if number of destinations is large Typical applications is multi-party conferencingover the Internet Example: Multicast Backbone (MBONE) usesreverse path multicasting 25 26. Reverse-Path Broadcasting (RPB) Fact: Set of shortest paths to the source node S forms a tree that spans thenetwork Approach: Follow paths in reverse direction Assume each router knows current shortest path to S Upon receipt of a multicast packet, router records the packets sourceaddress and the port it arrives on If shortest path to source is through same port (parent port), routerforwards the packet to all other ports Else, drops the packet Loops are suppressed; each packet forwarded by a router exactly once Implicitly assume shortest path to source S is same as shortest path fromsource If paths asymmetric, need to use link state info to compute shortest pathsfrom S 26 27. Example: Shortest Paths from SG1 G1 1 3 7 2242 42 3 115 2 5 3 3 G124 1 8S 14 G1 1 35 4 22 41 2 136 3 134 G23G3 G3 Spanning tree of shortest paths to node S and parentports are shown in blue27 28. Example: S sends a packet G1 G1 1 3 7 2242 42 3 115 2 5 3 3 G124 1 8 S14 G1 1 35 4 22 41 2 136 3 134 G23G3 G3 S sends a packet to node 128 Node 1 forwards to all ports, except parent port 29. Example: Hop 1 nodes broadcastG1G1 1 3 7 2242 42 3 115 5 3 2 3 G1 24 1 81S1 3 4 G1 5 4 22 41 2 136 3 134 G23G3 G3 Nodes 2, 3, 4, and 5 broadcast, except on parent ports 29 All nodes, not only G1, receive packets 30. Example: Broadcast continues G1 G113 7 2 24 2 42 31 15 25 3 3 G1 2418S14 G11 3 5 42 2 4 1 21 36 31 34 G2 3 G3G3 Truncated RPB (TRPB): Leaf routers do not broadcast ifnone of its attached hosts belong to packets multicast group30 31. Internet Group Management Protocol (IGMP) Internet Group Management Protocol: Host can join a multicast group by sending an IGMP message to its router Each multicast router periodically sends an IGMPquery message to check whether there are hostsbelonging 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 areassociated with a certain port Routers only forward packets on ports that havehosts belonging to the multicast group 31 32. Multicast programming 2.1 Multicast addresses. 224.0.0.0---247.255.255.255 2.2 Levels of conformance. 0: no, 1: sending, 2: receiving 2.3 Sending Multicast Datagrams. Open UDP socket, and send to multicast address TTL 0 Restricted to the same host. 1 Restricted to the same subnet.