Groups keyboard shortcuts have been updated
Dismiss
See shortcuts

OSError [Errno 19] No such device when sending packets with Scapy in Mininet-WiFi

72 views
Skip to first unread message

Huy Đỗ Quang

unread,
Aug 23, 2024, 5:29:53 AM8/23/24
to mininet-wifi-discuss

Hi,

I’m encountering an issue when trying to send packets using Scapy in a Mininet-WiFi setup. I receive the following error:
OSError: [Errno 19] No such device


Although, running ifconfig on sta1 gives the following information:
mininet-wifi> sta1 ifconfig
sta1-wlan0: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
        inet 10.0.0.1  netmask 255.0.0.0  broadcast 10.255.255.255


Here is the code I’m using to send packets:  
from scapy.all import IP, ICMP, sendp

ip_layer = IP(src="10.0.0.1", dst="10.0.0.2")
icmp_layer = ICMP(type='echo-request', id=1, seq=1) / "hello"
packet = ip_layer / icmp_layer

try:
    sendp(packet, iface='sta1-wlan0')
except OSError as e:
    print(f"Error: {e}")

What could be causing the No such device error when using Scapy to send packets from sta1?

Thank you!



Ramon Fontes

unread,
Aug 23, 2024, 5:50:05 AM8/23/24
to Huy Đỗ Quang, mininet-wifi-discuss
There is no problem with your code. It works.

Huy Đỗ Quang

unread,
Aug 26, 2024, 5:39:04 AM8/26/24
to mininet-wifi-discuss
Not sure why it does not work here on my end
Here's the sendpacket command that I modify from mn_wifi/cli.py:

def do_sendpacket(self, line):
        """Send a packet with content to a destination node by transferring through neighbor nodes until it reaches the destination.
            Usage: sendpacket <source_node> <destination_node> <content>"""
        args = line.split()
        if len(args) != 3:
            error('Usage: sendpacket <source_node> <destination_node> <content>\n')
            return


         ip_layer = IP(src="10.0.0.1", dst="10.0.0.2")
         icmp_layer = ICMP(type='echo-request', id=1, seq=1) / "hello"
         packet = ip_layer / icmp_layer

         try:
              print(packet.show())

              sendp(packet, iface='sta1-wlan0')
         except OSError as e:
              print(f"Error: {e}")
        

mininet-wifi> sendpacket sta1 sta2 "hello"
###[ IP ]###
  version   = 4
  ihl       = None
  tos       = 0x0
  len       = None
  id        = 1
  flags     =
  frag      = 0
  ttl       = 64
  proto     = icmp
  chksum    = None
  src       = 10.0.0.1
  dst       = 10.0.0.2
  \options   \
###[ ICMP ]###
     type      = echo-request
     code      = 0
     chksum    = None
     id        = 0x1
     seq       = 0x1
###[ Raw ]###
        load      = 'hello'

None
An error occurred while sending packet: [Errno 19] No such device
Exception ignored in: <function SuperSocket.__del__ at 0x7f4b14f654e0>
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/scapy/supersocket.py", line 134, in __del__
    self.close()
  File "/usr/lib/python3/dist-packages/scapy/arch/linux.py", line 514, in close
    set_promisc(self.ins, self.iface, 0)
  File "/usr/lib/python3/dist-packages/scapy/arch/linux.py", line 165, in set_promisc
    mreq = struct.pack("IHH8s", get_if_index(iff), PACKET_MR_PROMISC, 0, b"")
                                ^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/scapy/arch/linux.py", line 380, in get_if_index
    return int(struct.unpack("I", get_if(iff, SIOCGIFINDEX)[16:20])[0])
                                  ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/scapy/arch/common.py", line 59, in get_if
    ifreq = ioctl(sck, cmd, struct.pack("16s16x", iff.encode("utf8")))
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

OSError: [Errno 19] No such device

Vào lúc 16:50:05 UTC+7 ngày Thứ Sáu, 23 tháng 8, 2024, ramonre...@gmail.com đã viết:

UDIT PATEL

unread,
Aug 27, 2024, 5:12:28 AM8/27/24
to mininet-wifi-discuss
Hi

Can you ping other device from CLI?

Huy Đỗ Quang

unread,
Aug 29, 2024, 5:13:19 AM8/29/24
to mininet-wifi-discuss
Yes, stations can ping each other fine

Vào lúc 16:12:28 UTC+7 ngày Thứ Ba, 27 tháng 8, 2024, udit.p...@gmail.com đã viết:
Reply all
Reply to author
Forward
0 new messages