ftp

35

Upload: teja-bheemanapally

Post on 16-Nov-2014

102 views

Category:

Technology


3 download

DESCRIPTION

 

TRANSCRIPT

TCP/IP Protocol Suite 2

21-1 FTP

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, some problems must be dealt with first. For example, 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.

TCP/IP Protocol Suite 3

Topics Discussed in the Section

Connections Communication Command Processing File Transfer Anonymous FTP Security for FTP The sftp Program

TCP/IP Protocol Suite 4

FTP uses the services of TCP. It needs two TCP connections. The well-

known port 21 is used for the control connection and the well-known port 20 for the data connection.

Note

TCP/IP Protocol Suite 5

Figure 21.1 FTP

TCP/IP Protocol Suite 6

Figure 21.2 Opening the control connection

TCP/IP Protocol Suite 7

Figure 21.3 Creating the data connection

TCP/IP Protocol Suite 8

Figure 21.4 Using the control connection

TCP/IP Protocol Suite 9

Figure 21.5 Using the data connection

TCP/IP Protocol Suite 10

Figure 21.6 Command processing

TCP/IP Protocol Suite 11

TCP/IP Protocol Suite 12

TCP/IP Protocol Suite 13

TCP/IP Protocol Suite 14

TCP/IP Protocol Suite 15

TCP/IP Protocol Suite 16

TCP/IP Protocol Suite 17

TCP/IP Protocol Suite 18

TCP/IP Protocol Suite 19

Figure 21.6 Command processing

TCP/IP Protocol Suite 20

Figure 21.7 File transfer

TCP/IP Protocol Suite 21

TCP/IP Protocol Suite 22

TCP/IP Protocol Suite 23

TCP/IP Protocol Suite 24

TCP/IP Protocol Suite 25

TCP/IP Protocol Suite 26

TCP/IP Protocol Suite 27

TCP/IP Protocol Suite 28

TCP/IP Protocol Suite 29

Figure 21.7 File transfer

TCP/IP Protocol Suite 30

Figure 21.8 shows an example of using FTP for retrieving a list of items in a directory.

Example 21.1

TCP/IP Protocol Suite 31

Figure 21.8 Example 21.1

220 (Service ready)

USER forouzan

LIST /usr/user/forouzan/reports

PASS xxxxxx

125 (Data connection OK)

331 (User name OK. Password?)

PORT 8888

150 (Data connection opens shortly)

230 (User login OK)

1

2

3

4

5

6

7

8

9

List of files or directories

List of files or directories

10

11

QUIT

226 (Closing data connection)

221 (Service closing)

12

13

14

DATATRANSFER

TCP/IP Protocol Suite 32

The following shows an actual FTP session that parallels Example 21.1. The colored lines show the responses from the server control connection; the black lines show the commands sent by the client. The lines in white with black background show data transfer.

Example 21.2

TCP/IP Protocol Suite 33

Figure 21.9 shows an example of how an image (binary) file is stored.

Example 21.3

TCP/IP Protocol Suite 34

Figure 21.9 Example 21.3

220 (Service ready)

USER forouzan

TYPE EBCDIC

STRU R

STOR/usr/user/forouzan/reports/file1

PASS xxxxxx

200 (OK)

200 (OK)

250 (OK)

331 (User name OK. Password?)

PORT 1267

150 (Data connection opens shortly)

230 (User login OK)

1

2

3

4

5

6

7

8

9

10

11

12

13

DATATRANSFER

Records of file ..........

Records of file ..........15

14

QUIT

226 (Closing data connection)

221 (Service closing)

16

17

18

TCP/IP Protocol Suite 35

We show an example of anonymous FTP. We assume that some public data are available at internic.net.

Example 21.4