## 3 CSCL-WVE-UDI: Method for Identifying Unknown IoT Devices
### Algorithm for Generating Permutation Positive-Negative Sample Pairs (PNSPs)
#### 3.4.3 CSCL-Siamese Network  
Combining Sections 3.4.1 and 3.4.3, we propose a Siamese network based on CSCL (CSCL-Siamese). The structure of the CSCL-Siamese network is illustrated in Figure 7. First, the Siamese network comprises two identical subnetworks that share weights. The structure of each subnetwork is shown in Figure 6. This network accepts two samples at once and generates two 256-dimensional embedding vectors for each sample. Next, it calculates the Manhattan distance between the embedding vectors and passes this distance value to the CSCL function to compute the loss. Finally, the calculated loss is backpropagated to perform gradient updates on the parameters of the Siamese network. Figure 7: Structure of the CSCL-Siamese network  
3.4.4. Embedding-Vector Database Generation Based on CSCL-Siamese Network  
A previous study [4] showed that the embedding vectors of unknown and known IoT devices differ significantly. To obtain the embedding vectors of all unknown IoT devices, one must construct an embedded vector database for known IoT devices in advance for filtering the embedding vectors of unknown devices. The main steps for generating the embedded vector database are as follows: First, the CSCL-Siamese network is trained using the set of PNSPs and the trained model is saved. At this stage, the CSCL-Siamese network can generate compact embedding vectors for similar IoT devices while dispersing those for dissimilar devices, thereby enabling the identification of known IoT devices. Subsequently, traffic data from known IoT devices are input into the saved CSCL-Siamese network to extract and store the embedding vectors for each device. Thus, when new traffic data arrive, the corresponding embedding vector can be extracted using the CSCL-Siamese network and compared against the embedded vector database using a similarity threshold. Thus, the embedding vectors that do not match the known IoT devices are filtered out promptly--they are the embedding vectors of unknown IoT devices. 3.4.5. EVDC-CSCL-Siamese Algorithm  
Based on the study above, we propose the EVDC-CSCL-Siamese algorithm. The pseudocode for the EVDC-CSCL-Siamese algorithm is described in Algorithm 4. The input comprises a set of PNSPs, i.e., \(Po\) and \(Ne\). Before training the CSCL-Siamese network, the positive-negative sample pairs are randomly segmented into a training set \(X_{tr}\leftarrow(Po_{tr};Ne_{tr})\), validation set \(X_{va}\leftarrow(Po_{va};Ne_{va})\), and test set \(X_{te}\leftarrow(Po_{te};Ne_{te})\) at a 6:2:2 ratio. The output includes the trained CSCL-Siamese network model \(M\), the identification results \(\hat{Y}\) for known IoT devices, and the embedded vector database \(ED\) for known IoT devices. ```
1:\(Po\leftarrow(po_{1},\ldots,po_{i},\ldots,po_{f});Ne\leftarrow(ne_{1},\ldots, ne_{i},\ldots,ne_{f})\) // Full permutation of positive and negative pairs of samples
2:\(M;\hat{Y};ED\)
3:Divide \((Po;Ne)\) into \(X_{tr};X_{va};X_{te}\)
4:Create \(CSCL-Siamese\leftarrow\) CNN + Flatten + BiLSTM + Flatten + Dense
5:\(n_{po}\leftarrow len(Po);n_{ne}\leftarrow len(Ne)\)
6:Use Equation (5) to calculate \(\lambda_{po}\) // Use of Equation (5)
7:Use Equation (6) to calculate \(\lambda_{ne}\) // Use of Equation (6)
8:Set model parameters Epoch, Batch Size, and learning rate, etc.