950 likes | 1.32k Views
TCP/IP Protocol Stack. Overview. To communicate, two machines have to use the same protocol TCP/IP has become the defacto protocol for the transport and network layers of the network stack Application layer is informally represented by system libraries. Overview.
E N D
Overview • To communicate, two machines have to use the same protocol • TCP/IP has become the defacto protocol for the transport and network layers of the network stack • Application layer is informally represented by system libraries
Overview • TCP/IP is based on the Client/Server model • One machine/host is called the Server and provides services. The Server LISTENS for requests • The other side of the connection is a client, that initiates the connection by requesting services from a server
Overview • Peer to Peer relationships, (Microsoft file sharing, Bit Torrent) are represented by having both machines act as both clients and servers • There is no special support for Peer to Peer communication in TCP/IP
TCP/IP Transport Layer • There are two major protocols used for delivering data at the transport layer: • TCP, and • UDP.
TCP/IP Transport Layer • UDP is a simple protocol that does not promise delivery of packets.
TCP/IP Transport Layer • TCP is a more complicated protocol that does promise packet delivery.
TCP/IP Service Ports • Both TCP and UDP use numeric port numbers to do their work. • These port number represent virtual or imaginary ports. • In many ways, these resemble the physical ports you plug devices into on your computer.
Service Ports • Physical ports include • Parallel port for older printers • Comm ports for external modems • USB port is actually a kind of simple network connection
TCP/IP Service Ports • The reason for ports is that computers can communicate for a number of different reasons. • For example, web pages, email, streaming video. • The ports identify • the program (service) that a client is requesting from a server • The program on the client that the server is replying to.
TCP/IP Service Ports • These port numbers can be used to indicate the program (client or server) • sending a packet, or • Receiving a packet. • This makes sure that information (the packets) get sent to the correct program running on the computer.
TCP/IP Service Ports • For instance servers for • http (web pages) typically use port 80.
TCP/IP Service Ports • For instance servers for • POP3 (downloading email) typically use port 110
TCP/IP Service Ports • For instance servers for • SMTP (sending email) typically use port 25.
TCP/IP Service Ports • It is however possible to set up services to use non-standard port numbers.
TCP/IP Service Ports • It is however possible to set up services to use non-standard port numbers. • You could set up a http/web server that uses port 1234 if you wanted. 8080 is commonly used for private web servers. • Typically, standard ports are used, called Well Known Ports, because it makes services easier for clients to find.
Service Ports – Client Side • Typically Client machines are assigned random ports by the operating system when they request a connection to a server. • These ports are assigned outside the usual range of numbers for server ports.
TCP/IP UDP • The UDP Protocol is conceptually very simple. • Packets are sent to their destination. • No effort is made to ensure their delivery. • Overhead is very low, so there is very little delay . . . If the Packet makes it. • In practice, modern networks are very reliable
TCP/IP UDP • UDP is typically used for situations when the loss of an occasional packet is acceptable. • For example, streaming audio or video might use UDP. • UDP is used in “real time” applications, were delay is not easily tolerated • Communication with monitoring sensors.
TCP/IP TCP • The TCP protocol is used when it is important that each packet be delivered. • For example, when sending • Compressed video or image file. • A computer program. • Situations where the loss or mix-up of a packet would corrupt the information being sent.
TCP/IP TCP • TCP has multiple ways to ensure packets are delivered. • An important way is acknowledgement (ACK). • When a message is received at its destination, an acknowledgement message is sent back to the source. • The ACK tells not just that a message was received, but exactly which message was received.
TCP/IP TCP • Because of the overhead for ensuring delivery, TCP is slower than UDP. • Nothing comes for free. • Delays on individual packets, can reach several seconds before the connection is abandoned. Up to 60 second delays are tolerated
TCP/IP TCP • Overhead is extra computer operations that the computer must do, such as sending and receiving acknowledgement messages. • Since each computer instruction takes time, overhead slows down the task the computer is performing.
TCP/IP ICMP • In addition to TCP and UDP, there is an additional protocol, ICMP.
TCP/IP ICMP • ICMP (Internet Control Message Protocol) is used for • diagnosing, and • reporting network errors.
TCP/IP ICMP • ICMP is also a great protocol to use (abuse!) as the basis for network attacks. • We will discuss precisely how . . . Later.
TCP-based Communications TCP • TCP is the work-horse transport level protocol on the Internet. • Much of the information that gets sent across the Internet uses TCP. • Most applications cannot tolerate • Lost packets, or • Packets that arrive out of order.
TCP-based Communications TCP • TCP • ensures delivery, • in the proper order of packets sent between two computers.
TCP-based Communications TCP • To do this, it uses several mechanisms:
TCP-based Communications TCP • To do this, it uses several mechanisms: • Exclusive TCP Connection - hosts establish a session that allows them to track the traffic between them.
TCP-based Communications TCP • To do this, it uses several mechanisms: • TCP Sequence Numbers - packets sent using TCP have packet sequence numbers.
TCP-based Communications TCP • To do this, it uses several mechanisms: • Acknowledgements - Using sequence numbers, the recipient acknowledges packets received.
TCP-based Communications TCP Connection • The host requesting a TCP connection is known as the client, and the other is the server. • Because the client is requesting a service from the server.
TCP-based Communications TCP Connection • A potential sender and receiver establish a TCP connection by a procedure known as a handshake.
TCP-based Communications TCP Connection • The handshake procedure:
TCP-based Communications TCP Connection • The handshake procedure: • The client sends a SYN message(SYNc) to request a TCP connection with the server.
TCP-based Communications TCP Connection • The handshake procedure: • The client sends a SYN message(SYNc) to request a TCP connection with the server. • A server returns a single packet that both • Acknowledges (ACKc) the client’s SYN, and • Sends its own connection request (SYNs).
TCP-based Communications TCP Connection • The handshake procedure: • The client sends a SYN message(SYNc) to request a TCP connection with the server. • A server returns a single packet that both • Acknowledges (ACKc) the client’s SYN, and • Sends its own connection request (SYNs). • The client acknowledges (ACKs) the server’s message.
TCP-based Communications TCP Connection • The handshake procedure: • The client sends a SYN message(SYNc) to request a TCP connection with the server. • A server returns a single packet that both • Acknowledges (ACKc) the client’s SYN, and • Sends its own connection request (SYNs). • The client acknowledges (ACKs) the server’s message. • After the handshake, the connection is established.
TCP Handshake • The TCP handshake is often represented using a timeline.
Client Server Time TCP-based Communications TCP Handshake
Client Server Send SYNc TCP-based Communications TCP Handshake
Client Server Send SYNc SYNc TCP-based Communications TCP Handshake
Client Server Send SYNc Receive SYNc SYNc TCP-based Communications TCP Handshake
Client Server Send SYNc Receive SYNc SYNc Send SYNs/ACKs TCP-based Communications TCP Handshake