The Cluster Head (CH) configuration is similar to what was made for the Access Point. The CH however, can execute data sensing and processing so its configuration is a bit more complex (as the sensor nodes executes more different tasks more configuration adjustments should be made).
To create a sensor node just put in the tradicional node-config structure the -sensorNode ON command. Just like it was made in the AP configuration.
Continuing CH configuration, the user should set a node field to represent the sensor node just defined, create a tansport protocol (again an UDP transport protocol is used in the example presented in the box bellow), a sensor node application (as expected a ClusterHeadApp) and an instance of a processing module.
set node_($counter) [$ns_ node] set udp_($counter) [new Agent/UDP] set app_($counter) [new Application/SensorBaseApp/ClusterHeadApp] set processing_($counter) [new Processing/AggregateProcessing]
If the CH is supposed to sense data a CommonNodeApp aplication should also be attached to the cluster head node. See Common Node Configuration for details.
Cluster head application adjustments includes, besides transport protocol settings, sent messages destination address, dissemination interval and type (PERIODIC - 0, CONTINUOUS - 1, ON_DEMAND - 2 and EVENT_DRIVEN - 3). The wireless sensor node object, the transport protocol and the processing module just created are attached to the application also.
$app_($counter) node $node_($counter); $app_($counter) set destination_id_ 0; $app_($counter) set dissemination_type 0; $app_($counter) set dissemination_interval 30.0; $app_($counter) attach-agent $udp_($counter) $app_($counter) attach-processing $processing_($counter)
Concerning sensor node configuration the user should set itīs position, motion type (in the box example 0 means a static node), energy spent in processing tasks and nodeīs processor instruction per second rate. Cluster head application and transport protocol should be attached to sensor node. IMPORTANT: the transport protocol port should be the same used in all network elements.
$node_($counter) random-motion 0 $node_($counter) set X_ 5.0 $node_($counter) set Y_ 5.0 $node_($counter) set Z_ 0.0 $node_($counter) add-app $app_($counter) $node_($counter) attach $udp_($counter) $val(port) Node/MobileNode/SensorNode set processingPower_ 0.024 Node/MobileNode/SensorNode set instructionsPerSecond_ 8000000
To complete nodes configuration attach sensor node to processing module and shedules application start and stop time.
$processing_($counter) node $node_($counter) $ns_ at 1.0 "$app_($counter) start" $ns_ at 1200.0 "$app_($counter) stop"