#1. Protocol Specification The following section specifies the protocol for communication between the myftp client and the myftpd server. ##1.1. Transport Layer Protocol and Port Number The transport layer protocol used is TCP (transmission control protocol). The default port for the myftp protocol is 40903.
Message Sequence and Format
1. The client sends one message to the server to request a file upload. The message format is given below:
- one byte opcode, which is ASCII character P, followed by
- two-byte integer in two's compliment and in network byte order, which represents the length of the file name of the file sent to the server by
- the sequence of ASCII characters representing the file name
- one byte opcode which is ASCII character P followed by
- one-byte acknowledgement code, which is one of the following ASCII characters:
- 0 - The server is ready to accept the named file
- 1 - The server cannot accept the file because a file with the same name already exists in the target directory.
- 2 - The server cannot accept the file because it cannot create the named file.
- 3 - Server cannot accept due to miscellaneous error.
3. Once the client receives the P message from the server and if the acknowledgement code is 0, it responds with the following message:
- one byte opcode which is the ASCII character Q followed by
- four byte integer in two's compliment and in network byte order which represents the length of the file followed by
- a sequence of N bytes which is the content of the file. Files are transferred in 5120 byte blocks. If the file size is above 5120 bytes, multiple read/ writes must be constructed.
- a one byte opcode which is ASCII character Q followed by
- a one byte status code, which is one of the following ASCII characters:
- 0 - File successfully written to disk
- 1 - Server unable to write file to disk
Opcode Length file name
Opcode Status
Opcode Length file contents
Opcode status
P 7 foo.txt
P 0
Q 1335 foo.txt contents
Q 0
Message Sequence and Format
1. The client sends a message to the server to request a file download. The message format is given below:
- one byte opcode, which is ASCII character G, followed by
- two-byte integer in two's compliment and in network byte order, which represents the length of the file name of the file downloaded from the server by
- the sequence of ASCII characters representing the file name
- one byte opcode which is ASCII character G followed by
- one-byte acknowledgement code, which is one of the following ASCII characters:
- 0 - The server is ready to send the named file to the client
- 1 - The file name specified does not exist
- 2 - File permissions error
- 3 - The server cannot send file due to miscellaneous error.
3. Once the client receives the G message from the server and if the acknowledgement code is 0, it issues the following message:
- one byte opcode which is the ASCII character H followed by
- four byte integer in two's compliment and in network byte order which represents the length of the file followed by
- a sequence of N bytes which is the content of the file
- a one byte opcode which is ASCII character H followed by
- a one byte status code, which is one of the following ASCII characters:
- 0 - File transfer initiated successfully
- 1 - File name specified does not exist
- 2 - File permission error
- 3 - The server encountered a miscellaneous error
- four byte integer in two's compliment and in network byte order which represents the length of the file followed by
- a sequence of N bytes which is the content of the file. Files are transferred in 5120 byte blocks. If the file size is above 5120 bytes, multiple read/ writes must be constructed.
opcode length file name
opcode status
opcode length file name
opcode status length file content
G 7 bar.txt
G 0
H 7 bar.txt
H 0 1400 bar.txt file contents
Message Sequence and Format
1. The client sends a message to the server to request the current directory of the server. The message format is given below:
- one byte opcode, which is ASCII character W
- one byte opcode, which is ASCII character W, followed by
- two-byte integer in two's compliment and in network byte order, which represents the length of the path returned in the result
- a one byte status code containing one of the following ASCII characters:
- 0 - Command completed successfully
- 1 - Miscellaneous error
- a sequence of ASCII characters representing the current path
opcode
opcode length status path
W
W 16 0 /home/user/temp
Message Sequence and Format
1. The client sends a message to the server to request the contents of the current directory of the server. The message format is given below:
- one byte opcode, which is ASCII character D
- one byte opcode, which is ASCII character D followed by
- two-byte integer in two's compliment and in network byte order, which represents the length of the list of files
- a one byte status code containing one of the following ASCII characters:
- 0 - Navigated directory successfully
- 1 - Miscellaneous error
- a sequence of ASCII characters representing the current directory contents
opcode
opcode length status list of files
D
D 23 0 foo.txt bar.txt baz.txt
Message Sequence and Format
1. The client sends a message to the server to request a change of the host directory. The message format is given below:
- one byte opcode, which is ASCII character C
- a two-byte integer in two's compliment and in network byte order, which represents the length of the directory to navigate to
- a sequence of ASCII characters representing the host directory to navigate to
- one byte opcode, which is ASCII character C followed by
- a one byte status code containing one of the following ASCII characters:
- 0 - Navigated to given directory successfully
- 1 - Miscellaneous error
opcode length directory
opcode result
C 16 /home/user/temp
C 0