Ejemplo n.º 1
0
  // Look up an older packet for responses
  // Return true if the packet is unique; false if we have seen it before
  private boolean rememberPacket(GnutellaPacket pkt) {
    GnutellaConnection gc = (GnutellaConnection) packetTable.get(pkt.getGUID());
    if (gc != null) return false;

    if (DEBUG) System.err.println("**** REMEMBERING: " + pkt + " from " + pkt.getConnection());

    packetTable.put(pkt.getGUID(), pkt.getConnection());
    return true;
  }
Ejemplo n.º 2
0
  // Send the packet to everyone but the originator
  private void forwardPacketToAll(GnutellaPacket pkt) {
    if ((pkt.ttl == 0) || (--pkt.ttl == 0)) {
      if (VERBOSE) System.err.println("-- Dropping packet, TTL expired: " + pkt);
    }
    pkt.hops++;

    if (DEBUG) System.err.println("**** FORWARDING: " + pkt + " to all but " + pkt.getConnection());

    // System.err.println("FORWARDING "+pkt);
    gs.sendToAllButOne(pkt, pkt.getConnection());
  }
Ejemplo n.º 3
0
  // Forward an incoming packet to the corresponding source
  private void forwardPacket(GnutellaPacket pkt) {
    GnutellaConnection gc;
    gc = (GnutellaConnection) packetTable.get(pkt.getGUID());
    if (gc == null) {
      if (VERBOSE) System.err.println("-- Received reply with no request: " + pkt);
      return;
    }

    if (DEBUG) System.err.println("**** REPLYING: " + pkt + " to " + gc);

    if ((pkt.ttl == 0) || (--pkt.ttl == 0)) {
      if (VERBOSE) System.err.println("-- Dropping packet, TTL expired: " + pkt);
    }
    pkt.hops++;
    gc.enqueue_lossy(pkt);
  }