Network layer

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.
It exposes to the P2P application a very simple interface:

  • send a data buffer b from peer p1 to peer p2
  • receive a data buffer b from a remote peer p2 with the local peer p1

Currently the network layer, called net_helper_x, implements the following advanced features:

  • packet fragmentation: needed in order to deal with MTU
  • very basic loss-recovery: fragments can be requested in case of loss
  • data shaping: the data is forced to be sent regularly, avoiding traffic peaks

The modules implementing these features are called network_manager and shaper.


We refer with

  • "packet" the data buffer exchanged,
  • "fragment" the portion of packet
  • "message" to a fragment or a fragment request

net_helper_x sends and receives packet from the application layer and it sends and receives messages from the network.


The features listed above can be split in the following conceptual functionalities:

  • Sender side:
  • * Fragment outgoing packets
  • * Periodically send fragments
  • * Send fragments upon requests
  • * Flush old packet (defined by a threshold)
  • Receiver side:
  • * Enqueue incoming messages (either fragments or fragment requests)
  • * Pop completed messages
  • * Request fragments
  • * Flush old packet (defined by a threshold)

As additional requirements we want: * Fast look-up of data * * getting oldest packet * * getting specific packet (for fragment enqueuing) * * getting next message to be sent * Limit the number of data duplication

The Network Manager

The network manager is responsible of fragmenting/re-assembling of packets and it keeps the queue of outgoing messages.

The Shaper

The shaper estimates the application layer bitrate with a moving average Re with memory alpha=0.1.
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.
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:
tau = M/Rd

The Loss-Recovery

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.
If a request is already in the outgoing queue the same request is not created.

class_diagram.png (18.5 KB) Luca Baldesi, 08/22/2017 04:03 PM