Skip to content
Snippets Groups Projects
Commit 55133ccd authored by Adrien Béraud's avatar Adrien Béraud
Browse files

MultiplexedSocket: use incrementing channel number

'Birthday paradox' implies that if the two peers create channels
at the same time, there is a non-zero chance of collision even for
small amount of channels, because channel ids are 16 bits:
* >50% probability of collision with N=256
* >1% probability of collision with N=40
* 0.2% probability of collision with N=16

For this reason, use incrementing channel numbers,
but start at 0x8000 for the server and at 1 for the client.

This method guarantees 0-collision for
at least the first 2^15-1 channels opened each side,
and reduces the probability of collision
after that.

Change-Id: I913cf2962a1fc577a6d24b9184a25d75d2473574
parent b6504373
No related branches found
No related tags found
No related merge requests found
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment