Skip to main content
. 2024 Sep 8;24(17):5834. doi: 10.3390/s24175834
Algorithm 1 Federated learning with Selective Forwarding Attack Detection.
  •  1:

    Input: Local datasets {D1,D2,,Dn} for each CPS node

  •  2:

    Output: Global Model Mglobal

  •  3:

    Initialization:

  •  4:

    Set communication rounds T, local models M, learning rate η, aggregation method ϕ

  •  5:

    Initialize global model Mglobal(0)

  •  6:

    Fog Layer Processing:

  •  7:

    for t=1 to T do

  •  8:

       Receive local models from CPS nodes: {M1(t),M2(t),,Mn(t)}

  •  9:

       Aggregate models: Mglobal(t)=ϕ({M1(t),M2(t),,Mn(t)})

  • 10:

       Broadcast global model Mglobal(t) to all CPS nodes

  • 11:

    end for

  • 12:

    CPS Layer for Local Model Training:

  • 13:

    for i=1 to n do

  • 14:

       Initialize local model Mi(0)

  • 15:

       for t=1 to T do

  • 16:

         Receive global model Mglobal(t)

  • 17:

         Train local model Mi(t)=Train(Mi(t1),Di) using KNN, LR, SVM, NB

  • 18:

         Transmit local model Mi(t) to Fog layer

  • 19:

       end for

  • 20:

    end for

  • 21:

    Final Aggregation:

  • 22:

    Finalize the global model Mglobal