Chapter 2 Transport Layer Protocols TCP UDP SCTP

Slides:



Advertisements
Similar presentations
Introduction to Sockets Jan Why do we need sockets? Provides an abstraction for interprocess communication.
Advertisements

TCP - Part I Relates to Lab 5. First module on TCP which covers packet format, data transfer, and connection management.
CCNA – Network Fundamentals
UDP & TCP Where would we be without them!. UDP User Datagram Protocol.
1 TCP - Part I Relates to Lab 5. First module on TCP which covers packet format, data transfer, and connection management.
1 CS 4396 Computer Networks Lab Transmission Control Protocol (TCP) Part I.
Netprog: TCP Details1 TCP Details. Netprog: TCP Details2 TCP Lingo When a client requests a connection, it sends a “SYN” segment (a special TCP segment)
Lecture 6 TCP Socket Programming CPE 401 / 601 Computer Network Systems slides are modified from Dave Hollinger.
CSCE 515: Computer Network Programming TCP Details Wenyuan Xu Department of Computer Science and Engineering.
Netprog: TCP Details1 TCP Details Introduction to Networking Yan Gao TA Jan 27, 2005 Recital 3.
Lecture 3 TCP/IP model CPE 401 / 601 Computer Network Systems slides are modified from Dave Hollinger.
Networks: TCP/IP Socket Calls1 Elementary TCP Sockets Chapter 4 UNIX Network Programming Vol. 1, Second Ed. Stevens.
Elementary TCP Sockets Chapter 4 UNIX Network Programming Vol. 1, Second Ed. Stevens.
Netprog: TCP Details1 TCP Details Introduction to Networking John Otto TA Jan 31, 2007 Recital 4.
Netprog: TCP Details1 TCP Details Introduction to Networking.
CSCE 515: Computer Network Programming TCP Details Wenyuan Xu Department of Computer Science and Engineering.
Lecture 10 Overview. Network API Application Programming Interface – Services that provide the interface between application and protocol software often.
Lecture 8 UDP Sockets & I/O Multiplexing
Gursharan Singh Tatla Transport Layer 16-May
ECE 4110 – Internetwork Programming Client-Server Model.
Assignment 3 A Client/Server Application: Chatroom.
Elementary TCP Sockets
1 Netprog 2002 TCP/IP TCP/IP Transmission Control Protocol / Internet Protocol Based on Notes by D. Hollinger.
Lecture 6 Overview. TCP: Transmission Control Protocol TCP is an alternative transport layer protocol supported by TCP/IP. TCP provides: – Connection-oriented.
CS162B: IPv4 Socketing Jacob T. Chan. Socketing in the Real World  Most computer games are multiplayer in nature or have multiplayer components  DotA,
 Wind River Systems, Inc Chapter - 13 Network Programming.
---- IT Acumens. COM IT Acumens. COMIT Acumens. COM.
Chapter 2 Applications and Layered Architectures Sockets.
CPSC 441 TUTORIAL – FEB 13, 2012 TA: RUITNG ZHOU UDP REVIEW.
Lecture 15 Overview.
CSCE 515: Computer Network Programming UDP Socket Wenyuan Xu Department of Computer Science and Engineering.
1 Sockets Programming Socket to me!. 2 Network Application Programming Interface (API) The services provided by the operating system that provide the.
Programming with UDP – II Covered Subjects: Creating UDP sockets Client Server Sending data Receiving data Connected mode.
EECS340 Recitation 2: Very helpful to your project Hongyu Gao 1.
CSCI 330 UNIX and Network Programming Unit XV: Transmission Control Protocol.
1 TCP Sockets Programming Creating a passive mode (server) socket.Creating a passive mode (server) socket. Establishing an application-level connection.Establishing.
Lecture 15 Socket Programming CPE 401 / 601 Computer Network Systems slides are modified from Dave Hollinger.
Lecture 3 TCP and UDP Sockets CPE 401 / 601 Computer Network Systems slides are modified from Dave Hollinger.
3. END-TO-END PROTOCOLS (PART 1) Rocky K. C. Chang Department of Computing The Hong Kong Polytechnic University 22 March
1 UDP Sockets Programming Creating UDP sockets.Creating UDP sockets. –Client –Server Sending data.Sending data. Receiving data.Receiving data. Connected.
Netprog: TCP Sockets1 TCP Sockets Programming Creating a passive mode (server) socket.Creating a passive mode (server) socket. Establishing an application-level.
SOCKET PROGRAMMING Presented By : Divya Sharma.
Chapter 9: Transport Layer
Fast Retransmit For sliding windows flow control we waited for a timer to expire before beginning retransmission of a packet TCP uses an additional mechanism.
Instructor Materials Chapter 9: Transport Layer
Introduction to Networking Recital 4
5. End-to-end protocols (part 1)
Transport Layer.
Process-to-Process Delivery
TCP.
Socket Programming in C
TCP - Part I Karim El Defrawy
TCP - Part I Relates to Lab 5. First module on TCP which covers packet format, data transfer, and connection management.
Network Programming CSC- 341
Network Programming CSC- 341
UDP Sockets Programming
Process-to-Process Delivery:
TCP Details.
Lecture 11 Overview.
TCP Sockets Programming
Advanced Network Programming spring 2007
PART V Transport Layer.
PART 5 Transport Layer.
TCP - Part I Relates to Lab 5. First module on TCP which covers packet format, data transfer, and connection management.
Transport Protocols: TCP Segments, Flow control and Connection Setup
Sockets Programming Socket to me!.
Sockets Programming Socket to me!.
Transport Protocols: TCP Segments, Flow control and Connection Setup
Process-to-Process Delivery: UDP, TCP
Transport Layer 9/22/2019.
Presentation transcript:

Chapter 2 Transport Layer Protocols TCP UDP SCTP By Kulveer Singh

TCP SCTP UDP TCP reliable end to end delivery UDP unreliable SCTP (Stream control transport protocol) ->used for internet telephony communication/signals. ->It supports multiple streams and MultiHoming ->What is MultiHoming? ->which allows a single SCTP endpoint to support multiple IP addresses

TCP Lingo When a client requests a connection it sends a “SYN” segment (a special TCP segment) to the server port. SYN stands for synchronize. The SYN message includes the client’s ISN. ISN is Initial Sequence Number.

More... Every TCP segment includes a Sequence Number that refers to the first byte of data included in the segment. Every TCP segment includes a Request Number (Acknowledgement Number) that indicates the byte number of the next data that is expected to be received. All byte up through this number have already been received.

And more... There are a bunch of control flags: URG: urgent data included. ACK: this segment is (among other things) an acknowledgement. RST: error - abort the session. SYN: synchronize Sequence Numbers (setup) FIN: polite connection termination.

And more... MSS: Maximum segment size (A TCP option) Window: Every ACK includes a Window field that tells the sender how many bytes it can send before the receiver will have to toss it away (due to fixed bugger size).

TCP Connection Creation Programming details later - for now we are concerned with the actual communication. A server accepts a connection. Must be looking for new connections! A client requests a connection. Must know where the server is!

Client Starts A client starts by sending a SYN segment with the following information: Client’s ISN (generated pseudo-randomly) Maximum Receive Window for client. Optionally (but usually) MSS (largest datagram accepted). No payload! (Only TCP headers)

Sever Response When a waiting server sees a new connection request, the server sends back a SYN segment with: Server’s ISN (generated pseudo-randomly) Request Number is Client ISN+1 Maximum Receive Window for server. Optionally (but usually) MSS No payload! (Only TCP headers)

Finally When the Server’s SYN is received, the client sends back an ACK with: Request Number is Server’s ISN+1

Client Server SYN ISN=X 1 SYN ISN=Y ACK=X+1 2 ACK=Y+1 3

TCP 3-way handshake Client: “I want to talk, and I’m starting with byte number X”. Server: “OK, I’m here and I’ll talk. My first byte will be called number Y, and I know your first byte will be number X”. Client: “Got it - you start at byte number Y”. Bill: “Monica, I’m afraid I’ll syn and byte your ack” 1 2 3 ?

Why 3-Way? Why is the third message necessary? HINTS: TCP is a reliable service. IP delivers each TCP segment. IP is not reliable.

TCP Data and ACK Once the connection is established, data can be sent. Each data segment includes a sequence number identifying the first byte in the segment. Each segment (data or empty) includes a request number indicating what data has been received.

Buffering Keep in mind that TCP is part of the Operating System takes care of all these details asynchronously. The TCP layer doesn’t know when the application will ask for any received data. TCP buffers incoming data so it’s ready when we ask for it.

TCP Buffers Both the client and server allocate buffers to hold incoming and outgoing data The TCP layer does this. Both the client and server announce with every ACK how much buffer space remains (the Window field in a TCP segment).

Send Buffers The application gives the TCP layer some data to send. The data is put in a send buffer, where it stays until the data is ACK’d. The TCP layer won’t accept data from the application unless (or until) there is buffer space.

ACKs A receiver doesn’t have to ACK every segment (it can ACK many segments with a single ACK segment). Each ACK can also contain outgoing data (piggybacking). If a sender doesn’t get an ACK after some time limit (MSL) it resends the data.

TCP Segment Order Most TCP implementations will accept out-of-order segments (if there is room in the buffer). Once the missing segments arrive, a single ACK can be sent for the whole thing. Remember: IP delivers TCP segments, and IP in not reliable - IP datagrams can be lost or arrive out of order.

Termination The TCP layer can send a RST segment that terminates a connection if something is wrong. Usually the application tells TCP to terminate the connection politely with a FIN segment.

FIN Either end of the connection can initiate termination. A FIN is sent, which means the application is done sending data. The FIN is ACK’d. The other end must now send a FIN. That FIN must be ACK’d.

App1 App2 FIN SN=X 1 ACK=X+1 2 ... FIN SN=Y 3 ACK=Y+1 4

TCP Termination App1: “I have no more data for you”. App2: “OK, I understand you are done sending.” dramatic pause… App2: “OK - Now I’m also done sending data”. App1: “Roger, Over and Out, Goodbye, Astalavista Baby, Adios, It’s been real ...” camera fades to black ... 1 2 3 4

TCP TIME_WAIT Once a TCP connection has been terminated (the last ACK sent) there is some unfinished business: What if the ACK is lost? The last FIN will be resent and it must be ACK’d. What if there are lost or duplicated segments that finally reach the destination after a long delay? TCP hangs out for a while to handle these situations.

Test Questions Why is a 3-way handshake necessary? Who sends the first FIN - the server or the client? Once the connection is established, what is the difference between the operation of the server’s TCP layer and the client’s TCP layer? How many times did Bill: FIN? FIB? ACK his FIBs?

TCP Sockets Programming Creating a passive mode (server) socket. Establishing an application-level connection. send/receive data. Terminating a connection.

Creating a TCP socket int sock; sock = socket( PF_INET, SOCK_STREAM, int socket(int family,int type,int proto); int sock; sock = socket( PF_INET, SOCK_STREAM, 0); if (sock<0) { /* ERROR */ }

Binding to well known address int mysock; struct sockaddr_in myaddr; mysock = socket(PF_INET,SOCK_STREAM,0); myaddr.sin_family = AF_INET; myaddr.sin_port = htons( 80 ); myaddr.sin_addr = htonl( INADDR_ANY ); bind(mysock, &myaddr, sizeof(myaddr));

Establishing a passive mode TCP socket Address already determined. Tell the kernel to accept incoming connection requests directed at the socket address. Tell the kernel to queue incoming connections for us.

Listen() sockfd is the TCP socket (already bound to an address) int listen( int sockfd, int backlog); sockfd is the TCP socket (already bound to an address) backlog is the number of incoming connections the kernel should be able to keep track of. Listen() returns -1 on error (otherwise 0).

Accept() sockfd is the passive mode TCP socket. int accept( int sockfd, struct sockaddr* cliaddr, socklen_t *addrlen); sockfd is the passive mode TCP socket. Cliaddr is a pointer to allocated space. Addrlen is a value-result argument, must be set to the size of cliaddr, will be set on return to be the number of bytes in cliaddr set by the call to accept.

accept() return value Accept() returns a new socket descriptor (small positive integer) or -1 on error. After accept returns a new socket descriptor I/O can be done using the read() and write() system calls. read() and write() operate a little differently on sockets (vs. file operation)!

Terminating a TCP connection Either end of the connection can call the close() system call. If the other end had closed the connection and there is no buffered data, reading from a TCP socket returns EOF (0 bytes).

Client Code TCP clients can call connect() which: takes care of establishing an endpoint address for the client socket (we don’t need to call bind). Attempts to establish a connection to the specified server.

connect() sockfd is an already created TCP socket. int connect( int sockfd, const struct sockaddr *server, socklen_t addrlen); sockfd is an already created TCP socket. server contains the address of the server (IP Address and TCP port number) connect() returns 0 if OK, -1 on error

Reading from a TCP socket int read( int fd, char *buf, int max); By default read() will block until data is available* reading from a TCP socket may return less than max bytes (whatever is available). You must be prepared to read data 1 byte at a time!

Writing to a TCP socket int write( int fd, char *buf, int num); write might not be able to write all num bytes (on a nonblocking socket).

Use Telnet client Putty Download putty.exe telnet client from http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html Login to SSH using the Server ip address and userid and password . Please mail me your userid and password if you want to have a login on Linux Machine to Kulveer.singh@gmail.com

Vi Editor Use any text editor to write a code in .c for C code and .h for header files . You can use Vi editor Common commands used for Vi vi: vi filename To exit vi and save changes: ZZ or :wq To exit vi without saving changes: :q! To enter vi command mode: [esc]

Compilation steps Cc -Wall –o –I/pathofIncludeFiles outputfilename filename.c gcc options -o output file name, (a.out if omitted) -Wall display warnings for many possible errors hello.c file to be compiled, can specify multiple .c files The info pages (info gcc) has much more information about gcc. These are in the gcc-doc package. To run ./outputfilename

Home Work Write a Client Server program in which Server(MathServer) will act like Calculator and client(mathClient) would be like User for example if you enter 2+ 5 on client console then server should return 7 Server will do the all mathematical processing and echo back the result to Client.

Thanks For any queries Please mail me at kulveer.singh@{gmail.com,dit.dongseo.ac.kr}