Clustering and OFDMA-based MAC protocol (COMAC) for vehicular ad hoc networks

The IEEE community is working on the wireless access in vehicular environments as a main technology for vehicular ad hoc networks. The medium access control (MAC) protocol of this system known as IEEE 802.11p is based on the distributed coordination function (DCF) of the IEEE 802.11 and enhanced DCF of the IEEE 802.11e that have low performance especially in high-density networks with nodes of high mobility. In this paper, we propose a novel MAC protocol where nodes dynamically organize themselves into clusters. Cluster heads are elected based on their stability on the road with minimal overhead since all clustering information is embedded in control channel ’ s safety messages. The proposed MAC protocol is adaptable to drivers ’ behavior on the road and has learning mechanism for predicting the future speed and position of all cluster members using the fuzzy logic inference system. By using OFDMA, each cluster will use a set of subcarriers that are different from the neighboring clusters to eliminate the hidden terminal problem. Increasing the system reliability, reducing the time delay for vehicular safety applications and efficiently clustering vehicles in highly dynamic and dense networks in a distributed manner are the main contributions of our proposed MAC protocol.


Introduction
The increase in number of vehicles on our roads and the immense number of fatal accidents they cause have driven the research and development of new-generation technologies that help drivers travel more safely. One major cause to traffic accidents is that drivers cannot consistently respond to the changing road condition appropriately. In fact, most accidents could be avoided if drivers could obtain and use relevant information of the traffic that is beyond their vision using wireless communication technology. In recognition to this problem, the IEEE community is working on the standardization of IEEE802.11p [1], which is intended to enhance the IEEE 802.11 to support vehicular ad hoc networks (VANETs) applications where reliability and low latency are crucial.
The IEEE 802.11p uses carrier sense multiple access with collision avoidance (CSMA/CA) as the basic medium access scheme in the licensed ITS 5.9 GHz (5.850-5.925 GHz) band in North America. The 75 MHz spectrum is divided into seven 10 MHz channels and a 5 MHz guard band. The control channel (CCH), channel 178, will be used for safety-related applications and system control management. The other six channels are service channels (SCH) dedicated for non-safety and commercial applications. Vehicles will alternate between the CCH channel and one or more of the SCH channels.
The standard assumes that all vehicles will be synchronized to a common time through an external system like global positioning system (GPS). Although the interval of synchronization (SI) is not specified by the standard, it is selected to be 100 ms in most safetyrelated applications. At the beginning of this interval, vehicles will synchronize to the control channel for a period called control channel interval CCI. The remaining time is called service channel interval SCI, where vehicles synchronize to one of the service channels, such that SI = CCI+SCI.
Vehicles will be equipped with sensors and GPS systems to collect information about their position, speed, acceleration and direction to be broadcasted to all vehicles within their range. Based on this information, drivers can better operate vehicles to avoid potential dangers. In this scenario, all vehicles should have fair access to the control channel such that all safety-related messages are present to all vehicles that are all made visible to every individual driver in the range.
Since most VANETs' applications are broadcasting in nature, vehicles will not send an acknowledgement (ACK) for the received broadcast messages. Therefore, the transmitter cannot detect whether a packet is received properly and hence will not resend the packet. As VANETs tend to grow in terms of number of vehicles within a certain geographical area, their applications that use broadcasting will face a challenge in managing the wireless channel capacity in terms of throughput, fairness and time delay. This is because the IEEE 802.11p uses the DCF as a MAC protocol, which is known to have a poor performance such as unbounded channel access delay and consecutive packet drops as the number of nodes increases within the communication range.
Since vehicular safety applications have strict requirements on reliability and low latency, VANETs should be self-organized and provide a distributed channel access to all nodes within the communication range. It also implies the need for ad hoc mode to support vehicle-tovehicle (V2V) communication or intervehicle communication (IVC). In fact, the efficiency of VANETs depends on the performance and reliability of their MAC protocol, which must be decentralized to fit their ad hoc nature. The MAC protocol should cope with the fastchanging topology of VANETs and their uneven node density on the road. The vehicle density on the road varies with time and location. In some congested areas, the number of vehicles that contend for the channel is high, which results in deteriorating the DCF performance. However, in low-density areas, nodes may struggle to find a path between a source and a destination and to maintain the link between them for the whole period of communication.
To solve the aforementioned problems, we propose a novel MAC protocol called clustering and OFDMAbased MAC (COMAC) protocol where nodes dynamically organize themselves into clusters. Cluster heads are elected based on their stability on the road and with minimal overhead since clustering information is embedded in vehicles' periodic status messages. The COMAC protocol takes advantage of the OFDMA scheme and works under the IEEE 802.11p standard. We divide the control channel subcarriers into four groups. Each cluster will use a set of subcarriers that are different from the neighboring clusters to eliminate the hidden terminal problem and hence increase the system reliability and decrease the time delay for safety messages. The COMAC protocol is adaptable to drivers' behavior on the road and has a learning mechanism for predicting the future speed and position of all cluster members using the fuzzy logic inference system (FIS). This makes the proposed protocol more efficient in maintaining the cluster topology and increases the life time of the elected cluster head and its members.
The rest of this paper is organized as follows: Section 2 presents a review of the significant contributions in the scope of VANETs MAC protocols found in the literature. The characterization of our COMAC protocol and its algorithms are introduced in Section 3. In Section 4, we analyze the proposed MAC protocol in terms of time delay, reliability, stability and network convergence. We present our simulation results in Section 5 and conclude this paper in Section 6.

Related work
Most of vehicular safety applications proposed in the literature rely on the IEEE 802.11p standard, which uses the DCF as its MAC protocol. The authors in [2][3][4][5][6][7] studied and evaluated the IEEE 802.11p for VANETs. They showed that this protocol has problems in predictability, fairness, low throughput and high collision rate especially in high-density networks. Due to these problems, many of the proposed solutions are based on time division multiple access (TDMA) where the channel is divided into time slots and each node is granted access during one or more of these time slots. In [8], the authors proposed a decentralized TDMA-based MAC protocol but did not specify how to synchronize the TDMA time slots among all vehicles within the range by using only one wireless channel. The authors in [9] proposed a self-organizing time division multiple access (STDMA) MAC protocol to grant channel access to all nodes within the range. In ADHOC MAC [10], the time is divided into frames, and each frame has a fixed number of slots where nodes can only reserve one or more of the free unreserved slots. However, in TDMA, strict synchronization and large overhead are needed between all nodes, and the system can only handle a limited number of vehicles within the range. This is a problem in VANETs where MAC protocol has to scale well since the number of nodes are not limited and vehicles can enter and leave the network at any time.
In [11,12], the authors proposed a space division multiple access (SDMA) scheme where the road is divided into small cells. Each cell is large enough to occupy only one vehicle. For each cell, they assigned a time slot, frequency band or a code for the vehicle in that cell to use. This scheme has poor efficiency since most of the cells are empty especially in low-density networks and suffer from the location error problem.
A few clustering-based schemes have been proposed by [13] and [14] where nodes in the network are grouped into clusters. In [13], the authors proposed a clustering-based MAC multichannel protocol (CMCP) where each node is armed by two transceivers which they assume that they can operate simultaneously on different channels. One transceiver is used for the communication between cluster members, while the other is used to communicate with the cluster head on a different channel. Inside the cluster, the cluster head organizes the channel access between member nodes by using TDMA using one of its transceivers and different CDMA code. The other transceiver is used to communicate with the neighboring cluster heads by using the DCF of IEEE 802.11 on a different channel. This system has a very high cost and needs a very strict synchronization between all nodes in the network. Moreover, the system has a break point since all communications were done through the cluster head which uses both of its transceivers in communication with its cluster members and the neighboring cluster heads.
Since the communication requirements of VANETs' safety applications are complex and demand high throughput, reliability and bounded time delay concurrently, the design of their MAC protocol is a challenge especially in high-density scenarios where the number of nodes contending for the channel use is large. It is clear from previous studies that using TDMA or STDMA need strict synchronization and complete premapping of geographical locations to TDMA slots, but they are fair and have predictable delay. On the other hand, using CSMA scheme is less complex, supports variable packet sizes and requires no strict synchronization but has problems such as unbounded time delay and consecutive packet drops especially in high-density networks. Therefore, clustering is used to limit channel contention, provide fair channel access within the cluster, increase the network capacity by the spatial reuse of network resources and effectively control the network topology. The main challenge in clustering is the overhead introduced to elect the cluster head and maintain the membership in a highly dynamic and fast-changing topology such as in VANETs. Therefore, we propose a distributed and dynamic cluster-based MAC protocol called COMAC, which integrates OFDMA with the contention-based DCF algorithm in IEEE 802.11p. In COMAC, the network is dynamically organized into clusters where cluster memberships are changing overtime in response to vehicles mobility and density on the road. Cluster head is elected based on a stability criteria and could be taken over by another member if its stability factor has fallen below certain threshold. The proposed MAC protocol is adaptable to drivers' behavior and has a learning mechanism to predict the future speed and position of all cluster members using the fuzzy logic inference system. In COMAC, the OFDMA subcarriers of the IEEE 802.11p CCH channel are divided into four sets, and cluster members can use only one set within their cluster. COMAC is designed to fit under the IEEE 802.11p spectrum and specifications. In our COMAC, we assume that all vehicles are moving in one direction, i.e., one-way multilane highway segment.

COMAC PROTOCOL
Our proposed MAC protocol aims to make a large network with highly dynamic nodes that appear smaller and more stable, to increase the system reliability and to reduce the time delay in real-time applications. The main idea of our COMAC is to partition the network into clusters of nodes that are all reachable by their cluster head. Vehicles are equipped by one transceiver that can work in omnidirectional and directional modes. Vehicles are also equipped with the global positioning system (GPS) for positioning and time synchronization purposes. Vehicles will alternate between the CCH channel and one or more of the service channels every 100 ms. While they are synchronized to the CCH channel, vehicles transmit and receive their control and safety messages in omnidirectional mode. On the other hand, they could use directional mode when they are synchronized to one of the SCH channels. We assume that all vehicles within a cluster will have the same communication range (R), i.e., they use the same transmitting power (P t ), except for the cluster head that has two levels of power: one level of P t , which is the same as other members and dedicated to communicate with its cluster members, and a second level of power that is enough to reach a distance of 2R to communicate with neighboring cluster heads.
The COMAC use OFDMA where the CCH channel subcarriers are divided into four sets (c 1 , c 2 , c 3 , c 4 ). The first three sets can be used by clusters where each cluster has to select different set from its neighboring clusters as shown in Figure 1. The fourth set (c 4 ) is temporary and can be used only by a node that cannot join a cluster or a node that is moved out from a cluster and cannot communicate any more with its former cluster head. The use of c 4 is temporary; once a node falls again within the range of a cluster head, it releases c 4 and starts to use the same set as the new cluster head. The algorithm of selecting the subcarriers set will be explained in a later subsection.

A. Clustering in COMAC
The clustering algorithm is the most important component in any clustering-based MAC protocol. The faster the nodes are clustered around their elected cluster head and the less often they reelect a new cluster head, the more the network will appear small and static. In COMAC, each vehicle has its own unique ID and collect information such as speed, acceleration and direction from its internal sensor network and its position from GPS system, which is also used for time synchronization. The vehicle will also calculate its weighted stabilization factor (SF w ), which is a function of the change in its relative speed and direction compared to its neighbors for the time it has been on the road. A vehicle with higher (SF w ) is more likely to be elected as a cluster head. Calculation of the parameter (SF w ) will be explained in a later subsection.
Vehicles synchronize their time with the GPS while they enter the network for the first time. At the beginning of every synchronization interval (SI), all vehicles will synchronize to the CCH channel to exchange their status messages. The status message will contain information about its type (Type), the vehicle's (ID), its (SF w ) factor, current speed (v), current position (Pos), acceleration (a) during the next period (T f ), communication range (R), cluster head's ID (CHID) and the backup cluster head's ID (CHBK) as shown in Figure 2. The acceleration will help to determine the future values of the vehicle's speed and position and will be determined in a later subsection. The field Type has four values: 0 is for cluster member's status message; 1 is for cluster head's first message; 2 is for cluster head's invitation message; 3 is for cluster head's last message.
The vehicle will first listen to the channel for a random length of time from [0-CCI] to check whether there are other vehicles on the network and do one of the following: (1) If there are no other vehicles or it does not lie within the communication range of the neighboring cluster heads (lone state), it will start transmitting its status messages using the temporary subcarriers set c 4 and set the fields CHID = CHBK = 0 in its status message.
(2) If it encounters other vehicles using the same temporary set c 4 without an elected cluster head, they will start forming a temporary cluster. The vehicle with the highest SF w will be elected as the cluster head, and if more than one vehicle have the same SF w , they will elect the vehicle with the highest ID. The vehicle that happened to be located within the range of two or more cluster heads will select to join the cluster with the closest cluster head. The change in the cluster's status from temporary to main cluster depends on the status of the neighboring clusters and will be explained in a later subsection.
(3) If the vehicle hears other vehicles on the road whose status messages contain a cluster head ID, it will join that cluster if it is located within its cluster head's range. The vehicle will set its field CHID to the cluster head's ID and send its status message when it receives the cluster head's invitation message or the channel is being idle for time T w (d) as in Equation (4) which will be introduced in Subsection 3-D. (4) If the vehicle moves out of its cluster head's range, it will wait for certain number of SI intervals, which is three in our protocol, before it gives up the subcarriers set that it was using in the previous cluster. The vehicle will look for a new or a temporary cluster to join as in step 1. Figure 3 depicts the finite state machine dictating the state of any COMAC node.

B. COMAC parameters
The stability and reliability of COMAC is affected by the following parameters: (1) The stabilization factor (SF), which reflects the relative movement between adjacent vehicles. In every CCI interval, each vehicle will have information about all vehicles within its communication range and hence will calculate its average speed differencevd j from all other vehicles as: where n is the total number of vehicles within jth vehicle's communication range including itself, v j is the jth vehicle's speed in m/s. The jth Vehicle will calculate its stabilization factor (SF j ) at the end of every SI interval as: where V max is the maximum allowed speed on this road. If there are no other vehicles on the road, the vehicle compares its speed with V max to calculate its SF factor.
(2) The weighted stabilization factor (SF w ), which is the exponential-weighted moving average of the previous values of SF factors. Each vehicle calculates its new SF w i from the new value of SF i and the previous value of SF w i−1 as: where 0 ≤ ζ ≤ 1 is the smoothing factor and chosen here to be 0.5.
(3) The vehicle's acceleration (a), which will help to predict the vehicle's speed and position in the near future (after time T f ). The decision to accelerate, to decelerate or to stay on the same speed depends on many factors such as the distance between the vehicle and its front neighbor, the relative speed between them, the road conditions and the driver's behavior.  Most of the time, the drivers' behavior and how they estimate the interdistance and other factors are subjective and not predictable. Fuzzy logic is used to deal with this uncertainty in our study. Fuzzy logic is a rule-based system that consists of IF-THEN rules that forms the key component of any fuzzy inference system (FIS) [15]. Since FIS lacks the adaptability to deal with changing external environments, we incorporate a learning technique to predict the vehicles acceleration based on the previous behavior of the driver.
The FIS system consists of a fuzzifier, rule base, reasoning mechanism and defuzzifier. The fuzzifier defines the membership functions used in the fuzzy rules. In this paper, the triangular fuzzifier is chosen to implement our FIS system. While the rule base contains a selection of the fuzzy rules, the reasoning mechanism performs the inference procedure upon those rules to derive a reasonable output. The defuzzifier is a method used to map the output fuzzy sets to a crisp output values. In this paper, we used the interdistance and the relative speed between two vehicles as the input parameters to our FIS system and the vehicle's acceleration as its output.
The membership function of the distance between a vehicle and its immediate front neighbor is μ d and can take any of the three values: small, medium and large as shown in Figure 4. The parameter t s is a design parameter that represents the safety following distance between two vehicles on the road, i.e., the time needed by the following vehicle with a speed of v j to cross this interdistance.
The membership function of the relative speed between two vehicles is μ v and can take the three values: slow, same and fast as shown in Figure 5. The parameters a and g are used to make the system more adaptable to the driver's behavior on the road. Initially, their values are set to a = g = 1 and will be increased or decreased by a step of ε if the driver's decision to accelerate or decelerate did not match with the predicted output values as follows: if the system predicts that the vehicle will accelerate but it did not, then a ⇐ (1 + ε)a; if the system predicts that the vehicle's speed will stay the same but it accelerates, then a ⇐ max{(1 -ε)a, 0}, and if it decelerates, then g ⇐ max{(1-ε) g, 0} and finally if the system predicts that the vehicle will decelerate but it did not, then g ⇐ (1 + ε) g. By this, the values of a and g will converge to ceratin values after a short period of time to capture the driver's behavior on the road. If the vehicle's acceleration matches with the predicted value, then keep the same values of a and g.
The output variable, namely the predicted acceleration, is μ acc and has the following fuzzy names: accelerate, stay at the same speed and decelerate. We choose the crisp outputs 2, 0 and -2 m/s 2 for the values of μ acc , respectively. This is called a center-average defuzzifier, which produces a crisp output based on the weighted average of the output fuzzy sets. The output variable μ acc is shown in Figure 6. Table 1 shows the fuzzy rule for the acceleration output.

C. Cluster head election
Since VANETs are highly dynamic and their network topologies change very frequently, the clustering algorithm should be distributed and operate asynchronously. Therefore, the algorithm of electing and reelecting the

Small
Medium cluster head should be fair, simple and with minimal communication and coordination among vehicles within the communication range. For clusters to look more stable compared to the highly dynamic VANET, the algorithm should not initiate cluster head reelection very frequently and nodes should join, leave and form a new cluster smoothly. Moreover, if the network initiates an election or reelection of a cluster head, the algorithm should converge to a stable clustered topology in a very short time.
In COMAC, the clustering algorithm does not require any additional messages other than the dissemination of vehicles' status messages. Therefore, when vehicles are on the road for the first time, they start sending their status messages without an elected cluster head. Once these messages are received by all nodes in the network, vehicles start calculating their SF w factors.
If a vehicle has the highest weighted stabilization factor SF w among all vehicles within its communication range, it will elect itself as a cluster head by setting its field CHID to its own ID. The new cluster head will start sending its status messages using one of the main subcarriers sets (c 1 , c 2 , c 3 ). All other vehicles within its range have the chance to cluster with this cluster head and use the same subcarriers set.
If there is another vehicle, within this vehicle's range, which has the highest SF w factor, it will elect it as a temporary cluster head by setting its field BKID to the elected cluster head's ID. This temporary cluster head will check first whether it has the highest SF w factor, if yes it will elect itself as a cluster head by setting its field CHID to its own ID, and if no, it will accept to act as a temporary cluster head and will not participate in electing a new cluster head within its range waiting either to merge with another cluster or to change its state to a main cluster.
To fasten the network convergence to a stable cluster topology, a vehicle that is not a cluster head within its own range and lies within the range of a temporary cluster head will join this cluster and will not participate in electing another temporary cluster head. A vehicle that lies within the range of two cluster heads will cluster with the closest cluster head to itself given the priority to the main cluster over the temporary cluster.

D. Cluster head's role
Once elected, the cluster head will send three extra messages: First, a consolidated message (with Type = 1) will be sent at the beginning of every CCI interval. This message has information about the neighboring clusters and all current cluster members where their IDs are ordered from behind to front. Cluster members will follow this order to send their status messages within the CCI interval. At the same time, each vehicle calculates its maximum waiting time T w (d) that it should wait for its turn to access the channel based on their distance d from the elected cluster head as: where R is the communication range used by all cluster members, d [-R, R] is the distance from the cluster head where vehicles in front of the cluster head have positive distance and vehicles behind the cluster head have negative distance and T A = 6 × 13 μs is the arbitration interframe space (AIFS) for this type of messages as in IEEE 802.11p standard. A vehicle can send its status message when the vehicle ahead of it in the sequence finishes transmitting its status message. Otherwise, if the vehicle did not hear the message of its head neighbor, it will send its message when its T w (d) expires. After every successful transmission, each node updates its T w (d) based on the distance from the last vehicle that successfully transmits its status message. Vehicles that are in front of the cluster head will wait until their cluster head takes its turn to send its status message (Type = 0) successfully. This is to eliminate the hidden terminal problem that could arise from the other side of the cluster. Second, after receiving all status messages from its cluster members, the cluster head will send a status message with Type = 2, which is an invitation for new members to join the cluster and send their status messages. Third, a consolidated message with Type = 3, which contains information about all of its members with enough power to reach double the communication range (R) when the channel is idle for time (2+ψ)×T A , where ψ is a random number from [0,1]. This message is intended to reach the two neighboring cluster heads.
The cluster head will also decide which subcarriers set and what communication range R that all of its members should use and synchronize it with its neighboring clusters. In the remaining time of the CCI and after sending its final message, the cluster head will accept route requests from its members if they want to communicate with other vehicles on a different channel and outside the CCI interval.
If a vehicle has an emergency message, it will contend for the channel access using the minimum contention window specified for high priority class in IEEE 802.11p, i.e., CW min = 3 and waiting time T w (d) = 2 × 13 μs, to send this message for several times depending on the application. Once this message is received by the cluster head, the cluster head will start transmitting this message periodically with enough power to reach double the communication range (R) and in the direction of interest, all other cluster members will defer from using the channel during this time. When the next cluster head receives this emergency message, it will broadcast it omnidirectionally with a communication range (2R) to reach both the next cluster and the originating cluster heads. Once the originating cluster head hears its message back from the neighboring cluster head, it will stop broadcasting it with high power while continue to Table 1 The fuzzy rule of the acceleration broadcast it to all of its members for several times depending on the application or until the emergency situation is cleared. The emergency message will continue to propagate in the direction of interest for a maximum number of hops depending on the application and the emergency situation.

E. Temporary cluster
Once a temporary cluster has been formed, the temporary cluster head will wait for the first chance to either merge with adjacent cluster or become a main cluster itself. If this temporary cluster head falls within half of the communication range of its adjacent cluster head, it will merge with this cluster by sending a status message that includes the new cluster head's ID using the same temporary subcarriers set. When the temporary cluster members receive this message, they will join the new cluster if they fall within the range of the new cluster head; otherwise, they will form a new temporary cluster with a new cluster head that has the highest SF w factor among the remaining nodes that could not join the new cluster.
Since a cluster head communicates with adjacent cluster heads with double the communication range (2R), it knows about the subcarriers sets they use. Therefore, the temporary cluster head can change its state to a main cluster by selecting a subcarriers set that is not used by its adjacent clusters and trying its best to maintain the sequence of the subcarriers sets as c 1 , c 2 , c 3 . The cluster head knows the subcarriers set that is used by the cluster head in front of it; therefore, it will select to use the subcarriers set that comes after it in sequence. If the front cluster uses the temporary set c 4 , it will select c 1 set to start the sequence. If there is no front cluster, it will select a subcarrier set that is lower in sequence of the behind cluster. The core idea in COMAC is to let each cluster to iteratively move its subcarriers set following its immediate front cluster's set until a network convergence occur.

F. Cluster maintenance
Once the cluster head has been elected, our goal is to maintain the cluster topology as much stable as possible by not initiating the election process very frequently. Therefore, the cluster head will calculate the expected positions and speeds of all of its members after time T f based on their advertised speeds and accelerations as follows: x(T f ) = x + vT f + 1 2 v(T f ) = v + aT f .
The cluster head will remain as a cluster head if all its members are still within its range after time T f . The cluster head will select a backup cluster head based on two criteria: first, it is the closest to the center of the cluster, and second, it has the highest SF w factor among all vehicles around the cluster's center. If some of the cluster members will become out of the cluster head's range but still within the range of the backup cluster head, the current cluster head will hand the responsibility to the backup cluster head by setting its field CHID = CHBK. Otherwise, if some members become out of range of both the cluster head and its backup, the current cluster head will remain the cluster head in the next interval. Vehicles that became out of range will form a temporary cluster or join an adjacent cluster if they fall within its cluster head's range.

Analysis
The COMAC protocol is based on the weighted stability factor of vehicles on the road which measures how vehicles behave compared to the overall traffic flow. Vehicles that are well behaved are more likely to cluster with themselves around a cluster head that is moving on average with the same speed as other vehicles around it. Therefore, the network topology will look more stable where clusters are seen moving in sequence on the road instead of vehicles passing each other. This will allow achieve an acceptable levels of performance once the network converges. Vehicles will have the chance to send their status messages with less competition for accessing the channel and less vulnerable to the hidden terminal problem. In the following, we will present the performance measures of COMAC with respect to network convergence, stability, reliability, overhead and time delay.
As in [16], we built our model based on a multilane highway scenario. Since the communication range is much larger than the road's width, we simplify the network in each direction of the road as one-dimensional VANET. We assume that all status messages have the same length L bits, all vehicles have the same transmission range R meters and use the same transmission rate r d Mbps. Vehicles arrive at the beginning of each direction of the highway segment as a Poisson process with average rate b vehicles/s. After that they follow the direction of the road with a speed uniformly distributed between V min and V max with means μ = V min +V max 2 .
From this model, we derived the distribution of vehicles that are traveling in one direction on a highway segment at the steady state as a Poisson distribution with rate 2βR μ [16]. As a result, the probability of having k vehicles within a distance of 2R is: Therefore, the interdistance x between vehicles on the road has an exponential distribution with mean μ β as:

A. Network convergence and stability
In COMAC, the cluster size is governed by the cluster head's communication range, which is a critical parameter in networks stability. Increasing the communication range results in increasing the cluster size, and hence, more vehicles will contend for using the shared channel to send their status messages. At the same time, the increase in the communication range results in more space for vehicles to move within the cluster space with less probability to cross the cluster boundary. On the other hand, decreasing the communication range results in low network stability, where vehicles are very often cross the cluster's boundary but at the same time, the number of vehicles that are competing for the channel will decrease. To optimize the communication range and hence the cluster size is very difficult especially in a highly dynamic environment such as VANETs. In [16], the authors showed how vehicles' dynamics affect the network density and hence the reliability and throughput of VANETs' safety applications. However, in [2] and [17], the authors derived the relationship between the communication range and the network density, message sending rate, message size, data rate and channel conditions. Since each vehicle in the network has its own view of the network density and channel conditions, finding the optimal network parameters is difficult. Therefore, our main goal in COMAC is not to find the optimal cluster size but to make the network more stable.
In COMAC, we define two threshold cluster sizes (i.e., number of vehicles within the cluster head's range) K h = 2λ h R h and K l = 2l l R l , where R h is the communication range that all vehicles will use when they enter the road, l h is the maximum vehicle density that corresponds to R h and measured by vehicles per meter, R l is the lower communication range that can be used by all vehicles which is related to a jam scenario and l l is the vehicles' density that triggers the change from R l to R h . The cluster head can sense the network density by the number of status messages that are received within the control channel interval CCI. K h represents the maximum number of vehicles that can be accommodated within the cluster and have the chance to send their status messages. Therefore, to prevent the frequent change in cluster size as vehicles move in and out of the cluster boundary, the cluster head will use the hysteresis mechanism as shown in Figure 7.
In low-density networks, the cluster head uses the communication range R h because the vehicle density is below the threshold l h . When vehicle density reaches l h , the cluster head will change its communication range to R l triggering a change in the cluster size. Vehicles that found themselves out of the cluster attempt to join another cluster or to form a new cluster, while vehicles that are still within the cluster will change their communication range accordingly. The cluster head will keep using R l although the network density is decreasing till it reaches the threshold l l where it will change the communication range back to R h triggering a new change in the cluster size. By using the hysteresis mechanism, we reduced the frequent change in cluster topology due to vehicles' high dynamics.
For vehicles that found themselves inside a new cluster, they decide to either join the new cluster or stay with their current cluster based on the distance between them and the two neighboring cluster heads. The network convergence in this case is instant unless one of the cluster heads decides to merge with a neighboring cluster leaving some members behind it. In this case, either the backup cluster head will take over or a new cluster head will be elected.

B. Time delay
In COMAC, the cluster head will broadcast first its consolidated message to all of its members indicating the start of the CCI interval. After that all cluster members including the cluster head schedule themselves for the channel access to send their status messages by first following the sequence advertised by the cluster head. If the sequence is interrupted, then vehicles can use the channel based on their calculated T w (d) as in (4). All vehicles that are in front of the cluster head will defer from using the channel until they receive the cluster head's regular status message. This is to eliminate the hidden terminal problem that could arise from the other side of the cluster. After sending its regular status message, the cluster head will wait for (2 + ψ) × T A period after every successful transmission of a cluster member's status message before it sends its Type = 2 or Type = 3 message. By this, the cluster head gives enough time for all of its members and the recently joined members to send their status messages. To find the upper bond for the average time till all cluster members manage to send their status messages, we assume that all members wait for time T w (d) before they send their messages. The first message that will be sent by the cluster head will take time T cf as: where L cf is the cluster head's first message size in bits, r d is the data rate and δ is the propagation delay.
The first cluster member to win the channel access, assuming that it is located at distance d from the cluster head, will take T mf time as: where d in this case is a uniformly distributed random variable over the interval [-R, 0]. Therefore, the average time of T mf is The second vehicle to transmit its status message is the one which is the closest to the first one. Assuming that the interdistance between them is d which in this case has an exponential distribution as in (8), then its transmission time is T m (d) = T w (d) + L r d + δ. Therefore, the average time of T m is The cluster head will wait for time (2 + ψ) × T A before it can send its invitation message (Type = 2); therefore, the average transmitting time for this message is The last message that the cluster head will send is a consolidated message that has information about all of its members to reach a range of 2R. Assuming the size of this message is L cl bits and since the cluster head will wait for (2 + ψ) × T A before sending this message, therefore, the average transmitting time for this last message is From Equations (9), (11), (12), (13) and (14), we can find the upper bond of the total average time for all cluster members to send their status messages as: since the average number of vehicles within a range of 2R is 2βR μ as per our model in (7). The lower bond of the total average time for all cluster members to send their status messages is when all cluster members send their status messages following the sequence specified by the cluster head without waiting for time T w (d). Therefore, the lower bond for T avg is

C. Reliability
We define the reliability by the probability of successfully delivering safety messages from all cluster members during the control channel interval CCI. To assure that all vehicles have the chance to send their status messages within the control channel interval CCI, we should have where r ≤ 1 is a design parameter to spare some time from the CCI for other control messages.
From (17), we can find l h and R h that we should use to trigger the change in the cluster size as discussed in Figure 7. If we assume that each cluster has the same number of vehicles K, then the size of the cluster's first message is L cf = 2K × L and its last message is L cl = K × L. Moreover, as the communication range R increases, the term e use ceratin maximum range as R h , then we can find λ h = K 2R h by applying (15) into (17) as: While R l is governed by the jam scenario where we assume that each vehicle occupy 10 m on average and the road has W number of lanes, then On the other hand, l l is a design parameter that can be chosen as a fraction of l h , such that λ 1 < R 1 λ h R h . The smaller l l is selected, the less frequent the cluster size is changed. In our simulations, we set

Model validation and simulation
The performance of COMAC can be assessed based on different measures, such as the stability and efficiency of the clustering algorithm, system reliability and time delay.
To test for the system stability and efficiency, we define four metrics: First, the average cluster head time (CHT), which is the sum of all cluster head times divided by total number of cluster heads during the simulation period. Second, the average cluster stability factor (CSF), which is the average relative speed of the cluster head compared to its members and can be calculated as where C n (t) is the number of formed clusters at time t and T s is the total number of CCI intervals during the simulation time. Third, the average cluster size (CS), which is the total number of vehicles that became cluster members divided by the total number of formed clusters during the simulation time and can be calculated as where CM j (t) is the number of cluster j's members. Finally, the clustering management overhead, which is the total number of invitation messages sent by the cluster head compared to the total status messages sent by all cluster members within any CCI interval.
The system's reliability (ℜ) is tested by the probability for a cluster member to send its status message during the CCI interval and can be calculated as: CMs where CMs j (t) is the number of cluster j's members managed to send their status messages at time instance t.
The system's delay is measured by allowing one vehicle to send an emergency message and measure the time it reaches the intended distance, which is 2,000 m in our simulation, and the probability of successfully receiving this message by all vehicles within the intended distance and in the direction of interest.
The simulation is developed based on the network simulator ns-2 [18] to measure the mean cluster size, network convergence, the time delay for an emergency message to reach a certain distance and the probability of a vehicle to be within a cluster and its dwell time. ns-2 is a well-known simulator in analyzing VANETs. We used a realistic mobility model generated by MOVE [19], which is built on top of the micro-traffic simulator SUMO [20] that has the most realistic mobility traces for VANETs simulations [21].
The simulation scenario is built upon one-directional 4 lanes highway segment of 8,000 m in length and looped back to form a closed rectangle. The two opposite directions of the highway are separated by more than 500 m such that the clustering could not occur across them. The vehicles' speed ranges from 80-120 km/h, which is typical for Ontario highways. We used the Nakagami-m propagation model with configuration parameters as in [22]; hence, receivers located within 100 m of the transmitter will receive the signal based on Rician distribution, and others are based on Rayleigh distribution. We assume that all vehicles are synchronized to the control channel interval through a GPS system to send their status messages. We let one vehicle to send an emergency message to be propagated to a distance of 2,000 m behind it. The safety following distance or time is selected to comply with the 3 s rule, i.e., t s = 3 s and the cluster maintenance time is T f = 10s. The communication range R l is set to 200 m based on Equation (19). For R h , we used the communication ranges 300, 200 and 100 m, which correspond to the transmission powers of 109, 48 and 12 μ W, respectively. Therefore, when the used communication range R h = 300 m, we calculate l h = 0.25 from (18) and λ 1 = R 1 λ h R h = 0.17 vehicles/m. For the communication ranges of 200 and 100 m, there is no need to calculate l h and l l since these ranges are equal and less than R l , respectively. We compare our protocol by the CMCP [13] since it is the most relevant to our work. Each simulation typically simulated 1,000 s of real time and averaged over ten times to obtain the mean value as the final performance metric. Table 2 lists the simulation parameters used unless a change is mentioned explicitly. Figure 8 shows the impact of traffic density on the cluster topology for various communication ranges. The traffic density l v can be increased by either decreasing the vehicles' average speed μ or increasing the vehicles arriving rate b since λ v = β μ as per our model in (8). Figure 8a shows that the average life time of a cluster head is increasing by the increase in vehicles' density on the road. This is because the interdistances between vehicles are decreasing, and hence, the relative speed between them is also decreasing, resulting in high stability factor for the cluster head as shown in Figure 8b. This verifies that our clustering algorithm works perfectly by allowing the cluster head to reelect itself when all or most of its members will be within its range after time T f in the future. Figure  8c shows the increase in the average cluster size as the vehicle density increases. In COMAC, the cluster head has a rule to change the communication range when the vehicles' density reaches a threshold l h ; hence, all of its members have the chance to send their status  messages. This is clear on the abrupt change in the cluster size when the vehicle density reaches 0.25 vehicles/m for the used communication range R = 300 m. It is obvious that the stability of the network topology will increase by increasing the communication range as shown in Figure 8a, b and 8c. This is because vehicles will have more space to move within their cluster when the communication range is large without crossing the cluster's boundary. Figure 9 shows the average dwell time for a cluster member within the range of its cluster head. It is clear that the dwell time is increasing by the increase in either the vehicle density or the communication range. Increasing both the range and density will result at certain point that the cluster head will decrease the range, as explained in the hysteresis algorithm, to accommodate members not more than what the CCI interval can tolerate. The sudden decrease in the communication range results in less-stable network topology for a short period of time. This is clear from Figure 9a, which shows that the dwell time starts to increase again after the range has decreased since vehicles that found themselves outside the cluster will soon form a new cluster or join a neighbor cluster. Figure 9b shows the average cluster member's dwell time as a function of the cluster maintenance time (T f ). As the cluster maintenance time increases, the accuracy of predicting the vehicle's future position and speed decreases. But in COMAC, this decrease is very small since our algorithm is more adaptable to the driver's reactions to the interdistance and relative speed between the two following vehicles. This proves that the learning algorithm in COMAC increases the efficiency of electing and reelecting a cluster head giving more time to cluster members to stay within their cluster's boundary. It is also clear that increasing the communication range will increase the dwell time and at the same time will decrease the effect of long maintenance time T f . Therefore, T f should be selected carefully based on the configured range and average vehicles' density to increase the dwell time and decrease the computational overhead in the algorithm. Figure 10 shows the performance evaluation of our clustering algorithm as a function of vehicle density. Figure 10a shows the probability that all cluster members managed to send their status messages during the CCI interval. Since the cluster head in our clustering algorithm advertises the sequence that all of its members should follow to send their status messages, the system reliability is high especially in low-density networks. As the network density increases, the reliability decreases slightly since there is more possibility that new members will join the cluster. These new members are not included in the advertised sequence and have to compete for the channel use based on their distance from the last transmitter as in (4). This may cause collisions or disturbing the sequence, forcing the remaining members to compete for the channel use based on (4). This explains why the reliability drops to the lowest level when the cluster head changes the used communication range as the network density reaches 0.25 vehicles/m. Since the cluster head in COMAC reduces its communication range when the vehicle density reaches a certain threshold, it maintains high reliability even in a highdense networks compared to CMCP and the DCF of IEEE 802.11p where they suffer from high collision probability and drop rate. Figure 10b shows the time taken by an emergency message sent by a vehicle to reach a distance of 2,000 m versus the vehicle density for different communication ranges. It is obvious that as the communication range increases, the travel time decreases since the number of clusters that the message will hop through decreases. We can also see that the decrease in the vehicle density results in increasing the emergency travel time since in low-density networks, cluster heads struggle to find a neighboring cluster head to carry the message forward. Figure 10c shows the time needed for all cluster members to send their status messages as a function of vehicle density. It is clear that this time is less than the theoretical upper bound derived in (15). This proves that our clustering algorithm is efficient in managing the cluster size to allow all of its members to send their status messages. Figure 11 shows the cluster management overhead when the communication range is 100 m as a function of vehicle density for both our proposed COMAC and CMCP protocols. We can see as the vehicle density increases, the overhead percentage decreases since more vehicles will manage to send their status messages. In COMAC, the overhead is much lower than that of CMCP since the cluster head in COMAC has a role of selecting a backup cluster head that will take the responsibility of the cluster if it has higher stability factor than the current cluster head. This increases the dwell time of the cluster members and the stability of the cluster topology.
From all simulations, it is obvious that our COMAC performance far exceeds that of CMCP since the proposed protocol has the ability to elect a cluster head that moves with the same speed as most of its members. It has also a maintenance algorithm to reelect and elect a backup cluster head that covers most of its members in the future. The algorithm of changing the communication range when the number of cluster members reaches a certain threshold helps to maintain a high reliability compared to CMCP and DCF especially in high-density networks.

Competing interests
The authors declare that they have no competing interests.

Conclusion
In this paper, we proposed a novel clustering-based MAC protocol for VANETs. Our COMAC protocol is a mobility-based clustering protocol where cluster heads are elected and reelected in a distributed manner according to their relative speed and distance from their cluster members. The high stability of COMAC results from its adaptability to drivers' behavior on the road and its learning process to predict the future speed and position of all cluster members using the fuzzy logic inference system. In COMAC, the cluster head can change the used communication range based on the sensed vehicle density to allow all of its members to send their status messages within the CCI interval. The clusters created by COMAC exhibit long average cluster head's life time and long average dwell time for its members. Under COMAC, safety messages are exchanged within a cluster following a sequence that is advertised by the cluster head. Therefore, the reliability of COMAC is almost the same as in TDMA schemes but without the hassle of reserving time slots and much more than fully contention-based schemes. Moreover, the cluster heads in COMAC have to select one of four subcarrier sets that is different from their cluster head neighbors to eliminate the hidden terminal problem. The simulation results show that our proposed clustering protocol can achieve a timely and reliable delivery of emergency messages to their intended recipients. They also show that COMAC is a highly stable MAC protocol for VANETs.