Applies to: NetSim Standard/Pro v15.0.21
This example adapts NetSim MATLAB dynamic clustering from a Wireless Sensor Network (WSN) to an Underwater Acoustic Network (UWAN). It sends node positions and residual energy to MATLAB, forms clusters using K-means or Fuzzy C-Means (FCM), elects cluster heads, and returns the result to modified DSR routing code.
Workspace: https://github.com/NetSim-TETCOS/Dynamic_Clustering_UWAN_DSR_v15.0/archive/refs/heads/main.zip
The download should contain the modified workspace containing source code, binaries, MATLAB files, example experiments, along with a modified Underwater_device.xml file.
| Item | Meaning |
|---|---|
Xc, Yc | UWAN node coordinates. |
Pwr | Residual energy from the ALOHA PHY interface. |
A | Elected cluster-head device IDs. |
B | Cluster ID assigned to each node. |
C | Number of nodes in each cluster. |
C:\Program Files\NetSim\Standard_v15_0\Docs\UI_xml\Device_Properties\Underwater_device.xmlUnderwater_device.xml.The modified XML exposes the routing-protocol property needed by the UWAN devices.
Dynamic_Clustering_Matlab_v15.0_UWAN.netsimexp.| Experiment | Traffic | Timing | Purpose |
|---|---|---|---|
UWAN-Dynamic-Clustering-3-Flows | 16 nodes; three CBR flows | 5-second clustering; 100-second simulation | Short interface, routing, metrics, and log check. |
UWAN-Dynamic-Clustering-16-Flows | 16 ring flows; every node sends and receives | 300-second simulation | Traffic-coverage check across all nodes. |
In bin_x64\MATLAB\clustering.m, set Clustering_Method:
| Value | Method | Inputs used |
|---|---|---|
| 1 | K-means | Distance |
| 2 | Fuzzy C-Means | Distance |
| 3 | K-means | Distance and energy |
| 4 | Fuzzy C-Means | Distance and energy |
Clustering_Method = 1;The supplied C source sets four clusters:
#define NUMBEROFCLUSTERS 4The interval is set in DSR.h:
#define CLUSTER_INTERVAL 5*SECONDRebuild DSR and use the resulting workspace libDSR.dll after changing C source or header values.
clustering.m.Cluster_log.csv in the simulation log folder.A valid log contains one row per cluster at each clustering time:
Time (in us),CLUSTER ID,CLUSTER HEAD,Cluster Members
0,1,14,13,14,15
0,2,10,5,9,10,11
5000000,1,16,11,12,15,16
5000000,2,3,1,2,3,4Annotation: The change between 0 and 5,000,000 microseconds shows a new result after five seconds. A populated cluster log confirms clustering exchange; verify packet delivery separately.