Results returned by socket.recvfrom()

727 Views Asked by At

I have this simple code in python-3.5 :

import socket
sock = socket.socket(socket.AF_PACKET, socket.SOCK_RAW, socket.ntohs(3))
raw_data, addr = sock.recvfrom(65536)

recvfrom() returns data received on the socket in raw_data variable and a tuple in addr variable.

This returned tuple (addr) has 5 elements in it and I can't find the meaning of the different elements.

addr[0] contains the name of the interface on which raw_data was received.

addr[1] contains the Ethertype received.

addr[4] contains the layer 2 address of the sender (as far as I understand).

What are the values contained in elements addr[2] and addr[3]?

1

There are 1 best solutions below

0
On

The third one is somehow related to a sender address you see:

('eth0', 2048, 4, 1, b'RT\x00\x96\x9d\x16')
('eth0', 2054, 1, 1, b'\x00\x10t"\x82|')
('eth0', 2048, 0, 1, b'l;k`g0')