The ONL NPR Tutorial

NPR Tutorial >> Writing A Plugin TOC

New Window?

Basic Plugin Testing

Contents

Even though you may have successfully compiled your plugin, there still may be bugs in the code that will cause the plugin to misbehave. Typical signs that there is something wrong with your plugin include:

We gave an example of testing the mycount plugin in the page NPR Tutorial => Writing A Plugin => Quick Start. But that plugin was very simple and known to have no bugs. You are likely to encounter unexpected bugs when writing your first plugin that significantly departs from any working plugin.

 

A Development Strategy

You can not approach the writing, testing and debugging of a new plugin with a cavalier attitude. Such an approach will surely mean little progress even after spending many hours debugging. This situation is due to several factors:

These factors lead to the following approach to code development and testing:

 

A Testing Strategy

Our first objective should be to see if low-bandwidth traffic can flow through the plugin and the plugin continues to respond to control messages. Then, we can use incrementally more difficult tests as each step seems to succeed:

The test sequence will need to be modified if the plugin doesn't handle one or more of the protocols suggested in the test sequence.

The first four tests were demonstrated for the mycount plugin in the Quick Start page. The sections below expand on that mycount example. You can follow these steps using your own plugin.

Test 1 (Load)

Do the following:

If the RLI gives no indications of an error, the plugin likely loaded properly and it may have initialized properly. If you are worried about some variable initialization, you can use onl_api_debug_message() to output a message from within the plugin_init() routine or the plugin_init_user() routine.

Test 2 (Hello)

You can still send control messages to the plugin even if you have not created a filter to direct packets to the plugin. The mycount plugin should respond to three commands:

Successful return values from each of these commands indicates that the plugin executed its initialization properly, the hardware threads are context switching, and the handle_msg() routine is responding. This would be a good sign that something terrible has not happened yet.

Sometimes users have an explicit "hello" or "version" command where the plugin responds with a version number. This is also a good idea when you have a short debug cycle and you want to make sure that you are executing the correct version of the plugin. Although you should see a consistent view of your files on all machines, sometimes the Network File System (NFS) may be slow in updating the version of the plugin on the NPR control processor.

There are three possible bad outcomes:

Test 3 (A Few Pings)

Now, direct packets to the plugin with a filter, and see if you can send a few ping packets through the plugin (e.g., "ping -c 3 n2p3"). Then, follow up with some control messages to see if the plugin is still responsive. If this test is successful, it indicates that the plugin can handle low-intensity traffic and works at some rudimentary level.

There are mainly four bad outcomes:

By default, the ping command will send a 64-byte ICMP Echo Request (56 bytes of payload, 8 bytes of header, 20 bytes of IP header) packets once per second. If you get the standard response, then ICMP request/reply packets made it from the sender to the destination and back. This alone doesn't mean that your plugin saw the ping packet, but following the steps above should. You can also use the control message command "g" (get counts) to query for the values of npkts, maxinq and ndrops.

Test 4 (Continuous Pings)

Now, send a continuous sequence of ping packets by omitting the "-c 3" flag. The plugin should be able to handle this traffic load even if you outputting debug messages. Then, repeat the verification steps in the previous test.

Test 5 (UDP/TCP Traffic)

Now, you are ready to send UDP packets but remember that you will lock up the plugin if you send more than a few packets per second and the plugin is sending debug messages. So, you may want to send the UDP packets at a low rate. For example, the iperf command:

    iperf -c n2p3 -u -b 12k
will send UDP packets to n2p3 at 12 Kbps or about one 1470-byte packet every second. You might be able to send at 80 times this if you only generate one debug message per data packet (a little less than 1 Mbps for maximum-sized packets). If this works, then turn off all debugging output from the plugin and try increasing the iperf sending rate. The page Handling Errors shows how to record some debug information while sending at high traffic rates.

Even if your plugin is for TCP packets, it might be worthwhile testing a version of the plugin with UDP traffic even if it means changing the plugin code. The difference between UDP and TCP traffic when using iperf is that the UDP traffic will be near constant rate but the TCP traffic will be bursty. In fact, during the slow start phase, there may be pairs of back-to-back packets spaced by approximately the transmission delay of a single packet. Furthermore, the average input rate may reach twice the bottleneck capacity. This bursty behavior will be more stressful than the one provided by UDP iperf traffic. One way to limit this burstiness is to set the bottleneck capacity to some low rate, but note that the smallest NPR port rate is 0.683 Mbps which translates to about 6 packets per second for maximum-sized packets.


 Revised:  Fri, Jan 30, 2009 

  
  

NPR Tutorial >> Writing A Plugin TOC