程序代做CS代考 Java Week 8: Transport Layer Contd Internet Technologies COMP90007

Week 8: Transport Layer Contd Internet Technologies COMP90007
Lecturer: Semester 2, 2021
© University of Melbourne 2020
1

UDP
n Provides a protocol whereby applications can transmit encapsulated IP datagrams without a connection establishment
n UDP transmits in segments consisting of an 8-byte header followed by the payload
n UDP headers contain source and destination ports
n Payload is handed to the process which is attached to the particular port at destination
2

UDP Contd.
n Main advantage of using UDP over raw IP is:
q the ability to specify ports for source and destination pairs, i.e., addressing for
processes
n Both source and destination ports are required – destination allows for incoming segments, source allows reply for outgoing segments
Structure of UDP header: It has ports (TSAPs), length and checksum
3

Strengths and Weaknesses of UDP
n Strengths: provides an IP interface with multiplexing/de- multiplexing capabilities and related transmission efficiencies
n Weaknesses: UDP does not include support for flow control, error control/retransmission of bad segments
n Conclusion: where applications require a precise level of control over packet flow/error/timing, UDP is a good choice as application layer can make choices
n Domain Name System over the Internet is a famous user of UDP
4

Another one with UDP: Remote Procedure Call (RPC)
n Sending a message and getting a reply back is analogous to making a function call in programming languages
n Birrell and Nelson modified this to allow programs to call procedures on remote hosts using UDP
q Remote Procedure Call (RPC)
5

Remote Procedure Call (RPC)
n To call a remote procedure, the client is bound to a small library (the client stub) that represents the server procedure in the client‘s address space.
n Similarly the server is bound with a procedure called the server stub.
n These stubs hide the fact that the procedure itself is not local.
6

RPC Illustrated
7

Transmission Control Protocol (TCP)
n Provides a protocol by which applications can transmit IP datagrams within a connection-oriented framework, thus increasing reliability
n TCP transport entity manages TCP streams and interfaces to the IP layer – can exist in numerous locations (kernel, library, user process)
n TCP entity accepts user data streams, and segments them into pieces < 64KB (often at a size in order so that the IP and TCP headers can fit into a single Ethernet frame), and sends each piece as a separate IP datagram n Recipient TCP entities reconstruct the original byte streams from the encapsulation 8 The TCP Service Model n Sender and receiver both create sockets, consisting of the IP address of the host and a port number as we saw earlier n For TCP Service to be activated, connections must be explicitly established between a socket at a sending host (src-host, src-port) and a socket at a receiving host (dest-host, dest- port) n Special one-way server sockets may be used for multiple connections simultaneously 9 Example 10 Port Allocations n RecallTSAPs n Portnumberscanrangefrom 0-65535 n Portnumbersareregulatedby IANA (http://www.iana.org/assignme nts/port-numbers) n Portsareclassifiedinto3 segments: q Well Known Ports (0-1023) q Registered Ports (1024-49151) q Dynamic Ports (49152-65535) 11 Socket Library - Multiplexing n Socket library provides a multiplexing tool on top of TSAPs to allow servers to service multiple clients n It simulates the server using a different port to connect back to the client Special server socket 12 Features of TCP Connections n TCP connections are: n Full duplex - data in both directions simultaneously n Point to point - exact pairs of senders and receivers n Byte streams, not message streams - message boundaries are not preserved n Buffer options - TCP entity can choose to buffer prior to sending or not depending on the context n TCP_NODELAYinJava n Socket.setTcpNoDelay(boolean) 13 TCP Contd n Data sent between TCP entities in segments - segment has a 20 byte header plus zero or more data bytes n TCP entities decide how large segments should be mainly with 2 constraints: q 65,515byteIPpayload q Ethernetunitsize-generally1500bytes n Sliding window - sender transmits and starts a timer n Receiver sends back an acknowledgement which is the next sequence number expected - if sender's timer expires before acknowledgement, then the sender transmits the original segment again 14 The TCP Segment Header n TCP header includes addressing (ports), sliding window (seq. / ack. number), flow control (window), error control (checksum) and more 15 The TCP Segment Header n Source port and Destination port fields identify the local end points of the connection n Sequence number and Acknowledgement number fields perform their usual functions n TCP header length tells how many 32-bit words are contained in the TCP header n Window size field tells how many bytes may be sent starting at the byte acknowledged n Checksum is also provided for extra reliability. It checksums the header, the data n Options field provides a way to add extra facilities not covered by the regular header n URG is set to 1 if the Urgent pointer is in use. The Urgent pointer is used to indicate a byte offset from the current sequence number at which urgent data are to be found 16 The TCP Segment Header n CWR and ECE are used to signal congestion when ECN (Explicit Congestion Notification) is used n ECE is set to signal an ECN-Echo to a TCP sender to tell it to slow down when the TCP receiver gets a congestion indication from the network n CWR is set to signal Congestion Window Reduced from the TCP sender to the TCP receiver so that it knows the sender has slowed down and can stop sending the ECN-Echo n The ACK bit is set to 1 to indicate that the Acknowledgement number is valid. This is the case for nearly all packets. 0 means ignore ACK number field n PSH bit indicates PUSHed data. The receiver is hereby kindly requested to deliver the data to the application upon arrival and not buffer it until a full buffer has been received 17 The TCP Segment Header n The RST bit is used to abruptly reset a connection that has become confused due to a host crash or some other reason. It is also used to reject an invalid segment or refuse an attempt to open a connection n The SYN bit is used to establish connections. The connection request has SYN = 1 and ACK = 0. The connection reply does bear an acknowledgement, so it has SYN = 1 and ACK = 1. n In essence, the SYN bit is used to denote both CONNECTION REQUEST and CONNECTION ACCEPTED, with the ACK bit used to distinguish between those two possibilities. n The FIN bit is used to release a connection. It specifies that the sender has no more data to transmit. However, after closing a connection, the closing process may continue to receive data. 18 TCP Connection Establishment and Release n Connections established using three-way handshake n Two simultaneous connection attempts results in only one connection (uniquely identified by end points) n Connections released with symmetric release n Timers used for lost connection releases 19 TCP Connection Management – Full Set of States n The full TCP connection finite state machine has more states than the simple example from earlier. 20 TCP Transition Diagram 21 TCP Transmission Policy n TCP acknowledges bytes n Receiver advertises window based on available buffer space 22