Skip to main content
. 2020 Feb 17;20(4):1082. doi: 10.3390/s20041082
Algorithm 1 Caching algorithm at base station

Initialize:first_cached_seq=0, seq_acked=0, last_cached_seq=0

  • 1:

    Receive packet i

  • 2:

    for Every packet i from wired network do

  • 3:

        if Destination address == vehicle’s ID then

  • 4:

            if first_cached_seq=0 then

  • 5:

               Cache the package.

  • 6:

               first_cached_seq=seqi

  • 7:

            else if seq<first_cached_seq then

  • 8:

               first_cached_seq=seqi

  • 9:

               Cache the package.

  • 10:

            else

  • 11:

               Drop the package.

  • 12:

            end if

  • 13:

            if last_cached_seq=0 then

  • 14:

               first_cached_seq=seqi

  • 15:

            else if last_cached_seq<seqi then

  • 16:

               last_cached_seq=seqi

  • 17:

               Cache the package.

  • 18:

            else

  • 19:

               Drop the package.

  • 20:

            end if

  • 21:

        end if

  • 22:

        if Source address == vehicle’s ID then

  • 23:

            if seq_acked=0 then

  • 24:

            else if seq_acked <acki then

  • 25:

               seq_acked=acki

  • 26:

            end if

  • 27:

            if first_cached_seq<seq_acked then

  • 28:

               Release the caching package from first_cached_seq to seq_acked-1

  • 29:

               first_cached_seq = seq_acked

  • 30:

            end if

  • 31:

        end if

  • 32:

    end for