# Towards Mitigating Jellyfish Attacks Based on Honesty Metrics in V2X Autonomous Networks
## 4 Secure and Efficient Routing Protocol for Jellyfish Attack Prevention in V2X (SecE-V2X)
### SecE-V2X Routing Algorithm  
The SecE-V2X algorithm ensures security in vehicular networks by isolating malicious nodes from participating in packet routing during the next-hop selection phase. To ensure this, when a node communicates with any neighbor the Honesty value of this neighbor is computed in Equation (7) through the use of the packet loss rate, delay, and packet reordering. The beacon containing the updated Honesty is broadcasted after every Honesty update. Algorithm 1 below describes the steps involved to calculate the neighbor's Honesty value. ```
// The steps taken to calculate the neighbor Honesty value With the neighbor N do D\(\leftarrow\)getDelay(N); // Getting the delay of the node N  Sp\(\leftarrow\)getP(N); // Getting the number of successfully delivered packets of the node N  Fp\(\leftarrow\)getP(N); // Getting the number of unsuccessfully delivered packets of the node N  y\(\leftarrow\)Sp+Fp1;  Cfdt\(\leftarrow\)(2*Sp +1)/(2*y); // Calculating the forward packet confidence  Cfct\(\leftarrow\)1/y; // Calculating the factor of uncertainty confidence  Ccom\(\leftarrow\) (2*Cfdr+Cfct)/2 // Calculating the communication confidence  PR\(\leftarrow\)getPR(N); // Getting the packet reordering value of the node N if PR=0 then  Cdirect\(\leftarrow\)Wcom*Comm+Wdelay/D // Calculating the direct confidence else  Cdirect\(\leftarrow\)0; endif  Crcd\(\leftarrow\)0; for all i in neighborsTable do  Crcd\(\leftarrow\)Crcd+getHovr(N)[i]; // Calculating the sum of Recommended confidences endfor  Crcd\(\leftarrow\)Crcd/neighborsTable.length; // Calculating the average of the Recommended confidences  Hovr\(\leftarrow\)a*Cdirect+b*Crcd; // Calculating the overall honesty  My-id \(\leftarrow\)getNodeId(); //Getting current node id  Neighbor-id \(\leftarrow\)getNodeId(N); //Getting neighbor Node id  MyPosition\(\leftarrow\)getPosition(); // Getting current node position  NPosition\(\leftarrow\)getPosition(N); // Getting neighbor N position  t \(\leftarrow\)now(); //Getting current time  neighborsTable.upDateHonesty(Neighbor-id, NPosition, Hovr, t); //Updating neighborsTable  sendHonestyBeacon(My-Id, MyPosition, Neighbor-id, Hovr, t);
```  
**Algorithm 1**Steps involved when calculating the Honesty value for the neighbor (N). The recommended confidence and the Honesty value are computed after receiving an Honesty beacon message, and the table of neighbors is then updated. Algorithm 2 displays the activities conducted when receiving an Honesty beacon message. ```
// The steps taken when receiving an Honesty beacon message extractHonestyBeacon(Id, Position, Neighbor-id, Neighbor-Honesty, Timestamp); //Extracting information from the beacon message setHovr(N)[Id]\(\leftarrow\)Neighbor-Honesty; // Setting the honesty of the node N provided from the node Id Crcd\(\leftarrow\)0; for all i in neighborsTable do  Crcd\(\leftarrow\)Crcd+getHovr(N)[i]; // Calculating the Recommended confidence by getting the honesty of the node N provided from the node i endfor  Hovr\(\leftarrow\)a^Cdirect+b^Crcd; // Calculating the overall honesty neighborsTable.upDateHonesty(Neighbor-id, Neighbor-Position, Hovr, now()); //Updating node information in neighborsTable
```  
**Algorithm 2** Steps required when receiving an Honesty beacon message. When a node intends to transmit data to another node, it first examines all of its neighbors, after which it then chooses the one with the highest Honesty value and delivers the packet to that node. Until it arrives at its destination, the intended receiver follows the same procedure. The next forwarding nodes from the source to the destination are picked as shown in Figure 7.  
When all of the neighbors' Honesty values fall below the desired weight level, the current node sends the identical packet to the two best neighbors at the same time to increase the chances of receiving the message correctly. Algorithm 3 describes the SecE-V2X next-hop selection procedure. Figure 7: Next-hop selection from source to destination.