1 / 64

FTP Protocol Details

FTP Protocol Details. Tips for the assignment. Socket Programming using TCP. controlled by application developer. controlled by application developer. process. process. socket. socket. TCP with buffers, variables. controlled by operating system. TCP with buffers, variables.

hasana
Download Presentation

FTP Protocol Details

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. FTP Protocol Details Tips for the assignment

  2. Socket Programming using TCP controlled by application developer controlled by application developer process process socket socket TCP with buffers, variables controlled by operating system TCP with buffers, variables controlled by operating system Internet host or server host or server Socket: a door between application process and end-end-transport protocol (UDP or TCP) TCP service: reliable transfer of bytesfrom one process to another

  3. Simple TCP Server-TCP Client

  4. Client Sockets & Server Sockets server client Client socket Welcome socket time Client socket Connection socket bytes

  5. Client/server socket interaction: TCP create socket, connect to hostid, port=x create socket, port=x, for incoming request: clientSocket = Socket() welcomeSocket = Socket() TCP connection setup wait for incoming connection request connectionSocket = accept() send request using clientSocket read request from connectionSocket write reply to connectionSocket read reply from clientSocket close connectionSocket close clientSocket Server(running on hostid) Client Application 2-5

  6. Simple Server Pseudo-Code socket bind listen loop "forever" { accept /* by creating new socket */ /* process the client’s request */ loop until done { receive/send } closesocket(newsocket) }

  7. Simple Client Pseudo-Code socket connect /* process the client’s request */ loop until done { send/receive } closesocket(socket)

  8. Proper Ordering of Send and Recv socket connect /* process the clients request */ loop until done { send/receive } closesocket(socket) socket bind listen loop "forever" { accept /* by creating new socket */ /* process the clients request */ loop until done { receive/send } closesocket(newsocket) }

  9. Test the TCPClient-Server Codes • Run ServerWindows.c • Compile ClientWindows.c, look for the executable. • Run ClientWindows.c from the command prompt to connect to the server: • ClientWindowslocalhost1234 • Alternatively, use IpConfig to find out what your IP address is: (e.g. 130.123.123.111), then connect to the server using: • ClientWindows130.123.123.1111234 • Let’s see how to use the compiler’s debug mode to trace the exchange of messages.

  10. FTP Server

  11. FTP (Multiple Clients) TCP Control Socket C DIR Port 127,0,0,1,6,11 Listening Socket After file transfer TCP Control Socket Quit S TCP Active Data Socket Server • In TCP, the Server should be running already prior to a Client connecting to it

  12. FTP Operation

  13. FTP Operation CLIENT SERVER Control connection Data connection Note that Ports 1216 & 1217 are ephemeral ports. Any port [1024, 65535] will work. Source: Computer Networking and the Internet (5/e) by Fred Halsall

  14. FTP Commands Source: Computer Networking and the Internet (5/e) by Fred Halsall

  15. FTP Reply Codes Source: Computer Networking and the Internet (5/e) by Fred Halsall

  16. Active FTP (or Standard ) Standard (or PORT or Active) The Standard mode FTP client sends PORT commands to the FTP server. These commands are sent over the FTP command channel when establishing the FTP session. Operation Standard mode FTP clients first establish a connection to TCP port 21 on the FTP server. This connection establishes the FTP command channel. The client sends a PORT command over the FTP command channel when the FTP client needs to send or receive data, such as a folder list or file. The PORT command contains information about which port the FTP client receives the data connection on. In Standard mode, the FTP server always starts the data connection from TCP port 20. The FTP server must open a new connection to the client when it sends or receives data, and the FTP client requests this by using the PORT command again.

  17. Passive FTP (or PASV) Passive (or PASV) The Passive mode client sends PASV commands to the FTP Server. Operation Passive mode FTP clients also start by establishing a connection to TCP port 21 on the FTP server to create the control channel. When the client sends a PASV command over the command channel, the FTP server opens an ephemeral port (between 1024 and 5000) and informs the FTP client to connect to that port before requesting data transfer. As in Standard mode, the FTP client must send a new PASV command prior to each new transfer, and the FTP server will await a connection at a new port for each transfer.

  18. Active FTP mode p. 50, RFC 959

  19. ACTIVE FTP Operation SERVER CLIENT control connection control connection Data connection Data connection Port 20 Port 21 Port 1120 Port 1121 Passive open time time time time Source: Computer Networking and the Internet (5/e) by Fred Halsall

  20. ACTIVE FTP Operation SERVER CLIENT control connection control connection Data connection Data connection Port 20 Port 21 Port 1120 Port 1121 Active open Passive open time time time time Source: Computer Networking and the Internet (5/e) by Fred Halsall

  21. ACTIVE FTP Operation SERVER CLIENT control connection control connection Data connection Data connection Port 20 Port 21 Port 1120 Port 1121 Active open Passive open TCP control connection to Port 21 established time time time time Source: Computer Networking and the Internet (5/e) by Fred Halsall

  22. ACTIVE FTP Operation SERVER CLIENT control connection control connection Data connection Data connection Port 20 Port 21 Port 1120 Port 1121 Active open Passive open TCP control connection to Port 21 established 220 FTP server ready time time time time Source: Computer Networking and the Internet (5/e) by Fred Halsall

  23. ACTIVE FTP Operation SERVER CLIENT control connection control connection Data connection Data connection Port 20 Port 21 Port 1120 Port 1121 Active open Passive open TCP control connection to Port 21 established 220 FTP server ready USER <username> time time time time Source: Computer Networking and the Internet (5/e) by Fred Halsall

  24. ACTIVE FTP Operation SERVER CLIENT control connection control connection Data connection Data connection Port 20 Port 21 Port 1120 Port 1121 Active open Passive open TCP control connection to Port 21 established 220 FTP server ready USER <username> 331 password required time time time time Source: Computer Networking and the Internet (5/e) by Fred Halsall

  25. ACTIVE FTP Operation SERVER CLIENT control connection control connection Data connection Data connection Port 20 Port 21 Port 1120 Port 1121 Active open Passive open TCP control connection to Port 21 established 220 FTP server ready USER <username> 331 password required PASS <password> time time time time Source: Computer Networking and the Internet (5/e) by Fred Halsall

  26. ACTIVE FTP Operation SERVER CLIENT control connection control connection Data connection Data connection Port 20 Port 21 Port 1120 Port 1121 Active open Passive open TCP control connection to Port 21 established 220 FTP server ready USER <username> 331 password required PASS <password> 220 user <username> logged in time time time time Source: Computer Networking and the Internet (5/e) by Fred Halsall

  27. ACTIVE FTP Operation SERVER CLIENT control connection control connection Data connection Data connection Port 20 Port 21 Port 1120 Port 1121 Active open Passive open TCP control connection to Port 21 established 220 FTP server ready USER <username> 331 password required PASS <password> 220 user <username> logged in SYST time time time time Source: Computer Networking and the Internet (5/e) by Fred Halsall

  28. ACTIVE FTP Operation SERVER CLIENT control connection control connection Data connection Data connection Port 20 Port 21 Port 1120 Port 1121 Active open Passive open TCP control connection to Port 21 established 220 FTP server ready USER <username> 331 password required PASS <password> 220 user <username> logged in SYST 215 UNIX Type:XVersion:Y time time time time Source: Computer Networking and the Internet (5/e) by Fred Halsall

  29. ACTIVE FTP Operation SERVER CLIENT control connection control connection Data connection Data connection Port 20 Port 21 Port 1120 Port 1121 Active open Passive open TCP control connection to Port 21 established 220 FTP server ready USER <username> 331 password required PASS <password> 220 user <username> logged in get <filename.type> time time time time Source: Computer Networking and the Internet (5/e) by Fred Halsall

  30. ACTIVE FTP Operation SERVER CLIENT control connection control connection Data connection Data connection Port 20 Port 21 Port 1120 Port 1121 Active open Passive open TCP control connection to Port 21 established 220 FTP server ready USER <username> 331 password required PASS <password> 220 user <username> logged in PORT n1-n6 get <filename.type> time time time time Source: Computer Networking and the Internet (5/e) by Fred Halsall

  31. ACTIVE FTP Operation SERVER CLIENT control connection control connection Data connection Data connection Port 20 Port 21 Port 1120 Port 1121 Active open Passive open TCP control connection to Port 21 established 220 FTP server ready USER <username> 331 password required PASS <password> 220 user <username> logged in PORT n1-n6 get <filename.type> 200 PORT command successful time time time time Source: Computer Networking and the Internet (5/e) by Fred Halsall

  32. ACTIVE FTP Operation SERVER CLIENT control connection control connection Data connection Data connection Port 20 Port 21 Port 1120 Port 1121 Active open Passive open TCP control connection to Port 21 established 220 FTP server ready USER <username> 331 password required PASS <password> 220 user <username> logged in PORT n1-n6 get <filename.type> 200 PORT command successful RETR <filename.type> time time time time Source: Computer Networking and the Internet (5/e) by Fred Halsall

  33. ACTIVE FTP Operation SERVER CLIENT control connection control connection Data connection Data connection Port 20 Port 21 Port 1120 Port 1121 Active open Passive open TCP control connection to Port 21 established 220 FTP server ready USER <username> 331 password required PASS <password> 220 user <username> logged in PORT n1-n6 get <filename.type> 200 PORT command successful RETR <filename.type> 150 opening ASCII mode data connection time time time time Source: Computer Networking and the Internet (5/e) by Fred Halsall

  34. ACTIVE FTP Operation SERVER CLIENT control connection control connection Data connection Data connection Port 20 Port 21 Port 1120 Port 1121 Active open Passive open TCP control connection to Port 21 established 220 FTP server ready USER <username> 331 password required PASS <password> 220 user <username> logged in PORT n1-n6 get <filename.type> 200 PORT command successful Server does an active open to Port n5, n6 RETR <filename.type> 150 opening ASCII mode data connection time time time time Source: Computer Networking and the Internet (5/e) by Fred Halsall

  35. ACTIVE FTP Operation SERVER CLIENT control connection control connection Data connection Data connection Port 20 Port 21 Port 1120 Port 1121 Active open Passive open TCP control connection to Port 21 established 220 FTP server ready USER <username> 331 password required PASS <password> 220 user <username> logged in PORT n1-n6 get <filename.type> 200 PORT command successful Server does an active open to Port n5, n6 RETR <filename.type> 150 opening ASCII mode data connection Send file through data connection time time time time Source: Computer Networking and the Internet (5/e) by Fred Halsall

  36. ACTIVE FTP Operation SERVER CLIENT control connection control connection Data connection Data connection Port 20 Port 21 Port 1120 Port 1121 Active open Passive open TCP control connection to Port 21 established 220 FTP server ready USER <username> 331 password required PASS <password> 220 user <username> logged in PORT n1-n6 get <filename.type> 200 PORT command successful Server does an active open to Port n5, n6 RETR <filename.type> 150 opening ASCII mode data connection Send file through data connection 226 File transfer complete User prompted for a conmand time time time Source: Computer Networking and the Internet (5/e) by Fred Halsall

  37. ACTIVE FTP Operation SERVER CLIENT control connection control connection Data connection Data connection Port 20 Port 21 Port 1120 Port 1121 Active open Passive open TCP control connection to Port 21 established 220 FTP server ready USER <username> 331 password required PASS <password> 220 user <username> logged in PORT n1-n6 get <filename.type> 200 PORT command successful Server does an active open to Port n5, n6 RETR <filename.type> 150 opening ASCII mode data connection Send file through data connection 226 File transfer complete QUIT User prompted for a conmand time Source: Computer Networking and the Internet (5/e) by Fred Halsall

  38. ACTIVE FTP Operation SERVER CLIENT control connection control connection Data connection Data connection Port 20 Port 21 Port 1120 Port 1121 Active open Passive open TCP control connection to Port 21 established 220 FTP server ready USER <username> 331 password required PASS <password> 220 user <username> logged in PORT n1-n6 get <filename.type> 200 PORT command successful Server does an active open to Port n5, n6 RETR <filename.type> 150 opening ASCII mode data connection Send file through data connection 226 File transfer complete, QUIT User prompted for a conmand 221 Goodbye time Source: Computer Networking and the Internet (5/e) by Fred Halsall

  39. ACTIVE FTP Operation SERVER CLIENT control connection control connection Data connection Data connection Port 20 Port 21 Port 1120 Port 1121 Active open Passive open TCP control connection to Port 21 established 220 FTP server ready USER <username> 331 password required PASS <password> 220 user <username> logged in PORT n1-n6 get <filename.type> 200 PORT command successful Server does an active open to Port n5, n6 RETR <filename.type> 150 opening ASCII mode data connection Send file through data connection 226 File transfer complete, QUIT User prompted for a conmand Server closes data connection first , then control connection 221 Goodbye time Source: Computer Networking and the Internet (5/e) by Fred Halsall

  40. Passive FTP mode

  41. PASSIVEFTP Operation SERVER CLIENT control connection Data connection Data connection control connection Port 2024 Port 21 Port 1120 Port 1121 Passive open time time time time Source: Computer Networking and the Internet (5/e) by Fred Halsall

  42. PASSIVEFTP Operation SERVER CLIENT control connection Data connection Data connection control connection Port 2024 Port 21 Port 1120 Port 1121 Active open Passive open time time time time Source: Computer Networking and the Internet (5/e) by Fred Halsall

  43. PASSIVE FTP Operation SERVER CLIENT control connection Data connection Data connection control connection Port 2024 Port 21 Port 1120 Port 1121 Active open Passive open TCP control connection to Port 21 established time time time time Source: Computer Networking and the Internet (5/e) by Fred Halsall

  44. PASSIVE FTP Operation SERVER CLIENT control connection Data connection Data connection control connection Port 2024 Port 21 Port 1120 Port 1121 Active open Passive open TCP control connection to Port 21 established 220 FTP server ready time time time time Source: Computer Networking and the Internet (5/e) by Fred Halsall

  45. PASSIVE FTP Operation SERVER CLIENT control connection Data connection Data connection control connection Port 2024 Port 21 Port 1120 Port 1121 Active open Passive open TCP control connection to Port 21 established 220 FTP server ready USER <username> time time time time Source: Computer Networking and the Internet (5/e) by Fred Halsall

  46. PASSIVE FTP Operation SERVER CLIENT control connection Data connection Data connection Data connection control connection Port 2024 Port 21 Port 1120 Port 1121 Active open Passive open TCP control connection to Port 21 established 220 FTP server ready USER <username> 331 password required time time time time Source: Computer Networking and the Internet (5/e) by Fred Halsall

  47. PASSIVE FTP Operation SERVER CLIENT control connection Data connection Data connection control connection Port 2024 Port 21 Port 1120 Port 1121 Active open Passive open TCP control connection to Port 21 established 220 FTP server ready USER <username> 331 password required PASS <password> time time time time Source: Computer Networking and the Internet (5/e) by Fred Halsall

  48. PASSIVE FTP Operation SERVER CLIENT control connection Data connection Data connection control connection Port 2024 Port 21 Port 1120 Port 1121 Active open Passive open TCP control connection to Port 21 established 220 FTP server ready USER <username> 331 password required PASS <password> 220 user <username> logged in time time time time Source: Computer Networking and the Internet (5/e) by Fred Halsall

  49. PASSIVE FTP Operation SERVER CLIENT control connection Data connection Data connection control connection Port 2024 Port 21 Port 1120 Port 1121 Active open Passive open TCP control connection to Port 21 established 220 FTP server ready USER <username> 331 password required PASS <password> 220 user <username> logged in SYST time time time time Source: Computer Networking and the Internet (5/e) by Fred Halsall

  50. PASSIVE FTP Operation SERVER CLIENT control connection Data connection Data connection control connection Port 2024 Port 21 Port 1120 Port 1121 Active open Passive open TCP control connection to Port 21 established 220 FTP server ready USER <username> 331 password required PASS <password> 220 user <username> logged in SYST 215 UNIX Type:XVersion:Y time time time time Source: Computer Networking and the Internet (5/e) by Fred Halsall

More Related