Skip to content

Commit

Permalink
Merge pull request #143 from DUNE-DAQ/thea/dpdk_multi_ip
Browse files Browse the repository at this point in the history
Adding support for NICReceivers having multiple ips
  • Loading branch information
alessandrothea authored Oct 10, 2024
2 parents b2bb405 + 2c705c6 commit b993be9
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 11 deletions.
24 changes: 15 additions & 9 deletions src/IfaceWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,17 @@ IfaceWrapper::IfaceWrapper(
m_iface_id = iface_id;
m_mac_addr = net_device->get_mac_address();
m_ip_addr = net_device->get_ip_address();
IpAddr ip_addr_struct(m_ip_addr);
m_ip_addr_bin = udp::ip_address_dotdecimal_to_binary(
ip_addr_struct.addr_bytes[3],
ip_addr_struct.addr_bytes[2],
ip_addr_struct.addr_bytes[1],
ip_addr_struct.addr_bytes[0]
);

for( const std::string& ip_addr : m_ip_addr) {
IpAddr ip_addr_struct(ip_addr);
m_ip_addr_bin.push_back(udp::ip_address_dotdecimal_to_binary(
ip_addr_struct.addr_bytes[3],
ip_addr_struct.addr_bytes[2],
ip_addr_struct.addr_bytes[1],
ip_addr_struct.addr_bytes[0]
));
}


auto iface_cfg = receiver->get_configuration();

Expand Down Expand Up @@ -109,7 +113,7 @@ IfaceWrapper::IfaceWrapper(
for( auto nw_sender : nw_senders ) {
auto sender_ni = nw_sender->get_uses();

std::string tx_ip = sender_ni->get_ip_address();
std::string tx_ip = sender_ni->get_ip_address().at(0);

for ( auto res : nw_sender->get_contains() ) {

Expand Down Expand Up @@ -385,7 +389,9 @@ IfaceWrapper::garp_func()
{
TLOG() << "Launching GARP sender...";
while(m_run_marker.load()) {
arp::pktgen_send_garp(m_garp_bufs[0][0], m_iface_id, m_ip_addr_bin);
for( const auto& ip_addr_bin : m_ip_addr_bin ) {
arp::pktgen_send_garp(m_garp_bufs[0][0], m_iface_id, ip_addr_bin);
}
++m_garps_sent;
std::this_thread::sleep_for(std::chrono::seconds(1));
}
Expand Down
4 changes: 2 additions & 2 deletions src/IfaceWrapper.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ namespace dpdklibs {

bool m_with_flow;
bool m_prom_mode;
std::string m_ip_addr;
rte_be32_t m_ip_addr_bin;
std::vector<std::string> m_ip_addr;
std::vector<rte_be32_t> m_ip_addr_bin;
std::string m_mac_addr;
int m_socket_id;
int m_mtu;
Expand Down

0 comments on commit b993be9

Please sign in to comment.