Statistics
| Branch: | Tag: | Revision:

root / host / docs / transport.rst @ 1df3e9b1

History | View | Annotate | Download (6.67 KB)

1
========================================================================
2
UHD - Transport Application Notes
3
========================================================================
4

    
5
.. contents:: Table of Contents
6

    
7
------------------------------------------------------------------------
8
Introduction
9
------------------------------------------------------------------------
10
A transport is the layer between the packet interface and a device IO interface.
11
The advanced user can pass optional parameters
12
into the underlying transport layer through the device address.
13
These optional parameters control how the transport object allocates memory,
14
resizes kernel buffers, spawns threads, etc.
15
When not spcified, the transport layer will use values for these parameters
16
that are known to perform well on a variety of systems.
17
The transport parameters are defined below for the various transports in the UHD:
18

    
19
------------------------------------------------------------------------
20
UDP transport (sockets)
21
------------------------------------------------------------------------
22
The UDP transport is implemented with user-space sockets.
23
This means standard Berkeley sockets API using send()/recv().
24

    
25
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
26
Transport parameters
27
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
28
The following parameters can be used to alter the transport's default behavior:
29

    
30
* **recv_frame_size:** The size of a single receive buffer in bytes
31
* **num_recv_frames:** The number of receive buffers to allocate
32
* **send_frame_size:** The size of a single send buffer in bytes
33
* **num_send_frames:** The number of send buffers to allocate
34

    
35
**Note1:**
36
num_recv_frames does not affect performance (all platforms).
37

    
38
**Note2:**
39
num_send_frames does not affect performance (UNIX only).
40

    
41
**Note3:**
42
recv_frame_size and send_frame_size can be used to
43
increase or decrease the maximum number of samples per packet.
44
The frame sizes default to an MTU of 1472 bytes per IP/UDP packet,
45
and may be increased if permitted by your network hardware.
46

    
47
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
48
Flow control parameters
49
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
50
The host-based flow control expects periodic update packets from the device.
51
These update packets inform the host of the last packet consumed by the device,
52
which allows the host to determine throttling conditions for the transmission of packets.
53
The following mechanisms affect the transmission of periodic update packets:
54

    
55
* **ups_per_fifo:** The number of update packets for each FIFO's worth of bytes sent into the device
56
* **ups_per_sec:** The number of update packets per second (defaults to 20 updates per second)
57

    
58
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
59
Resize socket buffers
60
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
61
It may be useful increase the size of the socket buffers to
62
move the burden of buffering samples into the kernel, or to
63
buffer incoming samples faster than they can be processed.
64
However, if your application cannot process samples fast enough,
65
no amount of buffering can save you.
66
The following parameters can be used to alter socket's buffer sizes:
67

    
68
* **recv_buff_size:** The desired size of the receive buffer in bytes
69
* **send_buff_size:** The desired size of the send buffer in bytes
70

    
71
**Note:** Large send buffers tend to decrease transmit performance.
72

    
73
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
74
Latency Optimization
75
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
76
Latency is a measurement of the time it takes a sample to travel between the host and device.
77
Most computer hardware and software is bandwidth optimized which may negatively affect latency.
78
If your application has strict latency requirements, please consider the following notes:
79

    
80
**Note1:**
81
The time taken by the device to populate a packet is proportional to the sample rate.
82
Therefore, to improve receive latency, configure the transport for a smaller frame size.
83

    
84
**Note2:**
85
For overall latency improvements,
86
look for "Interrupt Coalescing" settings for your OS and ethernet chipset.
87
It seems the Intel ethernet chipsets offer fine-grained control in Linux.
88
Also, consult:
89

    
90
* http://publib.boulder.ibm.com/infocenter/pseries/v5r3/index.jsp?topic=/com.ibm.aix.prftungd/doc/prftungd/interrupt_coal.htm
91

    
92
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
93
Linux specific notes
94
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
95
On linux, the maximum buffer sizes are capped by the sysctl values
96
**net.core.rmem_max** and **net.core.wmem_max**.
97
To change the maximum values, run the following commands:
98
::
99

    
100
    sudo sysctl -w net.core.rmem_max=<new value>
101
    sudo sysctl -w net.core.wmem_max=<new value>
102

    
103
Set the values permanently by editing */etc/sysctl.conf*
104

    
105
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
106
Windows specific notes
107
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
108
On Windows, it is important to change the default UDP behavior such that
109
1500 byte packets still travel through the fast path of the sockets stack.
110
FastSendDatagramThreshold registry key to change documented here:
111

    
112
* http://www.microsoft.com/windows/windowsmedia/howto/articles/optimize_web.aspx#appendix_e
113

    
114
------------------------------------------------------------------------
115
USB transport (libusb)
116
------------------------------------------------------------------------
117
The USB transport is implemented with libusb.
118
Libusb provides an asynchronous API for USB bulk transfers.
119

    
120
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
121
Transport parameters
122
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
123
The following parameters can be used to alter the transport's default behavior:
124

    
125
* **recv_frame_size:** The size of a single receive transfers in bytes
126
* **num_recv_frames:** The number of simultaneous receive transfers
127
* **send_frame_size:** The size of a single send transfers in bytes
128
* **num_send_frames:** The number of simultaneous send transfers
129

    
130
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
131
Setup Udev for USB (Linux)
132
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
133
On Linux, Udev handles USB plug and unplug events.
134
The following commands install a Udev rule
135
so that non-root users may access the device:
136

    
137
::
138

    
139
    cd <install-path>
140
    sudo cp uhd-usrp.rules /etc/udev/rules.d/
141
    sudo udevadm control --reload-rules
142

    
143
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
144
Install USB driver (Windows)
145
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
146
A driver package must be installed to use a USB-based product with UHD:
147

    
148
* Download the driver from the UHD wiki page.
149
* Unzip the file into a known location. We will refer to this as the <directory>.
150
* Open the device manager and plug-in the USRP. You will see an unrecognized USB device in the device manager.
151
* Right click on the unrecognized USB device and select update/install driver software (may vary for your OS).
152
* In the driver installation wizard, select "browse for driver", browse to the <directory>, and select the .inf file.
153
* Continue through the installation wizard until the driver is installed.