> This page is for version 3.0 (Latest) (default).
> For other versions, use one of these documentation indexes:
> - 3.0 (Latest) (default): https://docs.nvidia.com/holoscan/sensor-bridge/3-0/llms.txt
> - 2.7: https://docs.nvidia.com/holoscan/sensor-bridge/2-7/llms.txt
> - Archives: https://docs.nvidia.com/holoscan/sensor-bridge/archives/llms.txt

> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.nvidia.com/holoscan/sensor-bridge/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.nvidia.com/holoscan/sensor-bridge/_mcp/server.

# hololink::module::ibv_device_for_peer

> Find the InfiniBand verbs device and port through which this host reaches a device.

```cpp showLineNumbers={false}
std::pair<std::string, uint32_t> hololink::module::ibv_device_for_peer(
    const std::string &peer_ip,
    const std::string &interface = std::string()
)
```

Find the InfiniBand verbs device and port through which this host reaches a device.

A RoCE receiver must use the network adapter that is actually connected to the device it receives from. When the host has more than one adapter, this identifies the right one: the adapter on the network interface used to reach `peer_ip`. Pass the result as the `ibv_name` and `ibv_port` of RoceReceiverInterfaceV1::start().

Only RoCE builds provide this function, since it uses the ibverbs library.

**Returns:** The device name (for example `"roceP5p3s0f0"`) and the port number on that device. If more than one device and port match, the first one the system lists is returned.

**Throws:** `std::runtime_error` if the list of devices cannot be read, or no device and port is bound to the network interface. The message names `peer_ip` and, in the second case, the interface.

**Parameters**

**`peer_ip`** `const std::string &`

IP address of the device. It is used to identify the network interface only when `interface` is not given; it is also named in error messages.

---

**`interface`** `const std::string &` — default: std::string()

Name of the host's network interface that is connected to the device, as recorded in the enumeration metadata under "interface" (the interface on which the device's enumeration message arrived). Pass it whenever it is available. If empty, the interface is chosen by the host's routing table for `peer_ip`, which gives the wrong answer when two devices share the same default data-plane subnet (192.168.0.x): both resolve to the same adapter, and frames from the other device are never received.

---