Using U-Net/NT

Libunet

Libunet is one example for how to use U-Net. It provides a set of functions that initialize endpoints, send and receive packets. However, libunet is not the most efficient way to use U-Net, especially the send and receive functions.

Send

To send a packet, a U-Net application needs to do the following:

Initialize

Send

Send more ...

Cleanup

For initialization and clean up, libunet's functions are the most convenient:

For using the tx queue, a good place to look is test\loopback\loopback.c. UNET_TRAP() is basically a trigger for sending. One can push a few entries into the tx queue and then trigger the device for efficiency.

Receive

To receive a packet, an application needs to perform a similar initialization and cleanup afterwards as the send operation. Except it needs to poll the receive queue for incoming packets.

Initialize

Receive

Receive more ...

Cleanup

Again, please read loopback.c for exactly how to receive. Currently, the only way to determine if receive queue has data is by polling the queue. Completion notification is not yet supported and it will be supported in the next release.

Structure of Loopback

In this release, test\loopback\loopback.c can be used as an example of U-Net application. It basically has the following structure:

	// initialization
	A. Open a U-Net device.
	B. Create a U-Net endpoint.
	C. Activate a channel.

	loop {
		// Send
		D. push pointer to send buffer to the tx queue.
		E. Call UNET_TRAP() 
		F. Poll.
	}

	..... more sends

	// cleanup
	G. Deactivate the channel.
	H. Destroy the endpoint.
	I. Close the device.

I realize that this is a very rough draft on how to write U-Net applications. Best of Luck...


X. Huang, xwh@cs.cornell.edu