The credit system

The credit system tries to distribute the ressources "fairly" so that users and applications with different requirements and aggressiveness can coexist friendly. Users who contribute bandwidth or other ressources will get a performance boost. Application priority can be defined by each user on their own, but is limited by the amount of credits a user has.

Credits are calculated as soon as 2 neighbor nodes are connected to each other. Each neighbor calculates how much credits the other neighbor can spend. Both neighbors have a reason to do this calculation "correctly: If node A spends a lot of credits, then B will throttle A and B will be able to use more of A's ressources. However if A does not allow this, B will just keep throttling A.

2 operations are periodically performed on the credit states for each neighbor: "additive increase" and "decay". These 2 operations will push the credits from any state towards a convergence point. This allows the system to get started. Also, nodes which do not contribute ressources can still use some ressources. To limit cheating by faking lots of neighbors, the sum of additive increase for all local neighbors is constant.

A client which establishes a connection will tell the first router the amount of credit flow per second. The first router takes some of these credits as "reward". The rest is passed on to the next router. Every router in the path does the same. The server will then send the credits back to the client. Optionally, after the connection is established, the server can contribute its own credits, too. This may help e.g. in situations where a mobile client wants to connect home.

The exact amount of credits a router charges and forwards is calculated as following:

  1. Load: If the bandwidth it fully utilised, connection which are charged the most credits per byte can transmit first. The credits charged locally and forwarded are balanced to get best performance.
    The load metric has an interesting side effect: Clients will try to find cheap routes. In this case it means routes with little load. Thus routers are less likely to stay idle compared to networks with link quality metrics. This will increase the fairness of the credit system as more users can forward data. Also, it might have a good motivational effect for owners if they see their routers are doing something. However, it might also increase congestion on wireless carriers.
  2. Credits which should be forwarded: A small percentage of credits forwarded will be charged independend of the load. This is done so that routers in critical paths which are not bottlenecks also get some credits. The load charging alone would give lots of credits to bottleneck routers and little elsewhere.
  3. Connection table fill status: If the connection table is at least half full, new connections will be periodically charged some credits just for being established. Connections which cannot be charged that amount, will not be accepted and in severe cases even dropped after they are established. This is done to avoid the network being DoSed by programs which try to open too many connections.
In some situations routers might end up spending a lot of their credits on a single neighbor and accumulating a lot on some others. For example, a router 'A' might be connected to 10 stub clients and to a second router 'B' which has a connection to the outside world. The clients might each want to spend most of their credits to connect to the outside world. However router 'A' will not have enough credits to satisty this. Thus credits are valuated when they are forwarded. The clients will then be able to use all of their credits, but router 'A' will will pass on only 1/10th to router 'B'. Credits flowing from 'B' to the clients are amplified 10 times by router 'A'.

In networks with redundant paths, this valuation can cause credits to be amplified infinitely by establishing connections which run in circles. However, this is not really a problem. If credits really do run in circles, the valuation will be modified so that the gain decreases and might get negative. Routing daemons will see whether there are circles they could profit from. Enough routing daemons will make this profit small for everyone and prevent this disbalance from growing too big.