Gnutonic Specifications

Note that this document is split into "Client" and "Server" functionality, and that the first two sections are solely Client-oriented.

Current Work (Note: gennyProtocol.java is the only file with real work on it so far)
  1. Read/Act Upon Config
    1. Options
      1. Speed -- What kind of connection do I have?
      2. Sort Order -- How should results be displayed?
      3. Min Connections -- How many hosts should we attempt to stay in touch with, minimum?
      4. Max Connections -- How many hosts are too many?
      5. Download Path -- Where should downloaded files go?
      6. Share Path(s) -- What directories do you want to share?
        1. Scan directory, generate array of filenames
        2. Assign each filename an identifier -- source
      7. Transfer Log -- Where should transfers be logged to?
      8. Get Hosts -- Should we ask a server for a list of hosts, or use a pre-existing one?
      9. Hosts Log -- Where should we log discovered hosts?
      10. Max Uploads -- How many outbound connections do I allow at once?
      11. Automatic Re-retrieve -- If a file's checksum computes improperly, should I automatically restart the download?
    2. Load GUI (only some clients)
  2. Connect
    1. Server Request
      1. Read in list of available servers
      2. Open socket on appropriate port
      3. Send request packet to each server
      4. Listen for responses
      5. Load responses into memory
      6. Close port, if different from main port
      7. Broadcast Existence()
    2. Read from config
      1. Broadcast Existence()
  3. Broadcast Existence

  4. Client:
    1. Open appropriate port, if not already open
    2. Send series of broadcast packets (Control Foos) to segments of network
    3. Listen for responses (Control Bars); (creates netHost objects)
    4. Update Hosts
    Server:
    1. Get open port from Client section
    2. Listen for Control Foos
    3. Send Control Bars
    NOTE: Once per (minute? 5 mins? etc?), Info Pongs will be sent out to keep the host list accurate.
  5. File Info Service

  6. Sever:
    1. Determine whether files are share
    2. If shared:
      1. Prepare File Response packet info (detailed below)
      2. Listen for/respond to File Requests
    Client:
    1. Send File Requests (i.e tell me about your file service) to all hosts which have responded with a Control Bar or Info Pong
    2. Listen for File Responses. These will include:
      1. Where am I?
      2. How many files do I have?
      3. How big are those files?
    3. Update statistics from File Responses
  7. Index Service

  8. Server:
    1. Listen for Index Requests
    2. Send Index Responses
      1. Unpack regex from Index Request
      2. Compare regex against array of available files (from config)
      3. Prepare Index Response packet (creates searchMatch objects) from matches. Includes:
        1. What are the matched files/IDs?
        2. How fast am I?
        3. Where am I?
        4. Am I over my upload quota? If so:
          1. If this is request #1 over quota, create array of queued hosts & their place in line, starting with this one
          2. If this is not request #1, add this host to the array
          3. Report back host's place in queue
      4. Send packet
    Client:
    1. Upon receiving search request from user, prepare Index Request, which includes:
      1. Regex to search with
      2. Where am I?
    2. Listen for Index Responses
    3. Unpack Index Responses & report back to user
  9. File Fetch Service

  10. Server:
    1. Listen for File Fetch Requests. These will include:
      1. File identifier
      2. Where am I?
      3. Port for data transfer
    2. Send File Fetch Responses. These will repeat data from File Fetch Request for confirmation.
    3. Listen for File GoAhead Responses. These will simply be "OK" or "No".
    4. If OK is received, open connection & begin sending file. Must be done over TCP/IP to ensure file integrity.
    5. Upon file completion, send File Done packet. This will be "identifier\checksum\Done".
    6. Listen for File Done OK packets. These will be "Got" if checksum computes, or "Bad" if it does not.
      1. Upon receiving "Got", drop connection
      2. Upon receiving "Bad", listen for File Resend packets
        1. If received, send File Fetch Response
          1. Listen for File GoAhead Response. If received, re-send file
        2. If not received within 30 seconds, drop connection
    Client:
    1. Receive file request from user
    2. Send File Fetch Request
    3. Listen for File Fetch Responses
    4. Send File GoAhead Responses
    5. Accept incoming connection
    6. Download file
      1. Check for File Done packets
      2. Upon File Done packet receipt, compute checksum
        1. If checksum is good, send File Done OK "Got" packet & drop connection
        2. If checksum is bad, look in config for Auto Re-retrieve flag
          1. If yes, send File Resend packet
            1. Listen for File Fetch Response
            2. If received, send File GoAhead Response
            3. Accept incoming connection
          2. If no, drop connection
      3. Report to user status of file transfer at these points:
        1. Connection queued
        2. Connection started
        3. Download completed OK
        4. Download did not complete OK
          1. Restarting
          2. Done