cnet v4.0.4 | |
home topology files command‑line options the core API FAQ download and install |
Wireless LANs and mobile nodes
cnet supports mobile and wireless networking,
with functions supporting mobile nodes (of node type
Wireless links
All node types may have one or more wireless links,
and mobile nodes may only have wireless links.
Links of type A WLAN link may be in one of four states. In sleep state, a link cannot transmit nor receive signals, and consumes very little energy. From idle state, the link may be asked to temporarily enter transmit state to transmit a signal, and will temporarily enter receive state to receive each signal within range. Idle, transmit, and receive states all consume considerably more energy than the sleep state. The battery energy consumed by these four states depends on how long the link is in each state.
During simulations,
nodes may examine and modify the transmission and reception
characteristics of their wireless links by calling
All wireless power attributes are measured in decibel-milliwatts (dBm),
units that are related to milliWatts by the relationship
The only wireless link attribute that cannot be modified during a simulation is the link's frequency of transmission. As an example, we can change the transmission power of a wireless link with the function:
void set_TX_power(int link, double new_power)
{
WLANINFO wlaninfo;
CHECK( CNET_get_wlaninfo(link, &wlaninfo) );
printf("previous power value was %.2fdBm\n", wlaninfo.tx_power_dBm);
wlaninfo.tx_power_dBm = new_power;
CHECK( CNET_set_wlaninfo(link, &wlaninfo) );
}
Nodes may determine the signal strength and direction of signals arriving via
their wireless links.
The function
EVENT_HANDLER(wlan_ready)
{
char packet[1024];
size_t length = sizeof(packet);
int link;
double signalstrength, angle;
CHECK( CNET_read_physical(&link, packet, &length) );
CHECK( CNET_wlan_arrival(link, &signalstrength, &angle) );
if(angle > -M_PI_4 && angle < M_PI_4)
printf("a %.3fdBm signal has arrived from the east\n",
signalstrength):
}
The lifetime of a wireless signalIt is instructive to follow the lifetime of a wireless signalin cnet, to determine how it is transmitted, propagates, and is received. The following picture, reproduced with permission from Terabeam Wireless, explains the principle components in wireless transmission. Terabeam Wireless also provide a helpful signal loss calculator which may be used to support your cnet experiments. The typical sequence of execution of cnet wireless protocols is as follows:
The default characteristics of WLAN links
cnet models its
In combination, these default characteristics permit (theoretically, perfect)
transmissions to be heard (detected and decoded) up to 173 metres away,
and the wireless carrier to be sensed (just detected) 1096 metres away.
The functions
A transmitting node does not receive a copy of its own signal.
If a new signal arrives at a node already receiving another signal,
a collision results, and neither signal is fully received
(and no Defining your own WLAN propagation modelThe WLAN characteristics and the circular free-space-loss equation, described above, form cnet's default signal propagation model. More realistic simulations may wish to employ different models that define other signal propagation equations, introduce randomness into the propagation, or account for impenetrable obstacles on the simulation map (knowledge of such obstacles could also be "shared" when managing node mobilty).
cnet's
Consider this simple example - within 50 metres of a transmitter its signal is perfectly detected and decoded, between 50 metres and 100 metres the signal may be decoded with a decreasing likelihood, and beyond 100 metres the signal cannot be detected at all.
WLANRESULT simple_WLAN_model(WLANSIGNAL *sig)
{
double dx, dy, dz;
double metres;
// CALCULATE THE DISTANCE TO THE RECEIVER
dx = sig->tx_pos.x - sig->rx_pos.x;
dy = sig->tx_pos.y - sig->rx_pos.y;
dz = sig->tx_pos.z - sig->rx_pos.z;
metres = sqrt(dx*dx + dy*dy + dz*dz);
if(metres < 50)
return WLAN_RECEIVED;
if(metres < 100)
return ((rand()%50) >= (metres-50)) ?
WLAN_RECEIVED : WLAN_TOONOISY;
return WLAN_TOOWEAK;
}
Each time a wireless signal leaves its transmitting node,
the propagation model function is called with a pointer to a
The first 4 fields of the
The return type of the function is
If the result is other than The code for cnet's default (internal) function, based on the simple free-space-loss (FSL) model, appears below.
WLANRESULT fsl_WLAN_model(WLANSIGNAL *sig)
{
double dx, dy, dz;
double metres;
double TXtotal, FSL, budget;
// CALCULATE THE TOTAL OUTPUT POWER LEAVING TRANSMITTER
TXtotal = sig->tx_info->tx_power_dBm - sig->tx_info->tx_cable_loss_dBm +
sig->tx_info->tx_antenna_gain_dBi;
// CALCULATE THE DISTANCE TO THE RECEIVER
dx = sig->tx_pos.x - sig->rx_pos.x;
dy = sig->tx_pos.y - sig->rx_pos.y;
dz = sig->tx_pos.z - sig->rx_pos.z;
metres = sqrt(dx*dx + dy*dy + dz*dz);
// CALCULATE THE FREE-SPACE-LOSS OVER THIS DISTANCE
FSL = (92.467 + 20.0*log10(sig->tx_info->frequency_GHz)) +
20.0*log10(metres/1000.0);
// CALCULATE THE SIGNAL STRENGTH ARRIVING AT THE RECEIVER
sig->rx_strength_dBm = TXtotal - FSL +
sig->rx_info->rx_antenna_gain_dBi - sig->rx_info->rx_cable_loss_dBm;
// CAN THE RECEIVER DETECT THIS SIGNAL?
budget = sig->rx_strength_dBm - sig->rx_info->rx_sensitivity_dBm;
if(budget < 0.0)
return WLAN_TOOWEAK;
// CAN THE RECEIVER DECODE THIS SIGNAL?
return (budget < sig->rx_info->rx_signal_to_noise_dBm) ?
WLAN_TOONOISY : WLAN_RECEIVED;
}
(Messy details!)
Any user-defined propagation function is evaluated in the
context of the transmitting node.
The function needs to be very fast -
it will be called millions of times in a typical simulation.
The function should not modify any fields of Node mobility
cnet simulations run on a rectangular simulation map,
whose dimensions, in metres, may be specified by the
global attributes of
Mobile nodes may determine their own position,
and the dimensions of the simulation map,
by calling
There is no direct support in cnet for a node to undertake steady motion,
but if
EVENT_HANDLER(walk_diagonal)
{
CnetPosition now, max;
CHECK( CNET_get_position(&now, &max) );
if(now.x < max.x && now.y < max.y) {
++now.x;
++now.y;
CHECK( CNET_set_position(now) );
CNET_start_timer(ev, 1000000, data);
}
}
|