Skip to main content
. 2023 Jan 3;23(1):531. doi: 10.3390/s23010531
Algorithm 1 bcn Reception
  • 1:

    procedureOn_bcn_Reception(beacon* bsm)                                            ▹ for each vehicle vi receiving a beacon bsm from vj

  • 2:

        Calculate the temporary distance Tempo_dist between vi and vj;

  • 3:

        if (Tempo_dist<=Delimiter_radius) then                                                   ▹ if vj is a potential delimiter

  • 4:

            if (Tempo_dist<=Prv_Neighbor_radius) then                                       ▹ if vj is in the privacy neighbors radius

  • 5:

               My_set.insert(vj);                                                                    ▹ insert vj in My_set

  • 6:

            end if

  • 7:

            if (vi and vj are on the same road) then

  • 8:

               if ((vi and vj are on the same direction) AND (vj is in front of vi)) then

  • 9:

                   if ((vi and vj are on the same lane) AND (Tempo_dist is > than Front_1_dist)) then        ▹ trying to obtain the farthest same lane front delimiter

  • 10:

                       Front_1_id←bsm.SenderID();                                                           ▹ which is vj

  • 11:

                       Front_1_dist←Tempo_dist;                                                          ▹ updating Front_1_dist

  • 12:

                       Front_1_speed←bsm.SenderSpeed();                                                  ▹ updating Front_1_speed

  • 13:

                   else if (Tempo_dist is > than Front_2_dist) then                                       ▹vi and vj are not on the same lane

  • 14:

                       Front_2_id←bsm.SenderID();                                                        ▹ which is vj

  • 15:

                       Front_2_dist←Tempo_dist;                                                    ▹ updating Front_2_dist

  • 16:

                       Front_2_speed←bsm.SenderSpeed();                                               ▹ updating Front_2_speed

  • 17:

                   end if

  • 18:

               else if ((vi and vj are on the same direction) AND (vj is behind of vi)) then

  • 19:

                   if ((vi and vj are on the same lane) AND (Tempo_dist is > than Rear_1_dist)) then          ▹ trying to get the farthest same lane rear delimiter

  • 20:

                       Rear_1_id←bsm.SenderID();                                                          ▹ which is vj

  • 21:

                       Rear_1_dist←Tempo_dist;                                                      ▹ updating Rear_1_dist

  • 22:

                       Rear_1_speed←bsm.SenderSpeed();                                             ▹ updating Rear_1_speed

  • 23:

                   else if (Tempo_dist is > than Rear_2_dist) then                                      ▹vi and vj are not on the same lane

  • 24:

                       Rear_2_id←bsm.SenderID();                                                       ▹ which is vj

  • 25:

                       Rear_2_dist←Tempo_dist;                                                   ▹ updating Rear_2_dist

  • 26:

                       Rear_2_speed←bsm.SenderSpeed();                                             ▹ updating Rear_2_speed

  • 27:

                   end if

  • 28:

               end if

  • 29:

            end if

  • 30:

        end if

  • 31:

        n_Neighbor++;                                                     ▹ increment the n_Neighbor number of vi

  • 32:

        Process_Beacon(BSM);

  • 33:

    end procedure