home
topology files
command‑line options
the core API
FAQ
download and install
|
cnet's core Application Programming Interface
Descriptions of cnet's core functions are available from here.
In each section functions are presented as C prototypes,
often with an example of their use.
cnet re-implements the standard C99 library functions
printf ,
puts ,
putchar ,
srand , and
rand
so that each node may call these independently of all other nodes.
Most core functions return the integer 0 on success
and the integer -1 on failure.
The most recent error status is reflected in
the global variable cnet_errno .
All values of cnet_errno will be instances of the
enumerated type CnetError .
Functions do not set the value of cnet_errno to
ER_OK if their execution was successful.
Note that these functions' names are prefixed with CNET_ .
Errors may be reported to stderr with
CNET_perror() and their error message string accessed from
cnet_errstr[(int)cnet_errno] .
Application Layer functions
Physical Layer functions
WLAN and mobile node functions
Event handling functions
Checksum and CRC functions
Timer functions
Tracing functions
Node and per-link statistics
Miscellaneous functions
API restrictions
- Calls to the functions:
CNET_write_application
CNET_read_application
CNET_enable_application
CNET_disable_application
CNET_set_handler(EV_APPLICATIONLAYER,...) and
CNET_set_handler(EV_KEYBOARDREADY,...)
are only valid if called from a node of type
NT_HOST or
NT_MOBILE .
-
Function calls to either the Application or Physical Layers are invalid
when cnet is not running.
This can occur when the node is rebooting,
when the simulation is running under a windowing system,
is paused,
and a node's debug button is selected.
- Calls to the function:
CNET_set_position
are only valid if called from a node of node type
NT_MOBILE .
- Calls to the functions:
CNET_get_wlaninfo
CNET_set_wlaninfo
CNET_wlan_arrival
are only valid for links of type LT_WLAN .
-
Calls to the functions:
CNET_set_nicaddr
are only valid for links of type
LT_LAN or
LT_WLAN .
Furthermore, you
cannot set the attributes of link 0 , the LOOPBACK link,
nor set a NIC address to either the zero address, 00:00:00:00:00:00 ,
or the broadcast address, ff:ff:ff:ff:ff:ff .
|