Netkitmig

283 views

Published on

  • Be the first to comment

  • Be the first to like this

Netkitmig

  1. 1. netkit ftpd/ftp migration
  2. 2. <ul><li>Netkit </li></ul><ul><ul><li>ftp://ftp.uk.linux.org/pub/linux/Networking/netkit </li></ul></ul><ul><ul><li>a port of the OpenBSD ftp daemon and client </li></ul></ul><ul><li>Source code </li></ul><ul><ul><li>ftpd (server): 4717 lines </li></ul></ul><ul><ul><li>ftp (client): 6249 lines </li></ul></ul>
  3. 3. flowchart Server start listening, and wait for new connection request Client open new connection, then login to the server Child use the established connection to transfer COMMANDs and REPLIES information with Client fork() USER, PASS, PORT, PASV, RETR, STOR communication channel data transfer channel 1 2 3
  4. 4. Disk and Connection Operation <ul><li>Use read() and write() operate on disk files and tcp connection </li></ul><ul><ul><li>Default BUFSIZ (8KB) in stdio.h in RHEL 5 </li></ul></ul><ul><li>FILE * and fd </li></ul><ul><ul><li>fdopen – associate a stream with a file descriptor </li></ul></ul><ul><ul><li>fileno - map a stream pointer to a file descriptor </li></ul></ul><ul><li>put </li></ul>
  5. 5. Transfer Param - PORT <ul><li>after finish login and authentication </li></ul><ul><li>ftp client start listen on a port, then send the port information to the server </li></ul><ul><ul><li>PORT h1,h2,h3,h4,p1,p2 </li></ul></ul><ul><li>Port choose </li></ul><ul><ul><li>sin_port = 0 /* let system pick one */ </li></ul></ul><ul><ul><li>Then use getsockname() to get listening address and port, send to the server </li></ul></ul>
  6. 6. Transfer Param - PASV <ul><li>ftp client send PASV command to the server, server listening on a port and waiting for connection </li></ul><ul><li>Choose a port in [40000, 44999] </li></ul><ul><li>Random </li></ul><ul><ul><li>sin_port = 0 /* let system pick one */ </li></ul></ul><ul><ul><li>Then use getsockname() to get listening address and port, send to the client </li></ul></ul>
  7. 7. put - STOR <ul><li>Client </li></ul><ul><ul><li>fin = fopen(local, “r”); </li></ul></ul><ul><ul><li>read(fileno(fin), ..); </li></ul></ul><ul><ul><li>dout = fdopen(connfd, ..); </li></ul></ul><ul><ul><li>write(fileno(dout), ..); </li></ul></ul><ul><li>Server </li></ul><ul><ul><li>fout = fopen(local, “r”); </li></ul></ul><ul><ul><li>read(fileno(din), ..); </li></ul></ul><ul><ul><li>write(read(fileno(din), ..); </li></ul></ul>FILE *fin -> *dout -> *din -> *fout;
  8. 8. get - RETR <ul><li>Client </li></ul><ul><ul><li>fout = fopen(local, “r”); </li></ul></ul><ul><ul><li>read(fileno(din), ..); </li></ul></ul><ul><ul><li>write(fileno(fout), ..); </li></ul></ul><ul><li>Server </li></ul><ul><ul><li>fin = fopen(local, “r”); </li></ul></ul><ul><ul><li>If filesize < 16MB </li></ul></ul><ul><ul><ul><li>mmap(.., fileno(fin), ..); </li></ul></ul></ul><ul><ul><ul><li>write(fileno(dout).., filesize); </li></ul></ul></ul><ul><ul><li>else </li></ul></ul><ul><ul><ul><li>read(fileno(din), ,blksize * 16); </li></ul></ul></ul><ul><ul><ul><li>write(read(fileno(din), ..); </li></ul></ul></ul>FILE *fout <- *din <- *dout <- *fin;
  9. 9. ftpcmd.y <ul><li>Procedure </li></ul><ul><li>bison –y ftpcmd.y </li></ul><ul><ul><li>Output y.tab.c </li></ul></ul><ul><ul><li>Gcc y.tab.c </li></ul></ul><ul><ul><li>Same procedure as Oracle Pro*C </li></ul></ul>
  10. 10. Migrate ftpd/ftp to RDMA environment <ul><li>Use librdmacm to establish the data transfer channel instead of socket </li></ul>Server start listening, and wait for new connection request Client open new connection, then login to the server Child use the established connection to transfer COMMANDs and REPLIES information with Client fork() USER, PASS, PORT, PASV, RETR, STOR communication channel data transfer channel
  11. 11. Desc <ul><li>Sequence processing </li></ul><ul><ul><li>cmd – data – cmd – data - … </li></ul></ul><ul><ul><li>When the process handle data transfer, it discards the communication channel error </li></ul></ul><ul><ul><li>no poll/select/epoll etc. </li></ul></ul><ul><li>Each process handle an individual data transfer channel. When the data transfer finished, the channel will be closed. </li></ul>
  12. 12. More efficient transfer – data transfer channel <ul><li>GridFTP’s method </li></ul><ul><ul><li>Parallel and striped transfer. </li></ul></ul><ul><li>Can we use parallel data transfer channels in rdma-ftp? Or we just implement the GridFTP command and protocol? </li></ul>
  13. 13. More efficient transfer – buffer and memory copy <ul><li>Read data directly into the MR. Avoid memcpy() in the process. </li></ul><ul><li>Reuse the MR. </li></ul><ul><li>Separate the EXCUTER and RESOURCE </li></ul><ul><ul><li>Excuter </li></ul></ul><ul><ul><ul><li>Sender, receiver, reader, writer, manager… </li></ul></ul></ul><ul><ul><li>Organize the MR blocks with linked lists. </li></ul></ul><ul><ul><ul><li>free block lists </li></ul></ul></ul><ul><ul><ul><li>busy block lists </li></ul></ul></ul>
  14. 14. example reader reader reader sender sender sender manager writer writer writer receiver manager receiver receiver listener listener
  15. 15. MiddleWare ? <ul><li>In each host, setup a group of daemon processes responsible for buffer management, remote data transfer, file operation and inter-process communication, etc. </li></ul><ul><li>Application just need send command and parameter to those daemon, to initiate the data transfer and check the result. </li></ul>RDMA - DAEMON RDMA - DAEMON ftp http scp ftp http scp

×