| home
topology files
command‑line options
the core API
FAQ
download and install | cnet's Application Programming Interface
NAMECNET_write_physical, CNET_write_physical_reliable - write data frames
to the Physical Layer
SYNOPSIS
#include <cnet.h>
int CNET_write_physical(int link, const void *frame, size_t *length);
int CNET_write_physical_reliable(int link, const void *frame, size_t *length);
 
DESCRIPTION
CNET_write_physicalrequests that the indicated number of bytes,
pointed to byframe,
be written "down to" the Physical Layer.
If accepted, the Physical Layer will attempt to transmit the data frame
on the indicatedlink,
which can be of typeLT_LOOPBACK,LT_WAN,LT_LAN, orLT_WLAN.
Depending on the characteristics of the link,
the data frame may be subject to corruption, loss, or collisions.
Each node has a fixed number of links,
the first available physical link is number 1,
the second is number2, and so on.
As a special case,
a node may reliably transmit a frame to itself by requesting
theLOOPBACK(=0)link. 
On invocation, lengthmust point to an integer indicating the number
of bytes to be copied fromframe.
On return, the integer pointed to bylengthwill now contain
the number of bytes accepted by the Physical Layer. 
CNET_write_physical_reliableperforms identically toCNET_write_physicalexcept that the written data frame will not suffer any
corruption, loss, or collisions in the Physical Layer.
In addition,CNET_write_physical_reliablepermits new frames to be
written to a link while the previous one is still being transmitted.RETURN VALUE
The value 0is returned on success.
On failure, the value-1is returned,
and the global variablecnet_errnois set to one of the
following values to describe the error:
 
ER_BADARGEither frameis aNULLpointer,
    orlengthis equal to zero.ER_BADLINKThe value of linkis less than zero, or greater than the
    number of physical links of the current node.ER_BADSIZEThe value of lengthexceeds the capacity of the Physical
    Layer link being written to.ER_LINKDOWNThe link being written to is currently down.
    ER_NOBATTERYThe current mobile node's battery is exhausted.
    ER_NOTREADYThe current node has not yet finished rebooting,
    the indicated WLAN link is in sleep mode,
    or the link has not yet completed transmitting the previous frame.
    ER_TOOBUSY
    The link has not yet completed transmitting the previous frame,
    or an attempt has been made to write more than 1000 frames to the
    indicated link before any of them have been read by the receiving node
    (this restriction is imposed to trap obvious errors in protocols).
    SEE ALSO
CNET_write_direct and
CNET_read_physical
 |