Design Document for a Continuous RQ - Selective Repeat Protocol 23-Nov-96 Authors: Diane Gruseck - Transmit Louis Guzik - Receive Transmit Design Pseudo Code while !sent_successfully { send init message ( seq_no = 0 ) } while !sent_successfully { send header frame( seq_no = 1 ) } /* send file */ for( all packets in window (zero based) ) { /* note: fill buffer returns status of whether eof is hit. If no more data in file, mark buffer as empty */ fill buffer ( win# * packet_size ) send packet in buffer( seq # = win# ) } next_ack = 0; while data remains in buffer { if ( escape entered ) { send fatal message(); return; } get ack or timeout() if( timeout or NAK ) { /* NAKS not implemented on receive side, but xmit is setup to handle them */ if( NAK ) { process all messages from next_ack to nack_received - 1 as acked fill those acked buffers( mark as empty if no file data remaining) send acked, non-empty buffers (seq num = win#) next_ack = nak_received } resend message(); } else { /* when ack is received, ack all packets from last acked packet to ack received */ process all packets from next_ack to ack_received as acked. fill those acked buffers (mark as empty if no file data remaining) send acked, non-empty buffers( seq num = win #) next_ack = ack_received + 1 (handle wrap) } } while !sent successfully { send end of file message } Receive Design Pseudo Code zero out stat counters; clear serial line buffer; setup transfer output to screen or file; while( ! recv_status ) { recv init message ( seq_no = 0 ); check packet bcc; check packet type; if( ok ) { recv_status = true; send positive ack( seq_no, init parameters ); } else send negative ack( seq_no ); if( ESC key pressed ) abort; } while( ! recv_status ) { recv file header message ( seq_no = 1 ); check packet bcc; check packet type; if( ok ) { recv_status = true; check file name; send positive ack( seq_no, filename parameters ); } else send negative ack( seq_no ); if( ESC key pressed ) abort; } if( output to file && ! open file for write ) abort; seq_no = 0; while( ! end of file packet ) { if( ESC key pressed ) goto leave; while( chars on serial line ) { get packet; get bcc; if( good bcc && ! dup packet for window) write packet to recv_window_buffer in seq_no slot; else throw packet away; if( ESC key pressed ) goto leave; } while( recv_window_buffer( seq_no) ! empty ) { if( ESC key pressed ) goto leave; case( packet type ) { data: output data; send positive ack( seq_no ); seq_no++; if( seq_no == window_size ) seq_no = 0; break; EOF: send positive ack( seq_no ); break; fatal: goto leave; other: send negative ack( seq_no ); } } } leave: if( file open ) close file; display stats; return to menu; User Manual Menu System The user interface is menu driven. The main menu consists of the following options: User Options Generate Errors Help User Options Set Line Speed Set Window Size Set Packet Size Set Time-out Value Generate Errors Generate Checksum Errors Generate Time-out Errors Steps to transfer a file Run sftp on receive system Set up desired window size, packet size and transmit speed Select receive file and enter where output should be sent. Run sftp on transmit system Set up desired window size, packet size and transmit speed (must match receive) Select transmit file and enter file name Requirements/ Limitations Line speed, window size and packet size options must be set to the same values on the transmit and receive machines before a file may be transmitted. Only ASCII files may be transmitted. Binary files can not be handled. Default Values Packet size - 20 Time-out - 30 seconds window size - 1 Special Considerations Window Size The optimum window size is dependent on the propagation time between the two hosts (transmit and receive). The optimum window size is the number of packets that can be transmitted to the receiver, before the ack for the first packet in the window is received. Therefore, the optimum window size is also dependent on the packet size. If packet size is small, and the propagation time is considerate, more packets can be transmitted than if the packet size were large. Optimum Window Size Test Case A test was performed to determine the optimum packet size using the test system in the lab and a 20 byte packet size and a file size of 1743 bytes. The results follow: Window SizeTransfer Time (seconds)162534455565 Optimum window size in this case is 3. Special Problems Encountered Checksum Using a checksum also has an inherent fault. There is always the chance that multiple errors occur that affect the data and the checksum in such a way that the errors are not detected. The likelihood of this happening is so slim, that it is not really a big issue. The End.