CSE/EE 461 Lecture 14. Connections. Last Time. This Time. We began on the Transport layer. Focus How do we send information reliably?

Similar documents
Connections. Topics. Focus. Presentation Session. Application. Data Link. Transport. Physical. Network

CSE 461 Module 11. Connections

CSE 461 Connections. David Wetherall

Some slides courtesy David Wetherall. Communications Software. Lecture 4: Connections and Flow Control. CSE 123b. Spring 2003.

CSEP 561 Connections. David Wetherall

CSEP 561 Connections. David Wetherall

Last Class. CSE 123b Communications Software. Today. Naming Processes/Services. Transmission Control Protocol (TCP) Picking Port Numbers.

CSE 461 The Transport Layer

CSE/EE 461 Lecture 12 TCP. A brief Internet history...

Transport Layer (TCP/UDP)

CSCI-1680 Transport Layer I Rodrigo Fonseca

CSCI-1680 Transport Layer I Rodrigo Fonseca

Chapter 5 End-to-End Protocols

Application Service Models

CSE/EE 461 Lecture 13 Connections and Fragmentation. TCP Connection Management

User Datagram Protocol

Operating Systems and Networks. Network Lecture 8: Transport Layer. Where we are in the Course. Recall. Transport Layer Services.

Operating Systems and Networks. Network Lecture 8: Transport Layer. Adrian Perrig Network Security Group ETH Zürich

What s an API? Do we need standardization?

Internet transport protocols

SWITCHING, FORWARDING, AND ROUTING

Introduc)on to Computer Networks

TCP Overview. Connection-oriented Byte-stream

CS 43: Computer Networks. 18: Transmission Control Protocol October 12-29, 2018

UNIX Sockets. Developed for the Azera Group By: Joseph D. Fournier B.Sc.E.E., M.Sc.E.E.

CS419: Computer Networks. Lecture 10, Part 2: Apr 11, 2005 Transport: TCP mechanics (RFCs: 793, 1122, 1323, 2018, 2581)

Network Communication

Processes communicating. Network Communication. Sockets. Addressing processes 4/15/2013

Socket Programming for TCP and UDP

Tutorial on Socket Programming

EEC-484/584 Computer Networks

sottotitolo Socket Programming Milano, XX mese 20XX A.A. 2016/17 Federico Reghenzani

UNIT V. Computer Networks [10MCA32] 1

Lecture 22: TCP & NAT. CSE 123: Computer Networks Alex C. Snoeren

Transport Layer Marcos Vieira

Islamic University of Gaza Faculty of Engineering Department of Computer Engineering ECOM 4021: Networks Discussion. Chapter 5 - Part 2

Lecture 7. Followup. Review. Communication Interface. Socket Communication. Client-Server Model. Socket Programming January 28, 2005

CS 356: Computer Network Architectures. Lecture 17: End-to-end Protocols and Lab 3 Chapter 5.1, 5.2. Xiaowei Yang

Chapter 6. The Transport Layer. Transport Layer 3-1

Reliable Byte-Stream (TCP)

ECE 650 Systems Programming & Engineering. Spring 2018

Lecture 2. Outline. Layering and Protocols. Network Architecture. Layering and Protocols. Layering and Protocols. Chapter 1 - Foundation

Programming with TCP/IP. Ram Dantu

End-to-End Protocols. End-to-End Protocols

Transport Layer. Gursharan Singh Tatla. Upendra Sharma. 1

TCP. TCP: Overview. TCP Segment Structure. Maximum Segment Size (MSS) Computer Networks 10/19/2009. CSC 257/457 - Fall

UDP and TCP. Introduction. So far we have studied some data link layer protocols such as PPP which are responsible for getting data

Review. Preview. Closing a TCP Connection. Closing a TCP Connection. Port Numbers 11/27/2017. Packet Exchange for TCP Connection

Outline Computer Networking. Functionality Split. Transport Protocols

Introduction to Socket Programming

STUDY OF SOCKET PROGRAMMING

Session NM056. Programming TCP/IP with Sockets. Geoff Bryant Process software

Internet Protocols Fall Outline

Outline. Distributed Computing Systems. Socket Basics (1 of 2) Socket Basics (2 of 2) 3/28/2014

CS457 Transport Protocols. CS 457 Fall 2014

TCP/IP Networking. Part 4: Network and Transport Layer Protocols

ELEC / COMP 177 Fall Some slides from Kurose and Ross, Computer Networking, 5 th Edition

Oral. Total. Dated Sign (2) (5) (3) (2)

QUIZ: Longest Matching Prefix

Information Network 1 TCP 1/2

Mobile Transport Layer Lesson 02 TCP Data Stream and Data Delivery

Group-A Assignment No. 6

UNIT IV TRANSPORT LAYER

TCP: Three-way handshake

Networked Applications: Sockets. End System: Computer on the Net

Lenuta Alboaie Computer Networks

Transport Layer. The transport layer is responsible for the delivery of a message from one process to another. RSManiaol

Computer Network Programming. The Transport Layer. Dr. Sam Hsu Computer Science & Engineering Florida Atlantic University

Socket Programming. #In the name of Allah. Computer Engineering Department Sharif University of Technology CE443- Computer Networks

TRANSMISSION CONTROL PROTOCOL. ETI 2506 TELECOMMUNICATION SYSTEMS Monday, 7 November 2016

EEC-682/782 Computer Networks I

OSI Transport Layer. objectives

Introduc)on to Computer Networks

NETWORK PROGRAMMING. Instructor: Junaid Tariq, Lecturer, Department of Computer Science

Socket Programming. CSIS0234A Computer and Communication Networks. Socket Programming in C

Outline. Operating Systems. Socket Basics An end-point for a IP network connection. Ports. Network Communication. Sockets and the OS

6. The Transport Layer and protocols

Outline. Distributed Computer Systems. Socket Basics An end-point for a IP network connection. Ports. Sockets and the OS. Transport Layer.

Application. Transport. Network. Link. Physical

COMPUTER NETWORKS CS CS 55201

COMPUTER NETWORKS CS CS 55201

Elementary TCP Sockets

CSC 634: Networks Programming

Transport Layer. <protocol, local-addr,local-port,foreign-addr,foreign-port> ϒ Client uses ephemeral ports /10 Joseph Cordina 2005

End-to-End Protocols: UDP and TCP. Hui Chen, Ph.D. Dept. of Engineering & Computer Science Virginia State University Petersburg, VA 23806

The Fundamentals. Port Assignments. Common Protocols. Data Encapsulation. Protocol Communication. Tevfik Ko!ar

CS 455: INTRODUCTION TO DISTRIBUTED SYSTEMS [NETWORKING] Frequently asked questions from the previous class surveys

Ports under 1024 are often considered special, and usually require special OS privileges to use.

TSIN02 - Internetworking

Lecture 11: IP routing, IP protocols

Sockets 15H2. Inshik Song

Agenda. Before we start: Assignment #1. Routing in a wide area network. Protocols more concepts. Internetworking. Congestion control

Networking Technologies and Applications

Computer Networks. Transmission Control Protocol. Jianping Pan Spring /3/17 CSC361 1

Transport Layer Review

Transport Layer (TCP/UDP)

TSIN02 - Internetworking

TCP: Transmission Control Protocol RFC 793,1122,1223. Prof. Lin Weiguo Copyleft 2009~2017, School of Computing, CUC

Application Programming Interfaces

TSIN02 - Internetworking

Transcription:

CSE/EE 461 Lecture 14 Connections Last Time We began on the Transport layer Focus How do we send information reliably? Topics ARQ and sliding windows Application Presentation Session Transport Network Data Link Physical sdg // CSE/EE 461, Fall 2005 L14.2 This Time More on the Transport Layer Focus How do we connect processes? Topics Naming processes Connection setup / teardown Flow control Application Presentation Session Transport Network Data Link Physical sdg // CSE/EE 461, Fall 2005 L14.3 1

Naming Processes/Services Process here is an abstract term for your Web browser (HTTP), Email servers (SMTP), hostname translation (DNS), RealAudio player (RTSP), etc. How do we identify for remote communication? Process id or memory address are OS-specific and transient So TCP and UDP use Ports 16-bit integers representing mailboxes that processes rent typically from OS Identify process uniquely as (IP address, protocol, port) OS converts into process-specific channel, like socket sdg // CSE/EE 461, Fall 2005 L14.4 Processes as Endpoints app stuff write(), sendto(), send() read(), recvfrom(), recv() OS stuff Socket file descriptor Socket file descriptor Protocol stuff port port sdg // CSE/EE 461, Fall 2005 L14.5 Picking Port Numbers We still have the problem of allocating port numbers What port should a Web server use on host X? To what port should you send to contact that Web server? Servers typically bind to well-known port numbers e.g., HTTP 80, SMTP 25, DNS 53, look in /etc/services Ports below 1024 reserved for well-known services Clients use OS-assigned temporary (ephemeral) ports Above 1024, recycled by OS when client finished sdg // CSE/EE 461, Fall 2005 L14.6 2

User Datagram Protocol (UDP) Provides message delivery between processes Source port filled in by OS as message is sent Destination port identifies UDP delivery queue at endpoint 0 16 31 SrcPort Checksum DstPort Length Data sdg // CSE/EE 461, Fall 2005 L14.7 UDP Delivery Ports Application process Application process Application process Kernel boundary Message Queues DeMux on Port # Packets arrive sdg // CSE/EE 461, Fall 2005 L14.8 UDP Checksum UDP includes optional protection against errors Checksum intended as an end-to-end check on delivery So it covers data, UDP header, and IP pseudoheader 0 16 31 SrcPort Checksum DstPort Length Data sdg // CSE/EE 461, Fall 2005 L14.9 3

Transmission Control Protocol (TCP) Reliable bi-directional bytestream between processes Message boundaries are not preserved Connections Conversation between endpoints with beginning and end Flow control Prevents sender from over-running receiver buffers Congestion control Prevents sender from over-running network buffers sdg // CSE/EE 461, Fall 2005 L14.10 TCP Delivery Application process Application process Write bytes Read bytes TCP TCP Send buffer Receive buffer Transmit segments Segment Segment Segment sdg // CSE/EE 461, Fall 2005 L14.11 TCP Header Format Ports plus IP addresses identify a connection 0 4 10 16 31 SrcPort DstPort SequenceNum Acknowledgment HdrLen 0 Flags Checksum AdvertisedWindow UrgPtr Options (variable) Data sdg // CSE/EE 461, Fall 2005 L14.12 4

TCP Header Format Sequence, Ack numbers used for the sliding window 0 4 10 16 31 SrcPort DstPort SequenceNum Acknowledgment HdrLen 0 Flags Checksum AdvertisedWindow UrgPtr Options (variable) Data sdg // CSE/EE 461, Fall 2005 L14.13 TCP Header Format Flags may be URG, ACK, PSH, RST, SYN, FIN 0 4 10 16 31 SrcPort DstPort SequenceNum Acknowledgment HdrLen 0 Flags Checksum AdvertisedWindow UrgPtr Options (variable) Data sdg // CSE/EE 461, Fall 2005 L14.14 TCP Header Format Advertised window is used for flow control 0 4 10 16 31 SrcPort DstPort SequenceNum Acknowledgment HdrLen 0 Flags Checksum AdvertisedWindow UrgPtr Options (variable) Data sdg // CSE/EE 461, Fall 2005 L14.15 5

Other TCP Header Fields Header length allows for variable length TCP header options for extensions such as timestamps, selective acknowledgements, etc. Checksum is analogous to that of UDP Urgent pointer/data not used in practice sdg // CSE/EE 461, Fall 2005 L14.16 TCP Connection Establishment Both sender and receiver must be ready before we start to transfer the data Sender and receiver need to agree on a set of parameters e.g., the Maximum Segment Size (MSS) This is signaling It sets up state at the endpoints Compare to dialing in the telephone network In TCP a Three-Way Handshake is used sdg // CSE/EE 461, Fall 2005 L14.17 Three-Way Handshake Opens both directions for transfer Active opener (client) SYN, SequenceNum = x Passive listener (server) SYN + ACK, SequenceNum = y, Acknowledgment = x + 1 ACK, Acknowledgment = y + 1 +data sdg // CSE/EE 461, Fall 2005 L14.18 6

Some Comments We could abbreviate this setup, but it was chosen to be robust, especially against delayed duplicates Three-way handshake from Tomlinson 1975 Choice of changing initial sequence numbers (ISNs) minimizes the chance of hosts that crash getting confused by a previous incarnation of a connection But with random ISN it actually proves that two hosts can communicate Weak form of authentication sdg // CSE/EE 461, Fall 2005 L14.19 TCP State Transitions CLOSED Passive open Close LISTEN Close Active open/syn SYN/SYN + ACK Send/ SYN SYN/SYN + ACK SYN_RCVD SYN_SENT ACK SYN + ACK/ACK Close /FIN Close /FIN FIN_WAIT_1 FIN/ACK ACK ESTABLISHED FIN/ACK CLOSE_WAIT Close /FIN FIN_WAIT_2 ACK + FIN/ACK CLOSING LAST_ACK ACK Timeout after two ACK segment lifetimes FIN/ACK TIME_WAIT CLOSED sdg // CSE/EE 461, Fall 2005 L14.20 Again, with States Active participant (client) SYN_SENT SYN, SequenceNum = x Passive participant (server) LISTEN ESTABLISHED SYN + ACK, SequenceNum = y, Acknowledgment = x + 1 SYN_RCVD ACK, Acknowledgment = y + 1 +data ESTABLISHED sdg // CSE/EE 461, Fall 2005 L14.21 7

Connection Teardown Orderly release by sender and receiver when done Delivers all pending data and hangs up Cleans up state in sender and receiver TCP provides a symmetric close both sides shutdown independently sdg // CSE/EE 461, Fall 2005 L14.22 TCP Connection Teardown FIN_WAIT_1 Web server FIN Web browser FIN_WAIT_2 TIME_WAIT CLOSED FIN ACK ACK CLOSE_WAIT LAST_ACK CLOSED sdg // CSE/EE 461, Fall 2005 L14.23 The TIME_WAIT State We wait 2MSL (two times the maximum segment lifetime of 60 seconds) before completing the close Why? ACK might have been lost and so FIN will be resent Could interfere with a subsequent connection sdg // CSE/EE 461, Fall 2005 L14.24 8

Berkeley Sockets interface Networking protocols implemented in OS OS must expose a programming API to applications most OSs use the socket interface originally provided by BSD 4.1c in ~1982. Principle abstraction is a socket a point at which an application attaches to the network defines operations for creating connections, attaching to network, sending and receiving data, closing connections sdg // CSE/EE 461, Fall 2005 L14.25 TCP (connection-oriented) Server Socket() Block until connect Process request Bind() Listen() Accept() Recv() Send() Connection Establishmt. Data (request) Data (reply) Client Socket() Connect() Send() Recv() sdg // CSE/EE 461, Fall 2005 L14.26 UDP (connectionless) Server Block until Data from client Socket() Bind() Recvfrom() Data (request) Client Socket() Bind() Sendto() Process request Data (reply) Sendto() Recvfrom() sdg // CSE/EE 461, Fall 2005 L14.27 9

Socket call Means by which an application attached to the network #include <sys/socket.h> int socket(int family, int type, int protocol) Family: address family (protocol family) AF_UNIX, AF_INET, AF_NS, AF_IMPLINK Type: semantics of communication SOCK_STREAM, SOCK_DGRAM, SOCK_RAW Not all combinations of family and type are valid Protocol: Usually set to 0 but can be set to specific value. Family and type usually imply the protocol Return value is a handle for new socket sdg // CSE/EE 461, Fall 2005 L14.28 Bind call Typically a server call Binds a newly created socket to the specified address int bind(int socket, struct sockaddr *address, int addr_len) Socket: newly created socket handle Address: data structure of address of local system IP address and port number (demux keys) Same operation for both connection-oriented and connectionless servers Can use well known port or unique port sdg // CSE/EE 461, Fall 2005 L14.29 Listen call Used by connection-oriented servers to indicate an application is willing to receive connections Int(int socket, int backlog) Socket: handle of newly creates socket Backlog: number of connection requests that can be queued by the system while waiting for server to execute accept call. sdg // CSE/EE 461, Fall 2005 L14.30 10

Accept call A server call After executing listen, the accept call carries out a passive open (server prepared to accept connects). int accept(int socket, struct sockaddr *address, int addr_len) It blocks until a remote client carries out a connection request. When it does return, it returns with a new socket that corresponds with new connection and the address contains the clients address sdg // CSE/EE 461, Fall 2005 L14.31 Connect call A client call Client executes an active open of a connection int connect(int socket, struct sockaddr *address, int addr_len) How does the OS know where the server is? Call does not return until the three-way handshake (TCP) is complete Address field contains remote system s address Client OS usually selects random, unused port sdg // CSE/EE 461, Fall 2005 L14.32 Input and Output After connection has been made, application uses send/recv to data int send(int socket, char *message, int msg_len, int flags) Send specified message using specified socket int recv(int socket, char *buffer, int buf_len, int flags) Receive message from specified socket into specified buffer Or can use read/write int read(int socket, char* buffer, int len) int write(int socket, char* buffer, int len); Or can sometimes use sendto/recvfrom Or can use sendmsg, recvmsg for scatter/gather sdg // CSE/EE 461, Fall 2005 L14.33 11

Sample Code Key Concepts We use ports to name processes in TCP/UDP Well-known ports are used for popular services Connection setup and teardown complicated by the effects of the network on messages TCP uses a three-way handshake to set up a connection TCP uses a symmetric disconnect sdg // CSE/EE 461, Fall 2005 L14.35 12