Presentation is loading. Please wait.

Presentation is loading. Please wait.

TCP/IP Refresher Prabhaker Mateti (ack: Many many sources …)

Similar presentations


Presentation on theme: "TCP/IP Refresher Prabhaker Mateti (ack: Many many sources …)"— Presentation transcript:

1 TCP/IP Refresher Prabhaker Mateti (ack: Many many sources …)

2 Mateti, TCP/IP Refresher 2 TCP/IP ? TCP = Transmission Control Protocol TCP = Transmission Control Protocol IP = Internet Protocol IP = Internet Protocol Almost always includes other protocols: Almost always includes other protocols: –UDP, User (Unreliable) Datagram –ICMP, Internet Control Message –ARP, Address Resolution

3 Mateti, TCP/IP Refresher 3 What’s a Protocol? An agreed upon convention for communication. An agreed upon convention for communication. Protocols must be formally defined and unambiguous Protocols must be formally defined and unambiguous

4 Mateti, TCP/IP Refresher 4 TCP UDP ICMPother IP layer Physical Layers The relative heights indicate the level of functionality.

5 Mateti, TCP/IP Refresher 5 Unix is a Layered System Applications Libraries System Calls Kernel

6 Mateti, TCP/IP Refresher 6 Layers The routines/methods of Layer N will not call Layer N+1. The routines/methods of Layer N will not call Layer N+1. The routines/methods of Layer N typically do call the same layer methods. The routines/methods of Layer N typically do call the same layer methods. The routines/methods of Layer N typically do call Layer N-1 methods. The routines/methods of Layer N typically do call Layer N-1 methods.

7 Mateti, TCP/IP Refresher 7 DoD model: Four Layers 1. Network Access Layer: Delivery over physical media in use. 2. Internet Layer: Delivery across different physical networks that connect source and destination machines. 3. Host-to-Host Layer: Connection rendezvous, flow control, retransmission of lost data, etc. TCP and UDP protocols are in this layer. 4. Process Layer: User-level functions, such as SMTP, FTP and rlogin.

8 Mateti, TCP/IP Refresher 8 OSI Reference Model Seven Layers 7. Application 6. Presentation 5. Session 4. Transport 3. Network 2. Data Link 1. Physical

9 Mateti, TCP/IP Refresher 9 TCP/IP & OSI In OSI reference model terminology - the TCP/IP protocol suite covers the network and transport layers. In OSI reference model terminology - the TCP/IP protocol suite covers the network and transport layers. TCP/IP can be used on many data-link layers (can support many network hardware implementations). TCP/IP can be used on many data-link layers (can support many network hardware implementations).

10 Mateti, TCP/IP Refresher 10 TCP UDP IP 802.3 Process Layer Transport Layer Network Layer Data-Link Layer Process ICMP, ARP & RARP

11 Mateti, TCP/IP Refresher 11 Physical Layer Responsibility: Responsibility: –transmission of raw bits over a communication channel. Issues: Issues: –mechanical and electrical interfaces –time per bit –distances

12 Mateti, TCP/IP Refresher 12 Data Link Layer - Data Link Control Responsibility: Responsibility: –provide an error-free communication link Issues: Issues: –framing (dividing data into chunks) header & trailer bits header & trailer bits –addressing 101101101010110001001110110000001

13 Mateti, TCP/IP Refresher 13 The Data Link Layer - The MAC sub layer Medium Access Control (MAC) - needed by multi-access networks. Medium Access Control (MAC) - needed by multi-access networks. MAC provides DLC with “virtual wires” on multi-access networks. MAC provides DLC with “virtual wires” on multi-access networks.

14 Mateti, TCP/IP Refresher 14 Ethernet: A Data-Link Layer IEEE 802.3 IEEE 802.3 Variety of physical layers. Variety of physical layers. Multi-access (shared medium). Multi-access (shared medium). Interface has a unique 6-byte hardware address. (E.g. 00-D0-09-E8-08-61) Interface has a unique 6-byte hardware address. (E.g. 00-D0-09-E8-08-61) The broadcast address is all 1’s. The broadcast address is all 1’s. Addresses are assigned to vendors by a central authority. Addresses are assigned to vendors by a central authority.

15 Mateti, TCP/IP Refresher 15 An Ethernet Frame Preamble is a sequence of alternating 1’s and 0’s used for synchronization. Preamble is a sequence of alternating 1’s and 0’s used for synchronization. CRC is Cyclic Redundancy Check CRC is Cyclic Redundancy Check 8 bytes6620-15004 Preamble Destination Address Source Address LenCRC DATA

16 Mateti, TCP/IP Refresher 16 Ethernet Addressing Each NIC looks at every frame and inspects the destination address. If the address does not match the hardware address of the interface or the broadcast address, the frame is discarded. Each NIC looks at every frame and inspects the destination address. If the address does not match the hardware address of the interface or the broadcast address, the frame is discarded. Some NICs can be programmed to recognize multicast addresses. Some NICs can be programmed to recognize multicast addresses.

17 Mateti, TCP/IP Refresher 17 The Network Layer Responsibilities: Responsibilities: –path selection between systems (routing). –subnet flow control. –fragmentation & reassembly –translation between different network types. Issues: Issues: –packet headers –virtual circuits

18 Mateti, TCP/IP Refresher 18 The Transport Layer Responsibilities: Responsibilities: –provides virtual end-to-end links between peer processes. –end-to-end flow control Issues: Issues: –headers –error detection –reliable communication

19 Mateti, TCP/IP Refresher 19 The Session Layer Responsibilities: Responsibilities: –establishes, manages, and terminates sessions between applications. –service location lookup Many protocol suites do not include a session layer. Many protocol suites do not include a session layer.

20 Mateti, TCP/IP Refresher 20 The Presentation Layer Responsibilities: Responsibilities: –data encryption –data compression –data conversion Many protocol suites do not include a Presentation Layer. Many protocol suites do not include a Presentation Layer.

21 Mateti, TCP/IP Refresher 21 The Application Layer Responsibilities: Responsibilities: –anything not provided by any of the other layers Issues: Issues: –application level protocols –appropriate selection of “type of service”

22 Mateti, TCP/IP Refresher 22 Layering & Headers Each layer needs to add control information. Each layer needs to add control information. Typically prefixed to the data before passing on to the lower layer. Typically prefixed to the data before passing on to the lower layer.

23 Mateti, TCP/IP Refresher 23 Headers Process Transport Network Data Link Process Transport Network Data Link DATA H H H H HH

24 Mateti, TCP/IP Refresher 24 Example Headers Physical: no header Physical: no header Data Link: Data Link: –address of the receiving endpoints –address of the sending endpoint –length of the data –checksum

25 Mateti, TCP/IP Refresher 25 Network layer header - examples protocol suite version protocol suite version type of service type of service length of the data length of the data packet identifier packet identifier fragment number fragment number time to live time to live protocol protocol header checksum header checksum source network address source network address destination network address destination network address

26 Mateti, TCP/IP Refresher 26 Connecting Networks Repeater: physical layer Repeater: physical layer Bridge: data link layer Bridge: data link layer Router: network layer Router: network layer Gateway: network layer and above. Gateway: network layer and above.

27 Mateti, TCP/IP Refresher 27 Repeater Copies bits from one network to another Copies bits from one network to another Does not look at any bits Does not look at any bits Allows the extension of a network beyond physical length limitations Allows the extension of a network beyond physical length limitations REPEATER

28 Mateti, TCP/IP Refresher 28 Bridge Copies frames from one network to another Copies frames from one network to another Can operate selectively - does not copy all frames (looks at data-link headers). Can operate selectively - does not copy all frames (looks at data-link headers). Extends the network beyond physical length limitations. Extends the network beyond physical length limitations. BRIDGE

29 Mateti, TCP/IP Refresher 29 Router Copies packets from one network to another. Copies packets from one network to another. Makes decisions about what route a packet should take (looks at network headers). Makes decisions about what route a packet should take (looks at network headers). ROUTER

30 Mateti, TCP/IP Refresher 30 Gateway Operates as a router Operates as a router Data conversions above the network layer. Data conversions above the network layer. Conversions: Conversions: –encapsulation - use an intermediate network –translation - connect different application protocols –encryption - could be done by a gateway

31 Mateti, TCP/IP Refresher 31 Encapsulation Example Gateway Provides service connectivity even though intermediate network does not support protocols. Provides service connectivity even though intermediate network does not support protocols.

32 Mateti, TCP/IP Refresher 32 Translation Translate from green protocol to brown protocol Translate from green protocol to brown protocol Gateway

33 Mateti, TCP/IP Refresher 33 Encryption gateway Secure Network Secure Network Encryption/Decryption Gateways GW ? ? ? Insecure Network

34 Mateti, TCP/IP Refresher 34 Hardware v. Software Repeaters are typically hardware devices. Repeaters are typically hardware devices. Bridges can be implemented in hardware or software. Bridges can be implemented in hardware or software. Routers and gateways are typically implemented in software so that they can be extended to handle new protocols. Routers and gateways are typically implemented in software so that they can be extended to handle new protocols. Many workstations can operate as routers or gateways. Many workstations can operate as routers or gateways.

35 Mateti, TCP/IP Refresher 35 Modes of Service connection-oriented vs. connectionless connection-oriented vs. connectionless sequencing sequencing error-control error-control flow-control flow-control byte stream vs. message based byte stream vs. message based full-duplex vs. half-duplex. full-duplex vs. half-duplex.

36 Mateti, TCP/IP Refresher 36 Connection-Oriented Service establishment of a logical connection between two processes. establishment of a logical connection between two processes. transfer data transfer data terminate connection. terminate connection.

37 Mateti, TCP/IP Refresher 37 Connectionless Service Sends independent messages. Sends independent messages.

38 Mateti, TCP/IP Refresher 38 Sequencing Sequencing provides support for an order to communications. Sequencing provides support for an order to communications. A service that includes sequencing requires that messages (or bytes) are received in the same order they are sent. A service that includes sequencing requires that messages (or bytes) are received in the same order they are sent.

39 Mateti, TCP/IP Refresher 39 Error Control Some services require error detection. Some services require error detection. Checksums provide a simple error detection mechanism. Checksums provide a simple error detection mechanism. Error control sometimes involves notification and retransmission. Error control sometimes involves notification and retransmission.

40 Mateti, TCP/IP Refresher 40 Flow Control Flow control prevents the sending process from overwhelming the receiving process. Flow control prevents the sending process from overwhelming the receiving process. Flow control can be handled in a variety of ways. Flow control can be handled in a variety of ways.

41 Mateti, TCP/IP Refresher 41 Byte Stream vs. Message Byte stream implies an ordered sequence of bytes with no message boundaries. Byte stream implies an ordered sequence of bytes with no message boundaries. Message oriented services provide communication service to chunks of data called datagrams. Message oriented services provide communication service to chunks of data called datagrams.

42 Mateti, TCP/IP Refresher 42 Full- v. Half-Duplex Full-Duplex services support the transfer of data in both directions. Full-Duplex services support the transfer of data in both directions. Half-Duplex services support the transfer of data in one direction. Half-Duplex services support the transfer of data in one direction.

43 Mateti, TCP/IP Refresher 43 End-to-End v. Hop-to-Hop Service modes, flow control and error control can be Either between endpoints of the communication. Either between endpoints of the communication. Or between consecutive nodes on the path between the endpoints. Or between consecutive nodes on the path between the endpoints.

44 Mateti, TCP/IP Refresher 44 End-to-End Process A Process B

45 Mateti, TCP/IP Refresher 45 Hop-by-Hop Process A Process B

46 Mateti, TCP/IP Refresher 46 Buffering Buffering can provide more efficient communications. Buffering can provide more efficient communications. Buffering is most useful for byte stream services. Buffering is most useful for byte stream services. Process AProcess B Send Buffer Recv. Buffer

47 Mateti, TCP/IP Refresher 47 Addresses Physical Layer: no address necessary Physical Layer: no address necessary Data Link Layer: address must be able to select any host on the network. Data Link Layer: address must be able to select any host on the network. Network Layer: address must be able to provide information to enable routing. Network Layer: address must be able to provide information to enable routing. Transport Layer: address must identify the destination process. Transport Layer: address must identify the destination process.

48 Mateti, TCP/IP Refresher 48 Broadcasts Broadcast = sending a message from one host to all other hosts on the network. Broadcast = sending a message from one host to all other hosts on the network. A special address called the “broadcast address” is created. A special address called the “broadcast address” is created. Some popular network services are based on broadcasting ( YP/NIS, rup, rusers ) Some popular network services are based on broadcasting ( YP/NIS, rup, rusers )

49 Mateti, TCP/IP Refresher 49 The IP in TCP/IP IP is the network layer IP is the network layer packet delivery service (host-to-host). packet delivery service (host-to-host). translation between different data-link protocols. translation between different data-link protocols.

50 Mateti, TCP/IP Refresher 50 IP Datagrams IP provides connectionless, unreliable delivery of IP datagrams. IP provides connectionless, unreliable delivery of IP datagrams. Connectionless: each datagram is independent of all others. Connectionless: each datagram is independent of all others. Unreliable: there is no guarantee that datagrams are delivered correctly or at all. Unreliable: there is no guarantee that datagrams are delivered correctly or at all.

51 Mateti, TCP/IP Refresher 51 IP Addresses The address must include information about what network the receiving host is on. This makes routing feasible. The address must include information about what network the receiving host is on. This makes routing feasible. IP addresses are not the same as the underlying data-link (MAC) addresses. IP addresses are not the same as the underlying data-link (MAC) addresses.

52 Mateti, TCP/IP Refresher 52 IP Addresses Includes a network ID and a host ID. Includes a network ID and a host ID. A Network ID is assigned to an organization by a global authority (http://www.iana.org/ ) A Network ID is assigned to an organization by a global authority (http://www.iana.org/ )http://www.iana.org/ Host IDs are assigned locally by a system administrator. Host IDs are assigned locally by a system administrator.

53 Mateti, TCP/IP Refresher 53 IP Addresses A single NIC is assigned one IP address. A single NIC is assigned one IP address. A host may have multiple NICs, and therefore multiple host addresses. A host may have multiple NICs, and therefore multiple host addresses. Hosts that share a network all have the same IP network address (the network ID). Hosts that share a network all have the same IP network address (the network ID).

54 Mateti, TCP/IP Refresher 54 Subnet Addresses An organization can subdivide it’s host address space into groups called subnets. An organization can subdivide it’s host address space into groups called subnets. The subnet ID is generally used to group hosts based on the physical network topology. The subnet ID is generally used to group hosts based on the physical network topology. It is possible to have a single wire network with multiple subnets. It is possible to have a single wire network with multiple subnets. NetID SubnetID HostID

55 Mateti, TCP/IP Refresher 55 IP4 Addresses Class 0 0 NetID 10 110 NetID 1110 Multicast Address HostID NetID HostID A B C D 8 bits

56 Mateti, TCP/IP Refresher 56 IP Addresses An IP broadcast address has a host- ID of all 1’s. An IP broadcast address has a host- ID of all 1’s. An IP address that has a host ID of all 0’s is called a network address and refers to an entire network. An IP address that has a host ID of all 0’s is called a network address and refers to an entire network.

57 Mateti, TCP/IP Refresher 57 IP Addresses v. MAC Addresses IP Addresses are not recognized by NIC. IP Addresses are not recognized by NIC. The process of finding the MAC address of a host given the IP address is called Address Resolution. The process of finding the MAC address of a host given the IP address is called Address Resolution. The process of finding out the IP address of a host given a hardware address is called Reverse Address Resolution. The process of finding out the IP address of a host given a hardware address is called Reverse Address Resolution.

58 Mateti, TCP/IP Refresher 58 IPv6 addresses Address is 128 bits long (16 bytes) Address is 128 bits long (16 bytes) Addresses are written in hexadecimal Addresses are written in hexadecimal Addresses can be abbreviated Addresses can be abbreviated3FFE:0B00:0000:0000:0000:0000:0000:00013FFE:0B00::00013FFE:B00::1 There is no broadcast addresses, only multicast. There is no broadcast addresses, only multicast. Loopback address is ::1 Loopback address is ::1 Addresses are scoped Addresses are scoped –Link-local, site-local, global

59 Mateti, TCP/IP Refresher 59 IP6 Address 16 bits 3FFE:0B00:1234:0000: 0001 128 bits

60 Mateti, TCP/IP Refresher 60 IP4-Compatible IP6 Address 0000... 0000IP4 Address0000 80 bits32 bits16 bits 80 bits of 0s followed by 16 bits of 0s, followed by a 32 bit IP4 Address:

61 Mateti, TCP/IP Refresher 61 ARP ARP is a broadcast protocol. Each host checks the request against its own host addresses - the matched one responds. ARP is a broadcast protocol. Each host checks the request against its own host addresses - the matched one responds. Hosts remember the hardware addresses of others. Hosts remember the hardware addresses of others. ARP protocol specifies that the receiving host should also remember the IP and hardware addresses of the sending host. ARP protocol specifies that the receiving host should also remember the IP and hardware addresses of the sending host.

62 Mateti, TCP/IP Refresher 62 Services provided by IP Connectionless Delivery (each datagram is treated individually). Connectionless Delivery (each datagram is treated individually). Unreliable (delivery is not guaranteed). Unreliable (delivery is not guaranteed). Fragmentation / Reassembly (based on hardware MTU). Fragmentation / Reassembly (based on hardware MTU). Routing. Routing. Error detection. Error detection.

63 Mateti, TCP/IP Refresher 63 IP Datagram VERSHL Fragment Offset Fragment LengthService Datagram IDFLAG TTLProtocolHeader Checksum Source IP Address Destination IP Address Options (if any) (TCP) Data 1 byte

64 Mateti, TCP/IP Refresher 64 IP Datagram Fragmentation Fragmentation can happen when datagrams are forwarded through a network for which they are too big. Fragmentation can happen when datagrams are forwarded through a network for which they are too big. IP specifies that datagram reassembly is done only at the destination (not on a hop- by-hop basis). IP specifies that datagram reassembly is done only at the destination (not on a hop- by-hop basis). If any of the fragments are lost the entire datagram is discarded (and an ICMP message is sent to the sender). If any of the fragments are lost the entire datagram is discarded (and an ICMP message is sent to the sender).

65 Mateti, TCP/IP Refresher 65 ICMP ( ICMP (Internet Control Message Protocol) ping www.yahoo.com ping www.yahoo.com ICMP uses IP to deliver messages. ICMP uses IP to deliver messages. ICMP messages are usually generated and processed by the IP layer, not the user process. ICMP messages are usually generated and processed by the IP layer, not the user process.

66 Mateti, TCP/IP Refresher 66 ICMP If packets arrive too fast the receiver discards excessive packets and sends an ICMP message to the sender (SOURCE QUENCH). If packets arrive too fast the receiver discards excessive packets and sends an ICMP message to the sender (SOURCE QUENCH). If an error is found (header checksum problem, say) the packet is discarded and an ICMP message is sent to the sender. If an error is found (header checksum problem, say) the packet is discarded and an ICMP message is sent to the sender.

67 Mateti, TCP/IP Refresher 67 ICMP Message Types Echo Request Echo Request Echo Response Echo Response Destination Unreachable Destination Unreachable Redirect Redirect Time Exceeded Time Exceeded Redirect (route change) Redirect (route change) more... more...

68 Mateti, TCP/IP Refresher 68 UDP (User Datagram Protocol) UDP is a transport protocol UDP is a transport protocol Uses IP to deliver datagrams Uses IP to deliver datagrams Connectionless, Unreliable, Minimal Connectionless, Unreliable, Minimal UDP uses ports to provide communication services to individual processes. UDP uses ports to provide communication services to individual processes.

69 Mateti, TCP/IP Refresher 69 Ports Port : an abstract destination point. Port : an abstract destination point. Ports are identified by a positive 16-bit integer. Ports are identified by a positive 16-bit integer. Operating systems provide some mechanism that processes use to specify a port. Operating systems provide some mechanism that processes use to specify a port.

70 Mateti, TCP/IP Refresher 70 Ports Host A Host B Process

71 Mateti, TCP/IP Refresher 71 UDP Datagram Format Source PortDestination Port LengthChecksum Data

72 Mateti, TCP/IP Refresher 72 Sockets

73 Mateti, TCP/IP Refresher 73 Sockets An active socket is connected to a remote active socket. Closing the connection destroys the active sockets at each endpoint. An active socket is connected to a remote active socket. Closing the connection destroys the active sockets at each endpoint. A passive socket is not connected, but rather awaits an incoming connection, which will spawn a new active socket. A passive socket is not connected, but rather awaits an incoming connection, which will spawn a new active socket.

74 Mateti, TCP/IP Refresher 74 Sockets v. Ports A socket is not a port. A socket is associated with a port. This is a many- to-one relationship. A socket is not a port. A socket is associated with a port. This is a many- to-one relationship. Each port can have a single passive socket, awaiting incoming connections, and multiple active sockets, each corresponding to an open connection on the port. Each port can have a single passive socket, awaiting incoming connections, and multiple active sockets, each corresponding to an open connection on the port.

75 Mateti, TCP/IP Refresher 75 TCP Transmission Control Protocol : Transmission Control Protocol : Connection-oriented Connection-oriented Reliable Reliable Full-duplex Full-duplex Byte-Stream Byte-Stream

76 Mateti, TCP/IP Refresher 76 Connection Four Numbers: Source IP Address, Source Port, Destination IP Address, Destination Port Four Numbers: Source IP Address, Source Port, Destination IP Address, Destination Port “connection is established”: Operating Systems of both source and destination hosts are maintaining “state information” re the connection. “connection is established”: Operating Systems of both source and destination hosts are maintaining “state information” re the connection.

77 Mateti, TCP/IP Refresher 77 Connection-Oriented Connection oriented means that a virtual connection is established before any payload data is transferred. Connection oriented means that a virtual connection is established before any payload data is transferred. If the connection cannot be established the user program is notified. If the connection cannot be established the user program is notified. If the connection is ever interrupted the user program is notified. If the connection is ever interrupted the user program is notified.

78 Mateti, TCP/IP Refresher 78 Connection establishment Connection establishment phase is required Connection establishment phase is required Ensures that the receiving process is available and to synchronize sequence numbers, etc. Ensures that the receiving process is available and to synchronize sequence numbers, etc.

79 Mateti, TCP/IP Refresher 79 TCP State Diagram

80 Mateti, TCP/IP Refresher 80 Reliable Every transmission of data is acknowledged by the receiver. Every transmission of data is acknowledged by the receiver. If the sender does not receive ACK within a specified amount of time, the sender retransmits the data. If the sender does not receive ACK within a specified amount of time, the sender retransmits the data. ACK can be piggybacked on data. ACK can be piggybacked on data.

81 Mateti, TCP/IP Refresher 81 Byte Stream Stream means that the connection is treated as a stream of bytes. 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). The user application does not need to package data in individual datagrams (as with UDP).

82 Mateti, TCP/IP Refresher 82 Buffering TCP is responsible for buffering data and determining when it is time to send a datagram. 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. It is possible for an application to tell TCP to send the data it has buffered without waiting for a buffer to fill up.

83 Mateti, TCP/IP Refresher 83 Full Duplex TCP provides transport in both directions. TCP provides transport in both directions. To the application program these appear as two unrelated data streams, although TCP can piggyback control and data communication by providing control information (such as an ACK) along with user data. To the application program these appear as two unrelated data streams, although TCP can piggyback control and data communication by providing control information (such as an ACK) along with user data.

84 Mateti, TCP/IP Refresher 84 TCP Ports Interprocess communication via TCP is achieved with the use of ports (just like UDP). 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). UDP ports have no relation to TCP ports (different name spaces).

85 Mateti, TCP/IP Refresher 85 TCP/UDP Ports Reserved Ports less than 1024: Only root can bind to these ports. Reserved Ports less than 1024: Only root can bind to these ports. Local Port of a process that requested the connection. Usually a random number, 0- 65535. Local Port of a process that requested the connection. Usually a random number, 0- 65535. Remote Port: What application accepted the connection. Usually a known number. /etc/services. E.g., Remote Port: What application accepted the connection. Usually a known number. /etc/services. E.g., –80 for HTTP –143 for IMAP –443 for HTTP/SSL

86 Mateti, TCP/IP Refresher 86 TCP Segments The chunk of data that TCP asks IP to deliver is called a TCP segment. The chunk of data that TCP asks IP to deliver is called a TCP segment. Each segment contains: Each segment contains: –data bytes from the byte stream –control information that identifies the data bytes

87 Mateti, TCP/IP Refresher 87 TCP Segment Format Destination Port Options (if any) Data 1 byte Source Port Sequence Number Request Number 1 byte offsetResControlWindow ChecksumUrgent Pointer

88 Mateti, TCP/IP Refresher 88 Sequence Number The “positional” number of the first data byte in this segment, except when SYN control flag is 1. The “positional” number of the first data byte in this segment, except when SYN control flag is 1. If SYN is 1 the sequence number is the initial sequence number (ISN). If SYN is 1 the sequence number is the initial sequence number (ISN). 32 bit unsigned integer 32 bit unsigned integer

89 Mateti, TCP/IP Refresher 89 Sequence Number Initial Sequence Number (ISN) is randomly generated. Initial Sequence Number (ISN) is randomly generated. What if ISN is not random? What if ISN is not random? –You can hijack and kill arbitrary connections!

90 Mateti, TCP/IP Refresher 90 Acknowledgment Number If the ACK control bit is set, this field contains the value of the next sequence number the sender of the segment is expecting to receive. Once a connection is established this is always included. If the ACK control bit is set, this field contains the value of the next sequence number the sender of the segment is expecting to receive. Once a connection is established this is always included.

91 Mateti, TCP/IP Refresher 91 Control Bits URG: Urgent Pointer field significant URG: Urgent Pointer field significant PSH: Push Function PSH: Push Function ACK: Acknowledgment field significant ACK: Acknowledgment field significant RST: Reset the connection RST: Reset the connection SYN: Synchronize sequence numbers SYN: Synchronize sequence numbers FIN: No more data from sender FIN: No more data from sender

92 Mateti, TCP/IP Refresher 92 TCP v. UDP Q: Which protocol is better ? A: It depends on the application. Q: Which protocol is better ? A: It depends on the application. TCP provides a connection-oriented, reliable byte stream service (lots of overhead). TCP provides a connection-oriented, reliable byte stream service (lots of overhead). UDP offers minimal datagram delivery service (as little overhead as possible). UDP offers minimal datagram delivery service (as little overhead as possible).

93 Mateti, TCP/IP Refresher 93 TCP three-way handshake Establishes a connection. Establishes a connection. 1. A: “I would like to talk to you B.” A sends a SYN packet to B 2. B: “Ok, let's talk.” B sends a SYN-ACK packet to A 3. A: “Thanks for agreeing.” A sends ACK to B

94 Mateti, TCP/IP Refresher 94 TCP three-way handshake Flags src dst seq ack SYN 1037 80 102723769 0 SYN-ACK 80 1037 1527857206 102723770 ACK 1037 80 102723770 1527857207

95 Mateti, TCP/IP Refresher 95 Four-Way Handshake The Four-Way Handshake terminates a previously established connection: The Four-Way Handshake terminates a previously established connection: 1. A to B: FIN 2. B to A: ACK 3. B to A: FIN 4. A to B: ACK

96 Mateti, TCP/IP Refresher 96 Connection Resetting Host X sends an RST packet resetting the connection if: Host X sends an RST packet resetting the connection if: –Y requested a connection to a non- existent port P on host X, or –For whatever reason (idle for a long time, or an abnormal condition,...), the host X (client or the sever) wishes to close the connection. Resetting is unilateral. Resetting is unilateral.


Download ppt "TCP/IP Refresher Prabhaker Mateti (ack: Many many sources …)"

Similar presentations


Ads by Google