1 Netprog 2002 TCP/IP TCP/IP Transmission Control Protocol / Internet Protocol Based on Notes by D. Hollinger.

Slides:



Advertisements
Similar presentations
1 Features of IPv6 Larger Address Extended Address Hierarchy Flexible Header Format Improved Options Provision For Protocol Extension Support for Auto-configuration.
Advertisements

Netprog: IPv61 IPv6 Refs: Chapter 10, Appendix A.
Socket Programming with IPv6. Why IPv6? Addressing and routing scalability Address space exhaustion Host autoconfiguration QoS of flow using flowlabel.
TCP - Part I Relates to Lab 5. First module on TCP which covers packet format, data transfer, and connection management.
CCNA – Network Fundamentals
Transmission Control Protocol (TCP)
Intermediate TCP/IP TCP Operation.
CSEE W4140 Networking Laboratory Lecture 6: TCP and UDP Jong Yul Kim
UDP & TCP Where would we be without them!. UDP User Datagram Protocol.
CSE551: Computer Network Review r Network Layers r TCP/UDP r IP.
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.
Networks I Transmission Control Protocol Instituto Tecnológico y de Estudios Superiores de Monterrey Campus Estado de México Prof. MSc. Ivan A. Escobar.
1 Chapter 3 TCP and IP. Chapter 3 TCP and IP 2 Introduction Transmission Control Protocol (TCP) Transmission Control Protocol (TCP) User Datagram Protocol.
CS3505 The Internet and Info Hiway transport layer protocols : TCP/UDP.
BZUPAGES.COM 1 User Datagram Protocol - UDP RFC 768, Protocol 17 Provides unreliable, connectionless on top of IP Minimal overhead, high performance –No.
Computer Networks 2 Lecture 2 TCP – I - Transport Protocols: TCP Segments, Flow control and Connection Setup.
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)
Copyright 1999, S.D. Personick. All Rights Reserved. Telecommunications Networking II Lecture 32 Transmission Control Protocol (TCP) Ref: Tanenbaum pp:
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.
EEC-484/584 Computer Networks Lecture 15 Wenbing Zhao (Part of the slides are based on Drs. Kurose & Ross ’ s slides for their Computer.
Netprog: TCP Details1 TCP Details Introduction to Networking John Otto TA Jan 31, 2007 Recital 4.
Netprog: TCP Details1 TCP Details Introduction to Networking.
1 TCP/IP Transmission Control Protocol / Internet Protocol.
CSEE W4140 Networking Laboratory Lecture 6: TCP and UDP Jong Yul Kim
CSCE 515: Computer Network Programming TCP Details Wenyuan Xu Department of Computer Science and Engineering.
Gursharan Singh Tatla Transport Layer 16-May
1 IPv6 Refs: Chapter 10, Appendix A. 2 IPv6 availability Generally not part of O.S. Available in beta for many operating systems. 6-Bone is experimental.
Process-to-Process Delivery:
TRANSPORT LAYER T.Najah Al-Subaie Kingdom of Saudi Arabia Prince Norah bint Abdul Rahman University College of Computer Since and Information System NET331.
1 Transport Layer Computer Networks. 2 Where are we?
6.1. Transport Control Protocol (TCP) It is the most widely used transport protocol in the world. Provides reliable end to end connection between two hosts.
Lecture 6 Overview. TCP: Transmission Control Protocol TCP is an alternative transport layer protocol supported by TCP/IP. TCP provides: – Connection-oriented.
TCP : Transmission Control Protocol Computer Network System Sirak Kaewjamnong.
TCP Lecture 13 November 13, TCP Background Transmission Control Protocol (TCP) TCP provides much of the functionality that IP lacks: reliable service.
1 The Internet and Networked Multimedia. 2 Layering  Internet protocols are designed to work in layers, with each layer building on the facilities provided.
Transport Layer: TCP and UDP. Overview of TCP/IP protocols Comparing TCP and UDP TCP connection: establishment, data transfer, and termination Allocation.
Copyright 2002, S.D. Personick. All Rights Reserved.1 Telecommunications Networking II Topic 20 Transmission Control Protocol (TCP) Ref: Tanenbaum pp:
TCP1 Transmission Control Protocol (TCP). TCP2 Outline Transmission Control Protocol.
Chapter 2 Applications and Layered Architectures Sockets.
Java Sockets Programming
Lecture 4 Overview. Ethernet Data Link Layer protocol Ethernet (IEEE 802.3) is widely used Supported by a variety of physical layer implementations Multi-access.
Chapter 24 Transport Control Protocol (TCP) Layer 4 protocol Responsible for reliable end-to-end transmission Provides illusion of reliable network to.
Hour 6 The Transport Layer 1. What You'll Learn in This Hour Connections oriented and connectionless protocols Ports and sockets TCP UDP 2.
4343 X2 – The Transport Layer Tanenbaum Ch.6.
Data Communications and Networks Chapter 6 – IP, UDP and TCP ICT-BVF8.1- Data Communications and Network Trainer: Dr. Abbes Sebihi.
Agenda Socket Programming The OSI reference Model The OSI protocol stack Sockets Ports Java classes for sockets Input stream and.
TCP/IP1 Address Resolution Protocol Internet uses IP address to recognize a computer. But IP address needs to be translated to physical address (NIC).
Lecture 3 TCP and UDP Sockets CPE 401 / 601 Computer Network Systems slides are modified from Dave Hollinger.
11 CS716 Advanced Computer Networks By Dr. Amir Qayyum.
1 TCP ProtocolsLayer name DNSApplication TCP, UDPTransport IPInternet (Network ) WiFi, Ethernet Link (Physical)
3. END-TO-END PROTOCOLS (PART 1) Rocky K. C. Chang Department of Computing The Hong Kong Polytechnic University 22 March
Introduction to TCP/IP networking
Introduction to Networking Recital 4
5. End-to-end protocols (part 1)
Transport Layer.
TCP.
TCP/IP Transmission Control Protocol / Internet Protocol
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.
Chapter 2 Transport Layer Protocols TCP UDP SCTP
TCP Details.
Refs: Chapter 10, Appendix A
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
Transport Protocols: TCP Segments, Flow control and Connection Setup
Process-to-Process Delivery: UDP, TCP
Transport Layer 9/22/2019.
Presentation transcript:

1 Netprog 2002 TCP/IP TCP/IP Transmission Control Protocol / Internet Protocol Based on Notes by D. Hollinger

2 Netprog 2002 TCP/IP Topics IPv6 TCP Java TCP Programming

3 Netprog 2002 TCP/IP IPv6 availability Generally available with (new) versions of most operating systems. BSD, Linux 2.2 Solaris 8 An option with Windows 2000/NT Most routers can support IPV6 Supported in J2SDK/JRE 1.4

4 Netprog 2002 TCP/IP IPv6 Design Issues Overcome IPv4 scaling problem lack of address space. Flexible transition mechanism. New routing capabilities. Quality of service. Security. Ability to add features in the future.

5 Netprog 2002 TCP/IP IPv6 Headers Simpler header - faster processing by routers. No optional fields - fixed size (40 bytes) No fragmentation fields. No checksum Support for multiple headers more flexible than simple “protocol” field.

6 Netprog 2002 TCP/IP IPv4 Header VERSHL Fragment Offset Fragment LengthService Datagram IDFLAG TTLProtocolHeader Checksum Source Address Destination Address Options (if any) Data 1 byte 4 for IPv4

7 Netprog 2002 TCP/IP IPv6 Header VERSPRIO Hop Limit Flow Label Payload LengthNext Header 1 byte 6 for IPv6 Source Address (128 bits - 16 bytes) Dest. Address (128 bits - 16 bytes)

8 Netprog 2002 TCP/IP IPv6 Header Fields VERS: 6 (IP version number) Priority: will be used in congestion control Flow Label: experimental - sender can label a sequence of packets as being in the same flow. Payload Length: number of bytes in everything following the 40 byte header (up to 64Kb), or 0 for a Jumbogram (up to 4Gb).

9 Netprog 2002 TCP/IP IPv6 Header Fields Next Header is similar to the IPv4 “protocol” field - indicates what type of header follows the IPv6 header. Hop Limit is similar to the IPv4 TTL field (but now it really means hops, not time).

10 Netprog 2002 TCP/IP Extension Headers Routing Header - source routing Fragmentation Header - supports fragmentation of IPv6 datagrams. Authentication Header Encapsulating Security Payload Header

11 Netprog 2002 TCP/IP IPv6 Addresses 128 bits - written as eight 16-bit hex numbers. 5f1b:df00:ce3e:e200:0020:0800:2078:e3e3 High order bits determine the type of address.

12 Netprog 2002 TCP/IP IPv6 Aggregate Global Unicast Address 010TLA IDNLA IDSLA IDInterface ID TLA: top-level aggregation (provider) NLA: next-level (subscriber) SLA: site-level (subnet) Interface ID is (typically) based on hardware MAC address

13 Netprog 2002 TCP/IP IPv4-Mapped IPv6 Address IPv4-Mapped addresses allow a host that support both IPv4 and IPv6 to communicate with a host that supports only IPv4. The IPv6 address is based completely on the IPv4 address.

14 Netprog 2002 TCP/IP IPv4-Mapped IPv6 Address 80 bits of 0s followed by 16 bits of ones, followed by a 32 bit IPv4 Address: IPv4 AddressFFFF 80 bits32 bits16 bits

15 Netprog 2002 TCP/IP Works with DNS An IPv6 application asks DNS for the address of a host, but the host only has an IPv4 address. DNS creates the IPv4-Mapped IPv6 address automatically. Kernel understands this is a special address and really uses IPv4 communication.

16 Netprog 2002 TCP/IP IPv4-Compatible IPv6 Address An IPv4 compatible address allows a host supporting IPv6 to talk IPv6 even if the local router(s) don’t talk IPv6. IPv4 compatible addresses tell endpoint software to create a tunnel by encapsulating the IPv6 packet in an IPv4 packet.

17 Netprog 2002 TCP/IP IPv4-Compatible IPv6 Address IPv4 Address bits32 bits16 bits 80 bits of 0s followed by 16 bits of 0s, followed by a 32 bit IPv4 Address:

18 Netprog 2002 TCP/IP Tunneling (done automatically by kernel when IPv4-Compatible IPv6 addresses used) IPv6 Host IPv6 Host IPv4 Routers IPv6 Datagram IPv4 Datagram

19 Netprog 2002 TCP/IP IPv6 in Java 1.4 Inet6Address class :: corresponds to (unspecified) in IPv4 ::1 corresponds to (loopback) in IPv4 ::ffff:w.x.y.z IPv4-mapped address ::w.x.y.z to tunnel IPv6 packets over IPv4 routing For details, see:

20 Netprog 2002 TCP/IP TCP Transmission Control Protocol TCP is an alternative transport layer protocol over IP. TCP provides: Connection-oriented Reliable Full-duplex Byte-Stream

21 Netprog 2002 TCP/IP Connection-Oriented Connection oriented means that a virtual connection is established before any user data is transferred. If the connection cannot be established - the user program is notified. If the connection is ever interrupted - the user program(s) is notified.

22 Netprog 2002 TCP/IP Reliable Reliable means that every transmission of data is acknowledged by the receiver. If the sender does not receive acknowledgement within a specified amount of time, the sender retransmits the data.

23 Netprog 2002 TCP/IP Byte Stream Stream means that the connection is treated as a stream of bytes. The user application does not need to package data in individual datagrams (as with UDP).

24 Netprog 2002 TCP/IP Buffering TCP is responsible for buffering data and determining when it is time to send a datagram. It is possible for an application to tell TCP to send the data it has buffered without waiting for a buffer to fill up.

25 Netprog 2002 TCP/IP Full Duplex TCP provides transfer in both directions. To the application program these appear as 2 unrelated data streams, although TCP can piggyback control and data communication by providing control information (such as an ACK) along with user data.

26 Netprog 2002 TCP/IP TCP Ports Interprocess communication via TCP is achieved with the use of ports (just like UDP). UDP ports have no relation to TCP ports (different name spaces).

27 Netprog 2002 TCP/IP TCP Segments The chunk of data that TCP asks IP to deliver is called a TCP segment. Each segment contains: data bytes from the byte stream control information that identifies the data bytes

28 Netprog 2002 TCP/IP TCP Segment Format Destination Port Options (if any) Data 1 byte Source Port Sequence Number Acknowledgment Number 1 byte offsetReser.ControlWindow ChecksumUrgent Pointer

29 Netprog 2002 TCP/IP 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.

30 Netprog 2002 TCP/IP More... Every TCP segment includes a Sequence Number that refers to the first byte of data included in the segment. Every TCP segment includes an Acknowledgement Number that indicates the byte number of the next data that is expected to be received. All bytes up through this number have already been received.

31 Netprog 2002 TCP/IP And more... There are a bunch of control flags: URG: urgent data included. ACK: this segment is (among other things) an acknowledgement. RST: error – connection must be reset. SYN: synchronize Sequence Numbers (setup) FIN: polite connection termination.

32 Netprog 2002 TCP/IP 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 buffer size).

33 Netprog 2002 TCP/IP 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!

34 Netprog 2002 TCP/IP 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)

35 Netprog 2002 TCP/IP Server 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)

36 Netprog 2002 TCP/IP Finally When the Server’s SYN is received, the client sends back an ACK with: Acknowledgment Number is Server’s ISN+1

37 Netprog 2002 TCP/IP SYN ISN=X SYN ISN=X Client Server SYN ISN=Y ACK=X+1 SYN ISN=Y ACK=X+1 ACK=Y

38 Netprog 2002 TCP/IP 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+1”. Client: “Got it - you start at byte number Y+1”. Bill: “Monica, I’m afraid I’ll syn and byte your ack ” ?

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

40 Netprog 2002 TCP/IP 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.

41 Netprog 2002 TCP/IP Buffering Keep in mind that TCP is part of the Operating System. The O.S. 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.

42 Netprog 2002 TCP/IP 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).

43 Netprog 2002 TCP/IP 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.

44 Netprog 2002 TCP/IP 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, it resends the data.

45 Netprog 2002 TCP/IP 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 is not reliable - IP datagrams can be lost or arrive out of order.

46 Netprog 2002 TCP/IP 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.

47 Netprog 2002 TCP/IP 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.

48 Netprog 2002 TCP/IP FIN SN=X FIN SN=X App1 App2 ACK=X+1 ACK=Y FIN SN=Y FIN SN=Y 3...

49 Netprog 2002 TCP/IP 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, Hastalavista Baby, Adios, It’s been real...” camera fades to black...

50 Netprog 2002 TCP/IP 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.

51 Netprog 2002 TCP/IP TCP Sockets Programming Creating a passive mode (server) socket. Establishing an application-level connection. Sending/receiving data. Terminating a connection.

52 Netprog 2002 TCP/IP Establishing a passive mode TCP socket Passive mode: Address already determined. Tell the kernel to accept incoming connection requests directed at the socket address. 3-way handshake Tell the kernel to queue incoming connections for us.

53 Netprog 2002 TCP/IP Accepting an incoming connection. Once we start listening on a socket, the O.S. will queue incoming connections Handles the 3-way handshake Queues up multiple connections. When our application is ready to handle a new connection, we need to ask the O.S. for the next connection.

54 Netprog 2002 TCP/IP Terminating a TCP connection Either end of the connection can call the close() system call. If the other end has closed the connection, and there is no buffered data, reading from a TCP socket returns 0 to indicate EOF.

55 Netprog 2002 TCP/IP Client Code TCP clients can connect to a server, which: takes care of establishing an endpoint address for the client socket. don’t need to call bind first, the O.S. will take care of assigning the local endpoint address (TCP port number, IP address). Attempts to establish a connection to the specified server. 3-way handshake

56 Netprog 2002 TCP/IP Reading from a TCP socket 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!

57 Netprog 2002 TCP/IP Writing to a TCP socket write might not be able to write all bytes (on a nonblocking socket).

58 Netprog 2002 TCP/IP Metaphor for Good Relationships Copyright Dr. Laura’s Network Programming Corp. To succeed in relationships: you need to establish your own identity. you need to be open & accepting. you need to establish contacts. you need to take things as they come, not as you expect them. you need to handle problems as they arise. bind() accept() connect() check for errors read might return 1 byte

59 Netprog 2002 TCP/IP Java Sockets Programming The package java.net provides support for sockets programming Typically you import everything defined in this package with: import java.net.*;

60 Netprog 2002 TCP/IP Classes InetAddress Socket ServerSocket DatagramSocket DatagramPacket UDP

61 Netprog 2002 TCP/IP Socket class Corresponds to active TCP sockets only! client sockets socket returned by accept(); Passive sockets are supported by a different class: ServerSocket

62 Netprog 2002 TCP/IP Socket Constructors Constructor creates a TCP connection to a named TCP server. There are a number of constructors: Socket(InetAddress server, int port); Socket(InetAddress server, int port, InetAddress local, int localport); Socket(String hostname, int port);

63 Netprog 2002 TCP/IP Socket Methods void close(); InetAddress getInetAddress(); getpeername InetAddress getLocalAddress(); getsockname InputStream getInputStream(); OutputStream getOutputStream(); Lots more (setting/gettting socket options, partial close, etc.)

64 Netprog 2002 TCP/IP Socket I/O Socket I/O is based on the Java I/O support (in the package java.io ). InputStream and OutputStream are abstract classes common operations defined for all kinds of InputStreams, OutputStreams…

65 Netprog 2002 TCP/IP ServerSocket Class (TCP Passive Socket) Constructors: ServerSocket(int port); ServerSocket(int port, int backlog); ServerSocket(int port, int backlog, InetAddress bindAddr);

66 Netprog 2002 TCP/IP ServerSocket Methods Socket accept(); void close(); InetAddress getInetAddress(); int getLocalPort(); throw IOException, SecurityException

67 Netprog 2002 TCP/IP Sample Echo Server TCPEchoServer.java, EchoClient.java, GenericClient.java Simple TCP Echo server. Based on code from: TCP/IP Sockets in Java, Java Online Tutorial