Research Article

Context-Aware Multicast Protocol for Emergency Message Dissemination in Vehicular Networks

Algorithm 2

Pseudo-code of the CMED protocol.
(1) procedure endInitialMessage()
(2) Compute multicast tree ( , )
(3) Create a new ESM and add ( , ) to the header
(4) sentMessages 0
(5) SendMessage ( )
(6) procedure SendMessage ( )
(7) Transmit using WSMP
(8) sentMessages sentMessages + 1
(9) if sentMessages maxRepeatCount then
(10)  Execute SendMessage ( ) after waiting time of repeatInterval
(11) procedure ReceiveMessage ( )
(12) Retrieve multicast tree from the header of
(13) if contains myId then
(14)  if first time reception of this message then
(15)   if receiving vehicle is endangared by this event then
(16)    Warn driver to brake
(17)   Mark messageId as received
(18)   countMessages 0
(19)   if  receiver is a relay node then
     // Relay message
(20)    SendMessage ( )
(21)   else
(22)    Calculate contention time
(23)    if   then
      // Start contention
(24)        isContending = true
(25)       Execute SendMessage ( ) after waiting time of
(26)  else
    // The same message has been received previosly
(27)      countMessages countMessages + 1
(28)      if isContending OR (countMessages maxMessages) then
(29)    Cancel contention