Network layer » History » Version 2

Luca Baldesi, 08/22/2017 04:12 PM

1 1 Luca Baldesi
h1. Network layer
2 1 Luca Baldesi
3 1 Luca Baldesi
The network layer is responsible of managing the exchange of data between the peers, yet its role is of central interest in the complex real networks.
4 1 Luca Baldesi
It exposes to the P2P application a very simple interface:
5 1 Luca Baldesi
6 1 Luca Baldesi
 * send a data buffer b from peer p1 to peer p2
7 1 Luca Baldesi
 * receive a data buffer b from a remote peer p2 with the local peer p1
8 1 Luca Baldesi
9 1 Luca Baldesi
Currently the network layer, called net_helper_x, implements the following advanced features:
10 1 Luca Baldesi
11 1 Luca Baldesi
 * packet fragmentation: needed in order to deal with MTU
12 1 Luca Baldesi
 * very basic loss-recovery: fragments can be requested in case of loss
13 1 Luca Baldesi
 * data shaping: the data is forced to be sent regularly, avoiding traffic peaks
14 1 Luca Baldesi
15 1 Luca Baldesi
The modules implementing these features are called network_manager and shaper.
16 1 Luca Baldesi
17 1 Luca Baldesi
h2. Nomenclature
18 2 Luca Baldesi
19 1 Luca Baldesi
We refer with
20 1 Luca Baldesi
21 1 Luca Baldesi
 * "packet" the data buffer exchanged,
22 1 Luca Baldesi
 * "fragment" the portion of packet
23 1 Luca Baldesi
 * "message" to a fragment or a fragment request 
24 1 Luca Baldesi
 
25 1 Luca Baldesi
net_helper_x sends and receives packet from the application layer and it sends and receives messages from the network.
26 1 Luca Baldesi
27 1 Luca Baldesi
h2. Functionalities
28 2 Luca Baldesi
29 1 Luca Baldesi
The features listed above can be split in the following conceptual functionalities:
30 1 Luca Baldesi
31 1 Luca Baldesi
 * Sender side:
32 1 Luca Baldesi
 * * Fragment outgoing packets
33 1 Luca Baldesi
 * * Periodically send fragments
34 1 Luca Baldesi
 * * Send fragments upon requests
35 1 Luca Baldesi
 * * Flush old packet (defined by a threshold)
36 1 Luca Baldesi
 * Receiver side:
37 1 Luca Baldesi
 * * Enqueue incoming messages (either fragments or fragment requests)
38 1 Luca Baldesi
 * * Pop completed messages
39 1 Luca Baldesi
 * * Request fragments
40 1 Luca Baldesi
 * * Flush old packet (defined by a threshold)
41 1 Luca Baldesi
42 1 Luca Baldesi
As additional requirements we want:
43 1 Luca Baldesi
 * Fast look-up of data
44 1 Luca Baldesi
 * * getting oldest packet
45 1 Luca Baldesi
 * * getting specific packet (for fragment enqueuing)
46 1 Luca Baldesi
 * * getting next message to be sent
47 1 Luca Baldesi
 * Limit the number of data duplication
48 1 Luca Baldesi
49 1 Luca Baldesi
50 1 Luca Baldesi
h2. The Network Manager
51 2 Luca Baldesi
52 1 Luca Baldesi
The network manager is responsible of fragmenting/re-assembling of packets and it keeps the queue of outgoing messages.
53 2 Luca Baldesi
!class_diagram.png!
54 1 Luca Baldesi
55 1 Luca Baldesi
56 1 Luca Baldesi
h2. The Shaper
57 2 Luca Baldesi
58 2 Luca Baldesi
The shaper estimates the application layer bitrate with a moving average Re with memory alpha=0.1.
59 2 Luca Baldesi
It then computes the desired byterate Rd as Re times a multiplication factor gamma. This is done to grant higher resources then the one expected.
60 2 Luca Baldesi
Whenever a message of size M is sent, the shaper is acknowledge and it computes the interval to wait before the next sending event as:
61 2 Luca Baldesi
tau = M/Rd
62 2 Luca Baldesi
63 2 Luca Baldesi
h2. The Loss-Recovery
64 2 Luca Baldesi
65 2 Luca Baldesi
The loss recovery is implemented straightforwardly, whenever a fragment is received, if there are fragment of the same packet with lower ID not received yet (which we assume to have been sent in advance), a request is created for those packets.
66 2 Luca Baldesi
If a request is already in the outgoing queue the same request is not created.