In USB network mode the radio is a USB network adapter for the computer. It routes IPv4 packets to other radios over
DMR packet data. It serves a status page, rig control, KISS, TFTP and SNMP to the computer. It is in the images for
radios with USB. IP over DMR to another radio is host-tested only. Which services have been checked on each radio is
in the Radio reference. A build made without it (CONFIG_DMR_IP_GATEWAY=n) says "USB network: not in
this build" in Tools > USB network.
The radio starts as a USB serial port unless USB network at start is on (below). To switch it, open Tools > USB network (OK, 6, 4). The page says which mode USB is in and what changes. Focus "Switch USB to network" and press OK. The radio says "USB is a network adapter now" and returns to Home, where the status line shows IP. An up and a down arrow appear beside it once the computer has set the adapter up and IP can flow. While USB is a network adapter, qdmr, hotspot hosts and the debug link over serial don't reach the radio.
To get back to serial, open Tools > USB network again and choose "Switch USB to serial" ("USB is a serial port again"), or restart the radio. The Tools row shows the current mode (serial or network).
Developers can also switch over the debug link:
tools/rfoundry_debug.py radio usb network
The radio drops off USB for a moment and comes back as a network adapter (USB ID 1FC9:0096). Linux, macOS, Windows 10 and 11 use their built-in drivers. If the computer doesn't set the adapter up within 10 s, the radio goes back to serial.
Settings > Connections > USB network at start makes the radio start as a network adapter. If the computer doesn't set the adapter up within 10 s of plugging in, the radio becomes a serial port again until it is restarted. This way you can always reach it to turn the setting off. The radio waits for a computer. A radio switched on away from a computer is still a network adapter when you plug it in later.
The computer gets its address from the radio by DHCP:
| Who | Address |
|---|---|
| The radio | 12.x.y.z, from your DMR ID (for example ID 9991234 is 12.152.116.66) |
| Your computer | 13.x.y.z, from the same DMR ID (13.152.116.66) |
| Another radio | 12.x.y.z from its DMR ID |
| A computer on another radio | 13.x.y.z from that radio's DMR ID |
| A talkgroup | 225.x.y.z from the talkgroup number |
Packets to another radio's or a talkgroup's address go out over the air on the current DMR channel. Packets from other radios arrive on the network adapter. DMR packet data is much slower than any wired network. A packet that can't go out within 2 s is dropped. Every address in 12.x.y.z other than your radio's own is another radio, so a packet to 12.152.116.67 goes over the air. The fixed addresses of control station mode replace the first two rows.
The debug link, the MMDVM hotspot protocol and the CPS protocol stay reachable over UDP port 3334 at the radio's address:
tools/rfoundry_debug.py --port udp:12.152.116.66 version
MMDVMHost connects the same way (Protocol=udp, ModemAddress=<radio address>, ModemPort=3334). qdmr finds radios
only by their serial USB ID, so program the radio in serial mode.
The project's own tools need no address and no change on the radio:
| Tool | In network mode |
|---|---|
tools/rfoundry_debug.py, tools/cps_client.py, rfoundry.py |
With no --port and no serial radio plugged in, they find the radio on the network link and use it |
stub/stubtool.py --rfoundry-enter --write-app ... (no port) |
Updates the firmware and restarts the radio, which comes back in network mode |
| The web installer and the codeplug editor | They ask the radio to become a serial port for the job. Some browsers do it unseen. Otherwise press Switch the radio to USB serial: a tab opens on the radio's own page (http://12.255.255.254/, every radio's address on its own USB link) and closes again. Then connect. The radio returns to network mode when it restarts |
If the button can't reach the radio (the tab shows an error: the computer hasn't set the adapter up, or sends 12.x addresses elsewhere), switch on the radio: Tools > USB network.
The radio answers Multicast DNS (Bonjour, Avahi) on the network adapter. Its name is rfoundry-<DMR ID>.local, for
example rfoundry-9991234.local. It advertises its services. A browser for Bonjour services lists it by your call sign,
the radio model and your DMR ID, for example "Q0TST XR-100UV (9991234)":
ping rfoundry-9991234.local
dns-sd -B _rfoundry-debug._udp # macOS; avahi-browse -r _rfoundry-debug._udp on Linux
tools/rfoundry_debug.py --port udp:rfoundry-9991234.local version
| Service | Port | What |
|---|---|---|
_rfoundry-debug._udp |
3334 | the debug link (and the other serial protocols) over UDP |
_mmdvm._udp |
3334 | the MMDVM modem, for MMDVMHost |
_tftp._udp |
69 | the codeplug over TFTP (below) |
_snmp._udp |
161 | the SNMP agent (below) |
_http._tcp |
80 | the status page |
_kiss-tnc._tcp |
8001 | KISS over TCP |
_rigctld._tcp |
4532 | Hamlib rig control |
Each one carries the board, the DMR ID, the call sign and the firmware version in its TXT record.
The radio answers at its own address on these TCP ports, over the USB cable only, never over the air.
| Port | Service |
|---|---|
| 80 | The radio's front panel. Open http://<radio address>/ in a browser. It shows the radio with its live screen and LEDs, and the channel, frequency, signal and battery. On a mobile radio its hand microphone is drawn too. Click a key or use the keyboard. Side and top keys also have a labeled button outside the radio's edge, and the arrows over the channel knob turn it one step per click (hold to keep turning). Keyboard keys: digits, * and #; the arrows; Enter for select (green key or MENU); Esc or Backspace for back (red key or BACK); [ and ] (or Page Up and Page Down) turn the channel knob; hold Space to talk. The page lists the keyboard keys your radio has beside the picture. Listen plays what the radio receives (on radios with network audio, Linking audio); over the programming cable (PPP, below) the page has no Listen, since the cable is too slow for audio. Keys work only from the computer the radio is plugged into; one page at a time controls the radio, and others show the status only. Programs can read /status (JSON) and the debug link's sections at /api/view?section=core. Open the page at the radio's address or its .local name: at a name of your own (a hosts file entry) the page loads but gets no data. Besides the radio's own page, only pages on radiofoundry.org and pages served on your own computer (localhost) can use the radio from a browser |
| 8001 | KISS over TCP for APRS programs (APRSdroid, Xastir, YAAC). Set the program's TNC to "KISS over TCP", the radio's address, port 8001. Turn on KISS on USB in Tools > APRS first. The radio sends only packets from your own callsign, and takes them only from your computer. On a radio that can't receive APRS (Radio reference), programs see only what they send |
| 4532 | Hamlib rig control for loggers, SDR and satellite programs. Choose "Hamlib NET rigctl" with the radio's address and port 4532, or run rigctl -m 2 -r <radio address>:4532 f. Programs can read and set the frequency, read the mode and the S meter, and key the transmitter. Setting the frequency of a channel switches to the VFO. Transmit works only from your computer, at most 3 minutes per keying |
The radio can connect to an APRS-IS server itself and send your position there. Your computer must pass the radio's traffic on to the Internet:
# macOS (en0: your Internet connection)
sudo sysctl -w net.inet.ip.forwarding=1
echo "nat on en0 from 12.152.116.66 to any -> (en0)" | sudo pfctl -ef -
# Linux (eth0: your Internet connection, usb0: the radio)
sudo sysctl -w net.ipv4.ip_forward=1
sudo iptables -t nat -A POSTROUTING -s 12.152.116.66/32 -o eth0 -j MASQUERADE
sudo iptables -A FORWARD -i usb0 -o eth0 -j ACCEPT
sudo iptables -A FORWARD -i eth0 -o usb0 -m state --state RELATED,ESTABLISHED -j ACCEPT
Use your radio's address instead of 12.152.116.66. Then give the radio a server's IP address. The radio can't look up
names. dig +short rotate.aprs2.net gives some addresses. You can also give a range in km for the messages and packets it
receives:
curl "http://12.152.116.66/api/aprsis?server=44.31.12.34:14580&range=50"
curl "http://12.152.116.66/api/aprsis" # the state
curl "http://12.152.116.66/api/aprsis?server=off" # stop
The radio logs in with its APRS callsign and the passcode computed from it. Your beacons go to APRS-IS when KISS on
USB and "to APRS-IS" are on (tools/rfoundry_debug.py aprs set to_is 1).
A program on your computer or a page in its browser, such as takRF, can choose the radio's zone and channel as a
knob would. It opens the connection the radio's web page uses, ws://<radio address>/ws (a WebSocket), and sends
short text messages on it. Zones and channels are counted from 0, in the order the radio shows them.
| Message | Does |
|---|---|
select?zone=2&pos=5 |
The third zone, its sixth channel (without pos, its first) |
step?channel=1 |
One channel on; -1 one back; it wraps at the zone's ends. From the VFO, the first step goes back to the channel you came from |
step?zone=1 |
One zone on, to its first channel; -1 one back; it wraps from the last zone to the first and back |
status?changes |
Send the status only when the zone or channel changes, not every second; status goes back to every change |
The radio sends its status on the same connection: zone, position, zone name, channel, frequency, and on DMR the
color code, timeslot and talkgroup. codeplug in it goes up whenever the channels or zones change (on the radio, or a
codeplug written to it). The radio answers a message only when it refuses it, with {"err":...}.
Zones and channels change only from the computer the radio is plugged into, and not while the radio transmits or is a
hotspot. The radio takes one such connection at a time: while a program has it, the radio's web page shows the status
only. tools/rfoundry_ws.py --radio <radio address> "select?zone=1" tries it from a terminal. Details:
tcp-services.md 5.1 and 8.
On a radio with a GPS, a program on the computer the radio is plugged into can have its position once a second, with
altitude, speed, course, satellites and the time: it sends gps over the web page's connection (gps?off stops it).
tools/rfoundry_gps.py does this for you. It prints the positions, or turns them into NMEA sentences for gpsd or a
mapping program:
python3 tools/rfoundry_gps.py # the positions, one line each
python3 tools/rfoundry_gps.py --nmea-udp 127.0.0.1:4349 # NMEA for gpsd: gpsd -N udp://127.0.0.1:4349
While the tool runs, takRF can't connect and the radio's web page shows the status only. The position is the radio's own GPS, never one your computer or phone gave the radio, and it is exact, whatever the position ambiguity setting. Nothing comes while Settings > Location > GPS is off or without a fix.
tools/ws_rig_control.html is a demo of all of the above in one web page: the status, zone and channel stepping and
selecting, the GPS position, the radio's screen, receive audio, its keys and PTT, and a box to send any message. It
is also a working example for writing your own program.
Serve it from a web server on the computer the radio is plugged into. Double-clicking the file does not work: the radio refuses a page opened from disk. Python's built-in server is enough:
cd tools
python3 -m http.server 8000
Then open http://localhost:8000/ws_rig_control.html, enter the radio's address and press Connect. Close the
radio's own web page and takRF first: the radio takes one connection at a time.
Warning: send only to the radio's own address. The radio passes messages for other addresses in its range to the air as DMR data, so a message to another address makes the radio transmit. Messages to the radio's own address never go on the air: to a port the radio doesn't serve, your program gets a "port unreachable" error back. Whenever the radio is in network mode, keep an antenna or a dummy load on the radio and leave the radio on a channel you may transmit on.
The radio speaks the USRP voice protocol on UDP port 34001, the protocol AllStarLink's USRP channel driver and DVSwitch Analog_Bridge use. A node on your computer hears what the radio receives and talks through it, as an RF link:
- AllStarLink:
rxchannel = usrp/<radio address>:34001:32001in the node'srpt.confsection. - Analog_Bridge:
txPort = 34001,rxPort = 32001, the radio's address as the destination.
While the radio receives a signal (the squelch open, or a DMR call playing), it sends the audio to your computer's
UDP port 32001, with the squelch as the keyup flag. When the program keys up, the radio transmits its audio on the
current channel: on FM through the radio's own transmit audio (its tone and deviation limit apply), on DMR as a call
to the channel's contact. The radio stops transmitting when the program unkeys, stops sending, or after 3 minutes.
Received audio follows the volume knob. tools/usrp_client.py is a small test program
(tools/usrp_client.py <radio address> tone 1000 3 transmits a tone for 3 seconds).
Which radios can transmit FM this way is in the Radio reference; on the others USRP carries DMR only.
The radio runs a TFTP server at its address. Any TFTP client works:
curl tftp://rfoundry-9991234.local/codeplug.bin -o backup.bin # read the codeplug
curl -T edited.bin tftp://rfoundry-9991234.local/codeplug.bin # write it
curl tftp://rfoundry-9991234.local/info.txt # board, firmware, IDs, addresses
codeplug.bin is the same 716,384-byte image tools/cps_client.py read makes. A file from either one can be
written with either one. A write is checked before anything is stored. The radio checks the size first, then that
the file is a codeplug.
A wrong file, a transfer that stops half way, or a cable pulled during the transfer leaves the codeplug as it was. A
power cut while the new codeplug is being stored is finished at the next power on. The radio keeps its own quick
keys, as with the CPS, and re-reads the codeplug right after the write.
The DMR ID database (the names shown for IDs that aren't contacts) has its own file:
curl tftp://rfoundry-9991234.local/iddb.bin -o iddb.bin # read the ID database
curl -T iddb.bin tftp://rfoundry-9991234.local/iddb.bin # write it
iddb.bin holds the database alone. The radio drops its old database as the new one starts arriving and shows names
again once the whole file is in. A transfer that stops leaves no database until the next try, never a broken one.
This works without a staging area, so also on radios where codeplug.bin can't be written.
A codeplug.bin saved by the Codeplug Editor with Save > For USB Network also carries the ID database when the
codeplug has one. The radio takes the database from it only when the client sends the file's size, as curl does.
Otherwise, and with any older codeplug.bin, the radio keeps the database it has. The codeplug part is written as
above.
To stop writes over the network (codeplug.bin and iddb.bin), turn off Settings > Connections > TFTP codeplug
write. Reading stays possible.
The radio answers SNMP version 2c requests at its address, port 161 (not in builds that leave SNMP out for flash room). Any SNMP manager works. The repository has a small one:
tools/rfoundry_snmp.py walk 12.152.116.66 # everything the radio reports
tools/rfoundry_snmp.py get 12.152.116.66 rfoundryBatteryVoltage.0 rfoundryChannelName.0
tools/rfoundry_snmp.py traps # events as they happen (needs port 162: root on Linux)
The radio reports its identity (DMR ID, radio name, model, firmware), battery, channel, frequencies, power, the DMR
call in progress and the last one heard, message and data counters, ARS state and the USB network counters. The
objects are described in docs/spec/RFOUNDRY-MIB.txt. Load it into your manager to see names instead of numbers.
While USB is a network adapter, the radio also sends events to your computer (port 162): power-up, calls starting and ending, text messages received, emergencies, ARS changes and low battery.
The read community is public. Changing settings needs a write community, which is off until you set one:
tools/rfoundry_debug.py snmp write MySecret # over the serial port, before switching to network mode
tools/rfoundry_snmp.py -c MySecret set 12.152.116.66 sysName.0 s:Q0TST
tools/rfoundry_debug.py snmp status # the agent's settings and counters
Other radios can query this radio over the air at its own 12.x.y.z address (read only unless you allow writes).
Events over the air go only to a manager radio you name (tools/rfoundry_debug.py snmp set rf_manager <DMR ID>). Apart
from emergencies, they go at most once a minute. Nothing is encrypted. SNMP community names travel as plain text.
Radios without USB (Radio reference) can get the same network over their programming cable with PPP. A
radio's image includes PPP when the radio has no USB and runs DMR. Other builds need CONFIG_NET_PPP=y. Run this on the computer as root. pppd comes with macOS and most Linux systems.
sudo tools/rfoundry_ppp.sh /dev/ttyUSB0 # Linux
sudo tools/rfoundry_ppp.sh /dev/cu.usbserial-XXXX # macOS
The radio switches to PPP by itself when pppd starts. It gives the computer the same address as in USB network mode.
The services above work the same, only slower (about 10 KB/s at 115200 baud). The front panel page works without its Listen button, and its screen takes up to a few seconds to update on a large color display. sudo tools/rfoundry_ppp.sh --stop hangs
up, and the cable goes back to programming and the debug link. The details are in docs/spec/ppp.md.
Dispatch software (TRBOnet, SmartPTT and similar) can use the radio as its control station. The computer then sends and receives the fleet's messages, locations and registrations through the radio.
- Turn on USB network at start and restart the radio, or switch it in Tools > USB network.
- Turn on PC answers data. While the computer is connected, text messages, location requests and registration answers sent to your radio's DMR ID go to the computer only. The radio no longer answers them itself, doesn't put messages in its inbox and doesn't register with a presence server. It still confirms data packets that ask for a confirmation, and still answers call alerts and radio checks. Unplug the computer and the radio answers for itself again.
- If the software expects fixed addresses, set USB address to 192.168.10.x. The radio is then 192.168.10.1 and the computer gets 192.168.10.2. Unplug and plug in the cable so the computer picks up the new address.
In the dispatch software, set:
| Item | Value |
|---|---|
| Control station address | The radio's address: 192.168.10.1, or 12.x.y.z from your DMR ID |
| Radio network | 12.0.0.0/8 |
| Peripheral network (computers on other radios) | 13.0.0.0/8 |
| Talkgroup network | 225.0.0.0/8 |
| DMR ID | Your radio's DMR ID |
What the computer sends goes over the air from your radio's DMR ID. Only one radio per computer can use the fixed addresses.
UDP packets to other radios go with a compressed header (ETSI's "UDP/IP header compression"). The header is 5 to 9 bytes instead of 28. Packets with a port in 4000-4099 keep the full header, because MOTOTRBO text, location and presence servers listen there. That saves one or two data blocks (60-120 ms on air) per packet. Radios that can't read it are rare. For them, or to compress those ports too:
tools/rfoundry_debug.py data ip-settings off # always the full header
tools/rfoundry_debug.py data ip-settings all # compress every UDP packet
Packets to a radio can also go as confirmed data. The other radio acknowledges each packet, and the radio sends again what didn't arrive. By default it makes 4 tries in all. Name up to two destinations (DMR IDs) or UDP ports:
tools/rfoundry_debug.py data ip-settings auto rules id=9991234 port=161 tries=4
Talkgroup packets are never confirmed. A packet to a radio that doesn't answer is sent every try before it is dropped, so confirm only where it helps. The settings are saved in the radio.
The network link takes packets of up to 586 bytes. The radio gives this size to the computer by DHCP, and to PPP as its MRU (584), and every packet of that size fits in one transmission on the air: up to 558 bytes of UDP data (556 over PPP). There is nothing to set on the computer.
A full-size packet keeps the channel for about 3 seconds (about 4 when it's sent confirmed). Small packets are quicker and more likely to get through on a weak channel: a lost burst loses the whole packet.
By default the radio carries only addresses that stand for a DMR ID: 12.x.y.z for a radio and 225.x.y.z for a talkgroup. A packet from the computer to any other address is dropped.
If another radio in your fleet is a gateway to a network (for example a MOTOTRBO control station on a dispatch PC), give the radio that radio's DMR ID in Settings > Connections > Data services > IP gateway (0 is off), in the Codeplug Editor, or over the debug link:
tools/rfoundry_debug.py data ip-settings auto rules gateway=9990500
tools/rfoundry_debug.py data ip-settings auto rules gateway=0 # off again
The command sets every IP setting at once, so repeat any id=, port= or tries= you use. The setting is saved in
the radio.
Then add a route on the computer for that network through the radio's address. For example, on Linux with the radio
as usb0:
sudo ip route add 10.20.0.0/16 via 12.152.116.66 dev usb0 # the radio's address (Addresses, above)
Packets to that network go over the air to the gateway radio, with the real destination address in the packet. They always use the full header, never the compressed one. Each one loses one from its time to live (TTL), and a packet with none left is dropped. The radio passes the time to live it received to the computer, so a packet caught in a loop between two gateway radios runs out. Answers come back to your radio's DMR ID with the sender's real address, and the radio passes them to the computer.