networking - NetSim - distance between the sensor nodes and the various agents? -
in netsim , code needs added print distance between various sensors , agents, beingness sensed sensors.
you can go source code (netsim_install_directory -> src -> simulation -> zigbee) , check file sensor.c, has asking for. code reproduced below -
_declspec(dllexport)int fn_netsim_zigbee_sensorevent(int nsensorloop,netsim_id nglobalpancoordinatorid,agent** pstruagent,sensors* pstru_sensor,metrics** pstrumetrics,netsim_eventdetails* pstrueventdetails,ieee802_15_4_primitives *pstruieee802_15_4_primitives) { ....... ..... pstrutemppos->dxpos = network->ppstrudevicelist[nsensorloop-1]->pstrudeviceposition->x; pstrutemppos->dypos = network->ppstrudevicelist[nsensorloop-1]->pstrudeviceposition->y; ddistance = fn_sensor_calculatedistance(pstrutemppos,pstrupos); .... .... } /** function used find distance between agent , sensor. */ double fn_sensor_calculatedistance(pos_2d* pstrupos1, pos_2d* pstrupos2) { double ddistance; if(pstrupos1 == null || pstrupos2 == null) homecoming 0; ddistance = (pstrupos1->dxpos - pstrupos2->dxpos)*(pstrupos1->dxpos - pstrupos2->dxpos); ddistance += (pstrupos1->dypos - pstrupos2->dypos)*(pstrupos1->dypos - pstrupos2->dypos); ddistance = sqrt(ddistance); homecoming ddistance; }
this section give distance between sensor , agent. can print file.
networking simulation
No comments:
Post a Comment