## 4 The Proposed Framework
### Distributed Grouping of Cyclists  
All fleet members in \(G\) are supposed to ride along a known common path \(P\). In a group, a cyclist may act as a _Group Header (GH)_, a _Relay Cyclist_, or an _Ordinary Cyclist_. The first cyclist of a group will act as the GH to broadcast beacons whereas other group members may act as relay cyclists to forward beacons or simply as ordinary cyclists. Within a group, each cyclist is assigned a serial number (SN), where the SN of the first cyclist (i.e., the GH) is 1, the SN of the second cyclist is 2,..., and the SN of the \(i\)th cyclist is \(i\). The SN of the last cyclist in a group is equal to the current group size. Each GH  
Figure 1: A two-tier mobile long-thin network formed by fleet cyclists. periodically broadcasts _Invitation Advertisement Beacons (IABs)_, where an IAB contains the fleet ID, group ID, sender ID, sender position, sender SN (SN\({}_{s}\)), current group size, maximum group size, and sequence number. The fleet ID and group ID convey whether the IAB is from the same fleet and the same group, respectively, because there may be different fleets cycling on the same path and each fleet consists of one or more groups. Based on the sender ID and position, an IAB receiver can calculate the distance between the sender and itself. Thus, it can select a location-based backoff timer such that the receivers further from the same sender could rebroadcast earlier on receiving IABs. SN\({}_{s}\) is the SN of the GH or relay cyclist that sent the IAB. The purpose of IABs is to broadcast the existence of a group and to invite nearby fleet cyclists as new members. A cyclist can join a group only if the current group size is smaller than the maximum group size that is depending on the allowed round-trip delay for cooperative sensing data collection and distribution. When a fleet cyclist \(c\) turns on a smartphone, it listens for IABs from its fleet for \(\theta\) seconds. If no IAB is received, it will form a new group and act as its GH. Otherwise, depending on the content of the received IAB, there are three possible cases for cyclist \(c\) to join an existing group \(L\) as follows, where the current group size is \(n\) (i.e., there are \(n\) members in the group currently), as shown in Figure 2a. Note that if multiple IABs of \(L\) are received, cyclist \(c\) joins \(L\) based on the IAB with the smallest SN\({}_{s}\). 1. If SN\({}_{s}=n\), the IAB was sent by the last group cyclist in \(L\). Cyclist \(c\) is currently behind the last group cyclist, it can join \(L\) from the rear. Cyclist \(c\) will set its SN to \(n+1\) and broadcast a join message \(M_{join}\) to all group cyclists ahead to update the current group size to \(n+1\). Otherwise, cyclist \(c\) can join \(L\) from the front and middle according to Case 2 and Case 3, respectively. 2. If SN\({}_{s}=1\), the IAB was sent by the GH in \(L\). Cyclist \(c\) is in the front of the GH, it can join \(L\) from the front. Cyclist \(c\) will set the group ID to its ID, the current group size to \(n+1\), and its SN to 1 to act as the new group header GH\({}_{new}\) and send a notification message \(M_{notify}\) to the old group header GH\({}_{old}\) to replace it. Then, GH\({}_{old}\) will set its SN to 2 and broadcast an update message \(M_{update}\) to all group cyclists \(i\) following behind, to set the group ID to the ID of GH\({}_{new}\), the current group size to \(n+1\), and SN\({}_{i}\) to SN\({}_{i}+1\). Otherwise, cyclist \(c\) can join \(L\) from somewhere in the middle according to Case 3. 3. If \(1<\text{SN}_{s}<n\), the IAB was sent by a relay cyclist in \(L\) and cyclist \(c\) can join \(L\) somewhere in the middle. Cyclist \(c\) will send a request message \(M_{req}\) with its GPS location to one-hop neighboring group cyclists for requiring the two closest group cyclists, group cyclists \(j\) and \(j+1\), to reply with ACK\({}_{j}\) and ACK\({}_{j+1}\).