cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
436
Views
0
Helpful
1
Replies

Cisco Modelling Labs - VM does not receive traffic on a python socket

Ivan Mamka
Level 1
Level 1

Howdy,

Take an Ubuntu VM in CML (2.4.1) and connect it's interface to the switch. Modify below script so the interface number matches (in my case was ens3). Run the script using python3. It will NOT print received STP/RSTP packets until one starts  "tcpdump -i ens3" (ens3 in my case). When stopping tcpdump, script stops receiving packets. Is this something to do with subscription to multicast address 0180c2000000?

Why I don't receive packets?

ETH_P_ALL = 0x0003
BUFFER_SIZE = 65536
a = BUFFER_SIZE * 0
import socket
class port_receive_state_machine():

def starting():
print("Receiving for port : ens3")
sckt = socket.socket(socket.AF_PACKET, socket.SOCK_RAW)
sckt.bind(("ens3", ETH_P_ALL))
while(1):
a =sckt.recvfrom(BUFFER_SIZE)[0].hex()
print(a)
a = BUFFER_SIZE * 0


if __name__ == "__main__":
port_receive_state_machine.starting()

1 Reply 1

Ivan Mamka
Level 1
Level 1

Yes it was to do with ubuntu settings. Fixed by below command:

ip link set ens3 allmulticast on