Project Home
Project Home
Wiki
Wiki
Discussion Forums
Discussions
Project Information
Project Info
Forum Topic - using sendmsg/sendmmsg for data link layer packets: (1 Item)
   
using sendmsg/sendmmsg for data link layer packets  
Hi,

i have written an application which runs under QNX version 7.1.0 to send raw Ethernet frames using BPF interface. The 
application constructs the Ethernet frame and send it using the write() function, it is working fine.

Since the number of frames that we need to send are really large, by using the write() function it takes long time and 
the throughput is very low.

Therefore I consider using the sendmsg (mainly sendmmsg) to send large chunks of frames in one shot. However these 
functions are not working with BPF interface and throws the error "Socket operation on non-socket".


 
Here is the used code snippet:


 std::vector<uint8_t> m_buffer = ...;

  struct msghdr snd_msg;

  unsigned char dst_addr[6] = {0x11, 0x11, 0x11, 0x11, 0x11, 0x11};

  struct iovec snd_iov[1];
  snd_iov[0].iov_base = m_buffer.data();
  snd_iov[0].iov_len = m_buffer.size();

  snd_msg.msg_name = dst_addr;
  snd_msg.msg_namelen = 6;
  snd_msg.msg_iov = snd_iov;
  snd_msg.msg_iovlen = 1;
  snd_msg.msg_control = 0;
  snd_msg.msg_controllen = 0;

  ssize_t bytes_sent = sendmsg(m_socketFd, &snd_msg, 0);

  if (bytes_sent == -1) {
    std::cerr << "sendmsg failed: " << strerror(errno) << "\n";
  } else if (bytes_sent != m_buffer.size()) {
    std::cerr << "could not send all data: " << bytes_sent << "\n";
  } else {
    std::cout << "sent all data\n";
  }


The error msg:

# /tmp/send 
sendmsg failed: Socket operation on non-socket


What is the standard solution to send multiple raw Ethernet frames in QNX?


Thanks