NalMultiplePacketTx Sample
You can find these sample files at Public Documents\IntervalZero\RTX64 SDK\4.5
.
Description
This sample program uses the NAL API to:
- initialize the application to use the NAL
- request use of the default or a specified receive queue or a specified transmit queue
- configure the queue
- allocate and free NAL frames
- transmit multiple Ethernet frames in a single transmit call
- receive Ethernet frames in a callback
- use packet timestamps returned in packet callbacks
Source Files
File | Description |
---|---|
NalMultiplePacketTx.h
|
Header file. |
NalMultiplePacketTx.c
|
Source file. |
NalMultiplePacketTx.rc
|
Resource file. |
NalMultiplePacketTx_VS<Visual Studio Version>.vcxproj
|
Project file for supported versions of Visual Studio. |
NalMultiplePacketTx_VS<Visual Studio Version>.vcxproj.filters
|
Project filters file for supported versions of Visual Studio.. |
NalMultiplePacketTx_VS<Visual Studio Version>.sln
|
Solution file for supported versions of Visual Studio. |
resource.h
|
Resource header file. |
readme.txt
|
Text file containing a description of the sample and a list of provided files. |
Building the Sample
This sample application requires a supported version of Visual Studio.
- Open the appropriate solution file for your version of Visual Studio.
- Set the configuration to RTSSDebug or RTSSRelease.
- Build the sample.
You should end up with an RTSS process called NalMultiplePacketTx.rtss
.
Running the Sample
Follow these steps to run the sample using the RtNalIGB driver to send 1000000 broadcast packets (100 packets per transmit call) of 0x1234 Ethernet type from transmit queue 0:
- Convert your NAL-supported device to RTX64. In this example, we will use a device supported by the RtNalIGB driver.
- In the RTX64 Control Panel, add at least one interface through the Manage interfaces page:
- Interface1
NOTE: Interface names cannot contain spaces.
- Start the NAL through the Control Panel.
- Run the sample with the flag to send packets:
RtssRun NalMultiplePacketTx.rtss Interface1 /transmit xx:xx:xx:xx:xx:xx
- Observe the output, which should be similar to what appears below:
NalMultiplePacketTx: Transmit Burst: 100 packets NalMultiplePacketTx: Link is UP NalMultiplePacketTx: Interface1 TxQ 0 Transmitted 100000 packets, sec 12, nsec 133017970 NalMultiplePacketTx: Interface1 TxQ 0 Transmitted 200000 packets, sec 13, nsec 363418098 NalMultiplePacketTx: Interface1 TxQ 0 Transmitted 300000 packets, sec 14, nsec 593818098 NalMultiplePacketTx: Interface1 TxQ 0 Transmitted 400000 packets, sec 15, nsec 824217986 NalMultiplePacketTx: Interface1 TxQ 0 Transmitted 500000 packets, sec 17, nsec 54617970 NalMultiplePacketTx: Interface1 TxQ 0 Transmitted 600000 packets, sec 18, nsec 285018098 NalMultiplePacketTx: Interface1 TxQ 0 Transmitted 700000 packets, sec 19, nsec 515417874 NalMultiplePacketTx: Interface1 TxQ 0 Transmitted 800000 packets, sec 20, nsec 745818050 NalMultiplePacketTx: Interface1 TxQ 0 Transmitted 900000 packets, sec 21, nsec 976218082 NalMultiplePacketTx: Interface1 TxQ 0 Transmitted 1000000 packets, sec 22, nsec 64308972 NalMultiplePacketTx: Interface1 TxQ 0 Statistics: Transmitted 1000000 packets
The printed timestamp is of the last transmitted packet when printed.
NOTE: The timestamps won’t appear if timestamping for the transmit complete callback is not supported by the device.
- Run the sample to receive 1000000 packets of 0x1234 Ethernet type on default receive queue:
RtssRun NalMultiplePacketTx.rtss Interface1 /receive
You will see the following output once your sample started:
NalMultiplePacketTx: Interface1: Acquired receive queue 0 NalMultiplePacketTx: Link is UP
Once another network device sends packets of Ethernet type 0x1234 to your device you should see output similar to the following:
NalMultiplePacketTx: Interface1 RxQ 0 Received 100000 packets, Length: 1514 Sec: 1334 nSec: 859625944 NalMultiplePacketTx: Interface1 RxQ 0 Received 200000 packets, Length: 1514 Sec: 1339 nSec: 4413504 NalMultiplePacketTx: Interface1 RxQ 0 Received 300000 packets, Length: 1514 Sec: 1343 nSec: 98515136 NalMultiplePacketTx: Interface1 RxQ 0 Received 400000 packets, Length: 1514 Sec: 1347 nSec: 193401136 NalMultiplePacketTx: Interface1 RxQ 0 Received 500000 packets, Length: 1514 Sec: 1351 nSec: 288001848 NalMultiplePacketTx: Interface1 RxQ 0 Received 600000 packets, Length: 1514 Sec: 1355 nSec: 384081912 NalMultiplePacketTx: Interface1 RxQ 0 Received 700000 packets, Length: 1514 Sec: 1359 nSec: 479278352 NalMultiplePacketTx: Interface1 RxQ 0 Received 800000 packets, Length: 1514 Sec: 1363 nSec: 575073104 NalMultiplePacketTx: Interface1 RxQ 0 Received 900000 packets, Length: 1514 Sec: 1367 nSec: 670148744 NalMultiplePacketTx: Interface1 RxQ 0 Received 1000000 packets, Length: 1514 Sec: 1371 nSec: 765655536 NalMultiplePacketTx: Interface1 RxQ 0 Statistics: Received 1000000 packets, Missed 0 packets
The printed timestamp is of the last transmitted packet when printed. Note that timestamps won’t appear if timestamping for the receive complete callback is not supported by the device.
- Once you stop receiving packets, you can stop the sample using RtssKill.
Options
/q queue_number
The queue number (0 to 7). Defaults: 0 for transmit, default queue for receive.
/type EtherType in hex
The Ethernet type value. Default is 1234.
/txlen transmit_packet_size
The transmit packet size. Default is 1514 (not counting Ethernet FCS).
/cnt packet_count
The number of packets to send or receive. Default is 1000000.
/burst burst_size
The number of packets to send in one transmit call. Default is 100.
/sleep interval_us
The amount of additional sleep between transmitted bursts in microseconds. Default is 0 (no sleep).
/report report_count
Prints a report on received or transmitted packets at an interval of report_count. Default is 100000.
/silent
Disables application printouts.
Usage
NalMultiplePacketTx interface_name /receive [options]
NOTE: /receive is not supported for the RtNalE1000 driver.
NalMultiplePacketTx interface_name /transmit dest_mac_address [options]
Examples
In the following examples, the Interface1
device name is used and the peer (destination) MAC address is xx:xx:xx:xx:xx:xx.
RtssRun NalMultiplePacketTx interface1 /receive
RtssRun NalMultiplePacketTx interface2 /transmit xx:xx:xx:xx:xx:xx
- To receive frames with Ethernet type 0x2001 on interface1, queue 2:
RtssRun NalMultiplePacketTx interface1 /receive /q 2 /type 2001
- To transmit frames with Ethernet type 0x2001 to the network device with MAC address xx:xx:xx:xx:xx:xx from interface2, queue 1:
RtssRun NalMultiplePacketTx interface2 /transmit xx:xx:xx:xx:xx:xx /q 1 /type 2001
- To transmit one broadcast packet per second and print report for each transmitted packet:
RtssRun NalMultiplePacketTx interface2 /transmit xx:xx:xx:xx:xx:xx /burst 1 /sleep 1000000 /report 1
- To print report for each received packet:
RtssRun NalMultiplePacketTx interface1 /receive /report 1
Remarks
The sample does not demonstrate the continuous use of the transmit DMA ring. Instead, it formats and sends the next packet burst when the previous has been transmitted.
For the Intel I210 or Intel I211 devices, which store only 10 bits of the seconds’ portion of the timestamp with the transmitted packet, the application runs a timer to read the device system time every 512 seconds to print the complete packet timestamp.
This sample is not supported for the following drivers:
- RtNalE1000
- RtNalRtl
- RtVirtualNic
Timestamps in receive packet callbacks are supported for following devices supported by the RtNalIGB driver:
- Intel® I350 Quad/Dual PCIe Copper Ethernet Controller
- Intel® I210 Flash-less Copper-only Ethernet Controller
- Intel® I210 T1 Copper-only Ethernet Controller
- Intel® I211-AT Ethernet Controller
- Intel® 82576 Gigabit ET Dual Port Server Adapter
- Intel® 82576 Gigabit Network Connection
- Intel® 82576 Gigabit ET2 Quad Port Server Adapter
- Intel® 82580 Quad Port 10/100/1000 Mb/s Ethernet Controller
- Intel® 82580 Quad port 10/100/1000 Mb/s Ethernet Controller - Fiber
- Intel® 82580 Quad port 10/100/1000 Mb/s Ethernet controller - 1000BASEKX/1000BASEBX Backplane
- Intel® 82580 Quad Port 10/100/1000 Mb/s Ethernet Controller - External SGMII PHY
- Intel® 82580 Dual port 10/100/1000 Mb/s Ethernet Controller - Copper
Timestamps in transmit complete callbacks are supported for following devices supported by the RtNalIGB driver:
- Intel® I210 Flash-less Copper-only Ethernet Controller
- Intel® I210 T1 Copper-only Ethernet Controller
- Intel® I211-AT Ethernet Controller
APIs Referenced
RTAPI
- RtCreateEvent
- RtSetEvent
- RtWaitForMultipleObjects
- RtCloseHandle
- RtCreateTimer
- RtSetTimerRelative
- RtCancelTimer
- RtPrintf
- Sleep
RTNal
- RtNalInit
- RtNalAllocateFrame
- RtNalFreeFrame
- RtNalGetNumberOfQueues
- RtNalAcquireQueue
- RtNalConfigureQueue
- RtNalGetReceivePacketCount
- RtNalReceiveWithCallback
- RtNalTransmitEx
- RtNalIsApplicationFrame
- RtNalIoctl
- RtNalReleaseQueue
- RtNalSetTransmitTimeStampType
- RtNalSetReceiveTimeStampType
- RtNalGetDeviceSystemTimer
- RtNalSetReceiveFilterEntryEthertype
C-Runtime API
- memcpy
- strcpy