To create an access point (AP) the first thing it to set node-config structure. This is a ns-2 structure used to define a bunch of mobile node parameters. In Mannasim context the only difference from the tradicional settings is the inclusion of -sensorNode ON command. With this command whenever an instance of a mobile node is instantiated a wireless sensor node is automatically created. The box bellow shows a sample configuration (note the use of val() vector).
$ns_ node-config -sensorNode ON -adhocRouting $val(rp) -adhocRouting $val(rp) -llType $val(ll) -macType $val(mac) -ifqType $val(ifq) -ifqLen $val(ifqlen) -antType $val(ant) -propType $val(prop) -energyModel $val(en)
Next thing to be done is to set sensor node functionalitys like for example, a transporte protocol, a data generator, a processing module and an application running within the sensor node. All these functionalities have have configuration parameteres of there own that will be explained shortly.
Since an AP doesn´t execute any sensing, processing and disseminating task it has the simplest sensor node configuration. The user should set a node field to represent the sensor node just defined, create a transport protocol (UDP transport protocol is used in the example presented in the box bellow) and an application, in this case an AccessPointApp.
set node_($counter) [$ns_ node] set udp_($counter) [new Agent/UDP] set app_($counter) [new Application/SensorBaseApp/AccessPointApp]
The transporte protocol should be attached to the application and applications sent message destination address must be set. This value can be a BROADCAST address to send requests to the network or the address of an outsider node (optional).
$app_($counter) set destination_id_ 0; $app_($counter) attach-agent $udp_($counter)
Configuring teh sensor node requires the adjustment of nodes position, motion characteristics (in the box example, 0 means that the sensor node is static) and the transport protocol. IMPORTANT: when attaching the transport protocol to an AP node the port value used must be the same of all network elements (common nodes, cluster heads, etc).
$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) attach $udp_($counter) $val(port)
To finish the AP stop time should be sheduled in the simulation object.
$ns_ at 1200.0 "$app_($counter) stop"
On demand networks require that the AP or other outsider send requests messages to the WSN. These messages specifies the situation when the network should provide data to the requester.
To create a request message to be send by the AP the following parameters should be set:
The sample code provided bellow defines the request time, schedules when data structure that encapulates request data is created and when request message will be sent.
$app_($counter) set request_type_ 25 0 $ns_ at 120.0 "$app_($counter) add_temp_data_param 25 0" $ns_ at 120.5 "$app_ send_request"