Skip to main content
. 2025 Aug 21;25(16):5188. doi: 10.3390/s25165188
Algorithm 3 Local model training at fog layer
  • Require:

  •   1: Set of controllers C={C1,C2,,Cn}

  •   2: Time step t, Learning rate μ, Batch size B, Regularization parameter λ

  •   3: Dataset Dctrlt={d1t,d2t,,dnt} from east–west traffic telemetry

  •   4: Initial local malicious detection models:

  •   5: CNN-based model TCNN,it, SVM-based model TSVM,it, General local model Tit

  •   6: Controller private keys κprivi and public keys κpubi

  • Ensure:

  •   7: Updated and signed local models Tit+1 with digital signatures Σi

  •   8: Prepared model updates for secure transmission to the blockchain layer

  •   9: for each controller node CiC do

  •   10:     Step 1: Data Collection

  •   11:     Load local traffic data Dctrlt from east–west interface flows

  •   12:     Extract feature vectors dktDctrlt

  •   13:     Step 2: Local Model Initialization

  •   14:     Retrieve previous local models Tit,TCNN,it,TSVM,it

  •   15:     Step 3: Gradient Computation for General Model

  •   16:     Compute gradient of loss: L(Tit,Dctrlt)

  •   17:     Step 4: General Model Update

  •   18:     Update local model weights:

  •   19:                Tit+1Titμ·L(Tit,Dctrlt)

  •   20:     Step 5: CNN Model Training

  •   21:     For each batch j=1B do

  •   22:                Extract batch samples (xj,yj)

  •   23:                Compute CNN gradient:

  •   24:                     LCNN(fθ(xj),yj)

  •   25:     end for

  •   26:     Update CNN model:

  •   27:                TCNN,it+1TCNN,itμ·1Bj=1BLCNN(fθ(xj),yj)

  •   28:     Step 6: SVM Model Training with Hinge Loss

  •   29:     For each sample (xj,yj)Dctrlt do

  •   30:                Compute indicator function:

  •   31:                     I(yj·TSVM,it,xj<1)

  •   32:                Calculate SVM gradient component:

  •   33:                     gj=λ·TSVM,ityjxj·I()

  •   34:     end for

  •   35:     Aggregate gradient over dataset and update:

  •   36:                TSVM,it+1TSVM,itμ·jgj

  •   37:     Step 7: Digital Signature Creation

  •   38:     Sign updated model using private key:

  •   39:                ΣiSign(Tit+1,κprivi)

  •   40:     Step 8: Secure Transmission

  •   41:     Transmit (Tit+1,Σi) to blockchain layer

  •   42:     Step 9: Signature Verification

  •   43:     Verify signature with public key:

  •   44:                Validate(Σi,κpubi)

  •   45:     if validation accepted then

  •   46:         Accept model update for global aggregation

  •   47:     else

  •   48:         Reject update, log security alert

  •   49:     end if

  •   50: end for