This directory contains a small RDMA-based file transfer example for moving large files directly between two Linux hosts or VMs using a Mellanox ConnectX-4 card and a direct SFP connection.
The project includes:
rdma_file_send.c— sender siderdma_file_recv.c— receiver siderdma_pingpong.c— basic RDMA ping-pong testrdma_write_bw.c— bandwidth testrdma_read_lat.c— latency testMakefile— builds the Linux RDMA toolsRDMA_GUIDE.md— detailed RDMA reference and background
This README is intended as a practical getting-started guide for hardware installation, driver setup, and file transfers.
The setup below shows the recommended physical arrangement: a host machine with a Mellanox PCIe card passed through to two VMs, with each VM using one of the RDMA-capable ports over an SFP cable.
flowchart LR
subgraph HOST[Physical Host]
CPU[Host CPU]
PCIe[PCIe Slot]
NIC[Mellanox ConnectX-4 Card\nPassthrough to VMs]
SFP1[SFP+ Cable]
end
subgraph VM1[VM 1]
APP1[Sender App\nrdma_file_send]
VF1[VF / Passthrough NIC]
end
subgraph VM2[VM 2]
APP2[Receiver App\nrdma_file_recv]
VF2[VF / Passthrough NIC]
end
PCIe --> NIC
NIC --> VF1
NIC --> VF2
VF1 --> SFP1
SFP1 --> VF2
APP1 --> VF1
APP2 --> VF2
Follow this procedure on the physical host:
- Power off the system before inserting the card.
- Open the chassis and locate a free PCIe x8 or x16 slot with enough airflow.
- Insert the Mellanox ConnectX-4 card firmly into the slot.
- Secure the bracket and confirm the card is seated properly.
- Connect the SFP+ cable to the Mellanox port.
- If using a direct cable between two machines or VMs, ensure both ends are connected to compatible ports.
- Boot the system and check that the card is visible in the PCI bus:
lspci | grep -i mellanox
lspci | grep -i mellanox- Verify the NIC link status after boot:
ip link
ibstat
ibv_devinfo- If the link is down, check:
- SFP module compatibility
- cable seating and polarity
- proper PCIe slot seating
- firmware version of the card
- port configuration and link settings in the BIOS / host setup
For a direct point-to-point RDMA connection, both endpoints must be configured consistently and the Mellanox card must have the correct kernel drivers and firmware loaded.
The Mellanox card requires the correct RDMA drivers before the ibv_* tools and the examples in this directory can work.
Download the OFED package from NVIDIA/Mellanox and install it on the Linux box.
wget <MLNX_OFED_PACKAGE_URL>
chmod +x MLNX_OFED_LINUX-*.tgz
sudo tar -xf MLNX_OFED_LINUX-*.tgz -C /tmp
cd /tmp/MLNX_OFED_LINUX-*
sudo ./mlnxofedinstall --upstream-libs --dpdk --force
sudo /etc/init.d/openibd restartThen verify the device is detected:
ibv_devinfo
ibstatOn Ubuntu or Debian systems, install the core RDMA packages:
sudo apt update
sudo apt install -y build-essential gcc make linux-headers-$(uname -r) \
rdma-core libibverbs-dev librdmacm-dev ibverbs-utils infiniband-diagsThen check the adapter:
ibv_devinfoThe following commands confirm that the card is correctly installed and the RDMA stack is active:
ibv_devinfo
ibstat
cat /sys/class/infiniband/*/ports/1/stateIf the ports are not active, inspect the driver and firmware status first.
The examples in this folder are meant to be compiled on a Linux machine with RDMA libraries available.
Use your Linux VM or server and copy the directory:
scp -r /path/to/rdma user@linux-host:/home/user/Then build:
cd ~/rdma
makeThe Makefile in this directory builds the example programs, including:
make rdma_file_send
make rdma_file_recvFor detailed background, references, and additional RDMA setup information, consult RDMA_GUIDE.md.
To validate large transfers, create a sample file of a few GBs:
dd if=/dev/zero of=/tmp/sample_4G.bin bs=1M count=4096 status=progressdd if=/dev/zero of=/tmp/sample_16G.bin bs=1M count=16384 status=progressYou can also use truncate if a sparse file is enough:
truncate -s 16G /tmp/sample_sparse_16G.binUse real data when validating checksums. For a more realistic test, prefer generating a file with random or compressed data.
This project uses a sender and a receiver. One machine acts as the server and the other is the client sender.
Run the receive program first:
cd ~/rdma
./rdma_file_recv --summary /tmp/received.binOptional progress flags:
./rdma_file_recv --verbose /tmp/received.bin
./rdma_file_recv --quiet /tmp/received.binNow send the file from the other machine or VM:
cd ~/rdma
./rdma_file_send --summary 10.0.0.2 /tmp/sample_4G.binOptional progress flags:
./rdma_file_send --verbose 10.0.0.2 /tmp/sample_4G.bin
./rdma_file_send --quiet 10.0.0.2 /tmp/sample_4G.binOn the receiver:
./rdma_file_recv --summary /tmp/received.binOn the sender:
./rdma_file_send --summary 192.168.1.20 /tmp/sample_4G.binAfter transfer, compare the file size and checksum:
ls -lh /tmp/received.bin
md5sum /tmp/received.bin /tmp/sample_4G.binThe MD5 values should match for a correct transfer.
ibstat
ibv_devinfo
ip link showcat /sys/class/infiniband/*/ports/1/statels /sys/class/infinibanddmesg | grep -i -E 'mlx|mellanox|ib'- Check whether the cables are fully seated.
- Confirm both machines see the Mellanox device.
- Verify
ibv_devinforeports a valid port state. - Make sure the IP addresses are reachable between the sender and receiver.
- Rebuild and rerun the example from a clean Linux environment.
- Start with a smaller file to confirm the connection is working.
- This project is intended for Linux hosts with RDMA-capable devices.
- This directory is designed around the Mellanox ConnectX-4 / libibverbs workflow.
- For deeper information about RDMA concepts, queue pairs, memory registration, GID selection, and performance tuning, refer to RDMA_GUIDE.md.
- The project is best validated on a real Linux RDMA host or VM with direct hardware passthrough and a working Mellanox NIC.
This file is meant to be a practical starting point. It can be expanded later with host-specific tuning, VLAN or RoCE config, or an example production deployment workflow.


