Main Page | Modules | Alphabetical List | Data Structures | File List | Data Fields | Globals | Related Pages

pcache.h File Reference


Detailed Description

Pong caching (LimeWire's ping/pong reducing scheme).

Author:
Raphael Manfredi
Date:
2001-2003

#include "hcache.h"
#include "if/core/nodes.h"

Go to the source code of this file.

Data Structures

struct  pong_meta
 Pong metadata that we try to preserve when present. More...


Typedefs

typedef pong_meta pong_meta_t
 Pong metadata that we try to preserve when present.


Enumerations

enum  {
  PONG_META_HAS_VC = (1 << 0), PONG_META_HAS_GUE = (1 << 1), PONG_META_HAS_UP = (1 << 2), PONG_META_HAS_LOC = (1 << 3),
  PONG_META_HAS_DU = (1 << 4), PONG_META_HAS_IPV6 = (1 << 5)
}

Functions

gnutella_msg_initbuild_ping_msg (const gchar *muid, guint8 ttl, gboolean uhc, guint32 *size)
 Global Functions.

void pcache_init (void)
 Initialization.

void pcache_close (void)
 Final shutdown.

void pcache_set_peermode (node_peer_t mode)
 Called when peer mode is changed to recompute the pong cache lifetime.

void pcache_possibly_expired (time_t now)
 Check pong cache for expiration.

void pcache_outgoing_connection (struct gnutella_node *n)
 Called when a new outgoing connection has been made.

void pcache_ping_received (struct gnutella_node *n)
 Called when a ping is received from a node.

void pcache_pong_received (struct gnutella_node *n)
 Called when a pong is received from a node.

void pcache_pong_fake (struct gnutella_node *n, const host_addr_t addr, guint16 port)
 Fake a pong for a node from which we received an incoming connection, using the supplied IP/port.

gboolean pcache_get_recent (host_type_t type, host_addr_t *addr, guint16 *port)
 Get a recent pong from the list, updating `last_returned_pong' as we go along, so that we never return twice the same pong instance.

void pcache_clear_recent (host_type_t type)
 Clear the whole recent pong list.


Typedef Documentation

typedef struct pong_meta pong_meta_t
 

Pong metadata that we try to preserve when present.


Enumeration Type Documentation

anonymous enum
 

Enumeration values:
PONG_META_HAS_VC  The "VC" fields are valid.
PONG_META_HAS_GUE  The "GUE" fields are valid.
PONG_META_HAS_UP  The "UP" fields are valid.
PONG_META_HAS_LOC  The "LOC" fields are valid.
PONG_META_HAS_DU  The "DU" fields are valid.
PONG_META_HAS_IPV6  The "IPV6" fields are valid.


Function Documentation

struct gnutella_msg_init* build_ping_msg const gchar *  muid,
guint8  ttl,
gboolean  uhc,
guint32 *  size
 

Global Functions.

By construction, hops=0 for all pings.

Parameters:
muid the MUID to use. If NULL, a random one will be assigned.
ttl the TTL to use in the generated ping.
uhc whether to generate an "UHC" ping for a host cache
size where the size of the generated message is written.
Returns:
pointer to static data, and the size of the message in `size'.

void pcache_clear_recent host_type_t  type  ) 
 

Clear the whole recent pong list.

void pcache_close void   ) 
 

Final shutdown.

gboolean pcache_get_recent host_type_t  type,
host_addr_t addr,
guint16 *  port
 

Get a recent pong from the list, updating `last_returned_pong' as we go along, so that we never return twice the same pong instance.

Fills `addr' and `port' with the pong value and return TRUE if we got a pong. Otherwise return FALSE.

void pcache_init void   ) 
 

Initialization.

void pcache_outgoing_connection struct gnutella_node n  ) 
 

Called when a new outgoing connection has been made.

Here needs brief description for the following list:

  • If we need a connection, or have less than MAX_PONGS entries in our caught list, send a ping at normal TTL value.
  • Otherwise, send a handshaking ping with TTL=1

void pcache_ping_received struct gnutella_node n  ) 
 

Called when a ping is received from a node.

Here needs brief description for the following list:

  • If current time is less than what `ping_accept' says, drop the ping. Otherwise, accept the ping and increment `ping_accept' by n->ping_throttle.
  • If cache expired, call pcache_expire() and broadcast a new ping to all the "new" clients (i.e. those flagged NODE_A_PONG_CACHING). For "old" clients, do so only if "next_ping" time was reached.
  • Handle "alive" pings (TTL=1) and "crawler" pings (TTL=2) immediately, then return.
  • Setup pong demultiplexing tables, recording the fact that the node needs to be sent pongs as we receive them.
  • Return a pong for us if we accept incoming connections right now.
  • Return cached pongs, avoiding to resend a pong coming from that node ID.

void pcache_pong_fake struct gnutella_node n,
const host_addr_t  addr,
guint16  port
 

Fake a pong for a node from which we received an incoming connection, using the supplied IP/port.

This pong is not multiplexed to neighbours, but is used to populate our cache, so we can return its address to others, assuming that if it is making an incoming connection to us, it is really in need for other connections as well.

void pcache_pong_received struct gnutella_node n  ) 
 

Called when a pong is received from a node.

Here needs brief description for the following list:

  • Record node in the main host catching list.
  • If node is not a "new" client (i.e. flagged as NODE_A_PONG_CACHING), cache randomly OLD_CACHE_RATIO percent of those (older clients need to be able to get incoming connections as well).
  • Cache pong in the pong.hops cache line, associated with the node ID (so we never send back this entry to the node).
  • For all nodes but `n', propagate pong if neeed, with demultiplexing.

void pcache_possibly_expired time_t  now  ) 
 

Check pong cache for expiration.

If expiration time is reached, flush it and ping all our neighbours.

void pcache_set_peermode node_peer_t  mode  ) 
 

Called when peer mode is changed to recompute the pong cache lifetime.


Generated on Sun Feb 12 10:50:06 2006 for Gtk-Gnutella by doxygen 1.3.6