NetSim Cognitive Radio library detects spectrum usage based on whether the primary user (incumbent) is inside / outside the keep out distance from the secondary user.
Please see the below link to understand how spectrum sensing is done.
The Keep-out distance used in NetSim is an abstract model for simulation purposes. A user can modify keep-out distance as per their sensing technique/algorithm. Since the keep-out distance is a user input, and hence the assumption is that the user has arrived at this value based on their sensing technique.
Now, if user wants to modify this at run time, then they can write a new sensing algorithm function and change keep-out distance used in below function.
struct stru_802_22_SSFOutput* fn_NetSim_CR_CPE_SSF(struct stru_802_22_SSFInput* input,NETSIM_ID nDevId,NETSIM_ID nInterfaceId)
This function is present in spectrummanager.c and it checks if the Incumbent signal is present or not.
Refer to http://tetcos.com/File_Exchange/Spectrum_usage_plots_in_802_22_CR_Networks_v_9_1.zip for plotting of spectrum usage.