## 4 Application Design and Implementation
### Message Structure and Dissemination Protocol
#### 4.2.2 Ad Hoc Domain  
As previously mentioned, we designed the X-NETAD system in order to be able to disseminate a (relatively) large content, adapting to the constraints imposed by the VANET scenario. The strategy we adopted to enforce this feature split the archive that comes from the cellular network into smaller pieces, called _chunks_, which are disseminated independently. Chunks are small data units of fixed size, exchanged during a single contact of limited duration with high probability. If a chunk is only partially received from a node (e.g., due to a connection breakdown), it is discarded. If, on the one hand, splitting the traffic update into several chunks allows nodes to receive parts of the same traffic update from different nodes, on the other hand, this adds complexity to the system, because nodes should be able to recognize which chunks are missing and, if needed, should request them back. The system behavior can be described as follows. The original traffic update received from the AS through the cellular network is divided in several chunks by the PU, and every chunk is packed into different data-bearing messages denoted as _DATA_. A _DATA_ message contains the actual data chunk and the chunk index; this index is crucial, because it allows the receiving of nodes to identify which part of the update they are receiving. In fact, each SU maintains a local bit-vector in its memory, whose length equals the total number of chunks of the current traffic update, where the \(i\)-th bit indicates whether the \(i\)-th chunk is missing (bit set to zero) or present (bit set to one). After each _DATA_ message is received by an SU, the local bit-vector is correspondingly updated. The payload of any _DATA_ message, related to the same traffic update, has a fixed size, apart for the last chunk. This size depends on the dimension of the original traffic update and on the number of chunks in which it is divided. The chunk size is an important parameter that significantly affects the system performance. With large chunks, there is the risk of performance degradation when partially received chunks are discarded by the network interface. The choice of small chunks reduces the amount of wasted reception, but it also increases the overhead. It is worth recalling that before being able to decode a traffic update, a node must receive all the _DATA_ messages associated with it. _DATA_ messages are propagated and replicated network-wide using the IF protocol, thus providing redundancy in the system. Whenever a PU receives a new traffic update from the AS using the cellular network, it should disseminate this information to SUs located in the _ad hoc_ domain. To make SUs aware of the existence of a new traffic update, allowing them to create a local bit-vector for the update, the PU issues an _ADVERTSE_ message. This message contains information on the update, such as its size and the number of chunks in which it is divided. Once a SU receives a new _ADVERTSE_ message, it creates a new bit-vector for the update and becomes ready to receive its flux of _DATA_ messages. Since, without this message, a SU cannot store the subsequent chunks of data, the goal is to provide a fast and reliable dissemination of the _ADVERTSE_ message all over the network using the IF protocol. This message is also periodically broadcast by PUs, allowing SUs, which join the network later, to get the traffic update. Because of the probabilistic nature of IF and of the underlying contention mechanism, there still exists the opportunity that messages may be lost due to noise bursts on wireless channels or to message collisions. A simple solution to recover from packet losses is to use a feedback loop. To minimize the total number of packets sent in the network and, thus, to prevent congestion and additional collisions, SUs ask periodically for missing chunks using a _REQUEST_ message. The payload of the _REQUEST_ message is a bit-vector representing the reception status for each chunk.