next up previous
Next: Run this program Up: Moving on Previous: The Ping program

Understanding the program : the OnRemote primitive

The OnRemote primitive is one of the two primitives provided in the language for specifying computation at a node across the network. It takes four arguments:

What
The first argument specifies what to execute at the remote node. It must be of the form of a function call. Note that the arguments to the function call will be evaluated on the machine invoking OnRemote, while the function will be evaluated on the remote machine.
Where
The second argument specifies where to execute the packet next at. Note that the packet will go through (possibly) many other active nodes in the process of getting to the specified host, but it will not be executed at any intermediate nodes.
How much
The third argument specifies how much of the current packet's resources to give to the outgoing packet.
How to
The fourth argument specifies which routing function to use to get to the remote host.

The other network primitive provided is OnNeighbor. It requires that the second argument be on the same (AN virtual) link-layer as the current host, and hence does not require the fourth argument.

The program consists of just one function definition. This function, called ``ping'', takes three arguments and returns a unit result. The first two arguments are of type host, and mean the source and destinationgif of the packet for a particular leg of its journey. The third argument is a boolean value which specifies whether the packet is outgoing or otherwise.

The body of the function is divided into three cases by the 'if .. then .. else' constructs.



next up previous
Next: Run this program Up: Moving on Previous: The Ping program



Michael Hicks
Mon Nov 24 10:50:43 EST 1997