1 NET 323 D NETWORKS PROTOCOLS Networks and

  • Slides: 25
Download presentation
1 NET 323 D: NETWORKS PROTOCOLS Networks and Communication Department Lecture 12: Application Layer

1 NET 323 D: NETWORKS PROTOCOLS Networks and Communication Department Lecture 12: Application Layer (FTP)

Introduction 2 The main task of the Internet is to provide services for users.

Introduction 2 The main task of the Internet is to provide services for users. One of the most popular applications is file transfer

FILE TRANSFER 3 File Transfer Protocol (FTP) is the standard mechanism provided by TCP/IP

FILE TRANSFER 3 File Transfer Protocol (FTP) is the standard mechanism provided by TCP/IP for copying a file from one host to another. Although transferring files from one system to another seems simple and straightforward. Before transferring, some problems must be dealt with first, such as: two systems may use different file name conventions. � Two systems may have different ways to represent text and data. � Two systems may have different directory structures. � All of these problems have been solved by FTP in a very simple and elegant approach.

FILE TRANSFER cont. 4 FTP differs from other client-server applications in that it establishes

FILE TRANSFER cont. 4 FTP differs from other client-server applications in that it establishes two connections between the hosts. One connection is used for data transfer, the other for control information (commands and responses). Separation of commands and data transfer makes FTP more efficient. We need to transfer only a line of command or a line of response at a time.

FILE TRANSFER cont. 5 The control connection uses very simple rules of communication. The

FILE TRANSFER cont. 5 The control connection uses very simple rules of communication. The data connection, on the other hand, needs more complex rules due to the variety of data types transferred. FTP uses two well-known TCP ports: � Port 21 is used for the control connection, � Port 20 is used for the data connection.

FTP (File Transfer Protocol) 6

FTP (File Transfer Protocol) 6

1 -Control Connection 7 There are two steps: 1. 2. The server issues a

1 -Control Connection 7 There are two steps: 1. 2. The server issues a passive open on the well-known port 21 and waits for a client. The client uses an ephemeral port and issues an active open. The connection remains open during the entire process. The user types commands and expects to receive responses without significant delay.

Opening the control connection 8

Opening the control connection 8

2 - Data Connection 9 The data connection uses the well-known port 20 at

2 - Data Connection 9 The data connection uses the well-known port 20 at the server site. The following shows how FTP creates a data connection: 1. The client, not the server, issues a passive open using an ephemeral port. 2. The client sends this port number to the server using the PORT command. 3. The server receives the port number and issues an active open using the well known port 20 and the received ephemeral port number.

Creating the data connection 10

Creating the data connection 10

2 - Data Connection cont. 11 The data connection is opened and then closed

2 - Data Connection cont. 11 The data connection is opened and then closed for each file transferred. It opens each time commands that involve transferring files are used, and it closes when the file is transferred. While the control connection is open, the data connection can be opened and closed multiple times if several files are transferred.

Communication 12 The FTP client and server, which run on different computers, must communicate

Communication 12 The FTP client and server, which run on different computers, must communicate with each other. These two computers may use: different operating systems Ø different character sets Ø different file structures Ø different file formats Ø FTP must make this heterogeneity compatible. FTP has two different approaches, one for the control connection and one for the data connection.

1 -Communication over Control Connection 13 It uses the 7 -bit ASCII character set.

1 -Communication over Control Connection 13 It uses the 7 -bit ASCII character set. Communication is achieved through commands and responses. Each command or response is only one short line, so we need not worry about file format or file structure. Each line is terminated with a two-character (carriage return and line feed) end-of-line token.

Using the control connection 14

Using the control connection 14

2 -Communication over Data Connection 15 File transfer occurs over the data connection under

2 -Communication over Data Connection 15 File transfer occurs over the data connection under the control of the commands sent over the control connection. We prepare for transmission through the control connection. The heterogeneity problem is resolved by defining three attributes of communication before sending the file through the data connection : file type � data structure � transmission mode �

1 - File Type � � � ASCII file: By default for transferring text

1 - File Type � � � ASCII file: By default for transferring text files. Sender transforms the file from its own representation to ASCII characters Receiver transforms the ASCII characters to its own representation. EBCDIC file If one or both ends of connection use EBCDIC encoding (used in IBM computers) the file can be transferred using EBCDIC encoding. Image file Default format for transferring binary files File is sent as continuous streams of bits without any interpretation or encoding Used for compiled programs or images.

2 - Data Structure � FTP can transfer a file across the data connection

2 - Data Structure � FTP can transfer a file across the data connection using one of the following interpretations about structure of data: File structure (default) File has no structure. Continuous stream of bytes Record structure File is divided into records Used only with text files. Page structure File is divided into pages, with each page having a page number and a page header.

3 - Transmission mode FTP can transfer a file across the data connection by

3 - Transmission mode FTP can transfer a file across the data connection by using one of following three transmission modes: � Stream mode Default mode Data is delivered from FTP to TCP as a continuous stream of bytes; TCP is responsible for chopping data into segments of appropriate size. End-of-file is closing of data connection by sender. � Block mode Data can be delivered from FTP to TCP in blocks. Block is preceded by 3 -byte header. 1 st byte is called the block descriptor; next 2 bytes defines the size of block in bytes. �

3 - Transmission mode cont. � Compressed mode If file is big, data can

3 - Transmission mode cont. � Compressed mode If file is big, data can be compressed. Commonly used compression method is run-length encoding. Consecutive appearance of a data unit are replaced by one occurrence and number of repetitions. Usually, Blanks in text file and null characters in binary file are compressed.

Using the data connection 20

Using the data connection 20

Command Processing 21 FTP uses the control connection to establish a communication between the

Command Processing 21 FTP uses the control connection to establish a communication between the client control process and the server control process. During this communication, the commands are sent from the client to the server and the responses are sent from the server to the client.

Commands 22 Commands are sent from the FTP client control process. are in the

Commands 22 Commands are sent from the FTP client control process. are in the form of ASCII uppercase, which may or may not be followed by an argument. commands are divided into six groups: � access commands � file management commands � data formatting commands � port defining commands � file transferring commands � miscellaneous commands

Responses 23 Every FTP command generates at least one response. A response has two

Responses 23 Every FTP command generates at least one response. A response has two parts: a three digit number followed by text. The numeric part defines the code. � The first digit defines the status of the command. � The second digit also defines the status of the command � The third digit provides additional information the text part defines needed parameters or extra explanations.

File Transfer 24 File transfer in FTP means one of three things: Retrieving: A

File Transfer 24 File transfer in FTP means one of three things: Retrieving: A file is to be copied from the server to the client. � It is done under the supervision of the RETR command. � Storing: A file is to be copied from the client to the server. � It is done under the supervision of the STOR command. � List: A list of directory or file names is to be sent from the server to the client. � This is done under the supervision of the LIST command. � FTP treats a list of directory or file names as a file. �

File Transfer cont. 25

File Transfer cont. 25