[컴퓨터망] 21. File Transfer:FTP&TFTP

서정윤·2022년 7월 8일
0

컴퓨터망

목록 보기
5/7

1. FTP

FTP란 File Transfer Protocol의 약어로, 한 host에서 다른 host로 file을 copying하는 mechanism이다.

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

FTP는 TCP기반의 서비스로, 두가지의 TCP 연결이 필요하다.

  • port 21 : control connection
  • port 22 : data connection

Connections

opening the control connection

Control connection 과정은 다른 응용프로그램과 같다
1. 서버는 port 21번에 passive open하고 클라이언트를 기다린다.
2. 클라이언트는 임의의 포트번호로 active open

creating the data connection

Data connection 과정은 server port 20번을 사용한다.
1. client가 임의의 포트 번호로 passive open한다.
2. 1에서 설정한 포트 번호를 control connection 통해서 전송한다.
3. 서버가 해당 포트번호를 받고 port 20번으로 active open한다.

using the control connection


ftp도 TELNET이랑 SMTP 처럼 control connection 할 때 NVT ASCII character set을 사용한다.

using the data connection

Data connection을 통해 파일을 전송한다.
client는 보낼 file의 type, 데이터 구조, 전송 모드를 정의한다.

command processing

FTP client가 보내는 command는 여섯가지로 나뉠 수 있다.
:access commands, file management commands, data formatting commands, port defining commands, file transferring commands, miscellaneous commands.

FTP는 client control process 와 server control process사이의 연결을 위해 control connection을 사용한다.
이 연결을 통해 명령들이 클라이언틑에서 서버로 전송되고,
서버의 응답이 클라이언트에게 전송된다.

response

모든 FTP command는 적어도 하나의 reponse를 생성한다.

  • 1yz:positive preliminary reply
  • 2yz:positive completion reply
  • 3yz:positive intermediate reply

  • 4yz:transient negative completion reply
  • 5yz:permanent negative completion reply

file transfer

파일 전송은 data connection을 통해 이루어진다.
FTP에서 '파일 전송' 은 다음의 세 가지 경우를 말한다.

  1. 파일이 서버에서 클라이언트로 복사되는 것 (download)
  2. 파일이 클라이언트에서 서버로 복사되는 것 (upload)
  3. 파일의 경로나 이름이 server에서 client로 전송된다.

    ftp는 파일의 경로나 이름도 파일로 취급한다. 그래서 data connection으로 이동된다.

examples

2. TFTP

FTP protocol이 사용하는 모든 features를 사용하지 않고 간단하게 file을 copy하는 방법이다.

TFTP는 UDP기반의 서비스로, port number 69번의 well-known port를 가진다

message categories

TFTP의 메세지는 다음과 같은 네 가지로 분류된다

RRQ format

RRQ는 read request message로 client가 server에서 data를 읽기 위해 연결하는 메세지이다.

WRQ format

WRQ는 write request로 client가 server에 data를 쓰기 위해 연결하는 메세지이다.

Data format

Data message는 client 또는 server가 block 단위의 데이터를 보내기 위해 사용된다.

  • Opcode:data 보낼 땐 3
  • Block number:메세지 받는 쪽이 블럭의 순서를 매길 때 사용한다. 1부터 시작
  • Data:sender는 데이터 전송이 끝났음을 알리기 위해 다 0으로 채워진 블럭을 마지막에 보내야한다.

ACK format

ACK message는 client나 server가 data block을 받았음을 알리기 위해 사용한다.

Error format

Error message는 client나 server가 연결이 안됐거나 데이터 전송에 문제가 생겼을 때 알리기 위해 전송한다.

Connection establishment

TFTP 는UDP를 사용하기 때문에 연결이나 종료의 과정이 없다.
캡슐화된 datagram단위로 전송된다.

Data transfer

UDP port numbers used by TFTP

  1. 서버가 port 69번으로 passive open
  2. 클라이언트가 임의의 port number로 69번 포트에게 active open(RRQ, WRQ)
  3. 서버가 임의의 포트번호로 active open하고 클라이언트랑 통신. 이렇게 해야 well-know port 69번이 다른 클라이언트의 요청을 받을 수 있다.

TFTP example

Use of TFTP with DHCP

  1. DHCP client가 DHCP server에게 configuration file의 이름을 요청했다
  2. DHCP server가 client에게 이름을 전송했다.
  3. workstation에서 이름을 TFTP client에 전송했다.
  4. TFTP client가 TFTP server에 해당 이름을 가진 configuration file을 요청했다.
  5. TFTP server가 해당 파일을 TFTP client에게 제공했다.

0개의 댓글