← index #4425PR #3066
Off-topic · high · value 1.874
QUERY · ISSUE

esp8266 recvfrom() gives ap address instead of source

openby pmp-popened 2019-01-24updated 2019-05-13
port-esp8266

on esp8266 with master :
STA 192.168.4.2 send packet to AP with sendto( data, ('192.168.4.1',port) )

on ap data, adrr = recvfrom() gives addr[0] == '192.168.4.1' source address instead of '192.168.4.2'

CANDIDATE · PULL REQUEST

esp8266/modnetwork: Add network.wlan.sniffer() function.

closedby rmokeroneopened 2017-05-05updated 2017-05-07

I noticed that esp8266 has a promiscuous mode.So I use this mode to write a sniffer function.This function sniffs the mac address of the device that is linked to the specified device.

Function definition:

class wlan.network.sniffer(mac=*, ch=1, timeout=1)
[(source mac, dest mac, Number of packets captured)]

Example:

>> import network
>> ap = network.WLAN(network.AP_IF)
>> ap.active(False)  #First: Close AP mode
>> sta = network.WLAN(network.STA_IF)
>> sta.active(True) #Second: Open STA mode
>> sta.scan() #Scan all AP
[(b'Drone', b'\xa8\x15M@\xe98', 1, -35, 4, 0), (b'EXCEL', b'\x0cr,x\x88\xc0', 1, -62, 4, 0), (b'ics543', b'$ih\x8f\x8c\x8e', 1, -56, 4, 0), (b'ics542', b'\xa8\x15M\xe7\n\xf8', 1, -60, 4, 0), (b'TP-LINK_15C4', b'\xd0\xc7\xc0\x84\x15\xc4', 1, -57, 4, 0), (b'Jedi', b'\xd4\xee\x07\x15D\xd6', 1, -72, 4, 0)]
>>> sta.sniffer(mac= b'\xa8\x15M@\xe98', ch=1, timeout=10) #sniffs specified device 10s
[(b'\xa8\x15M@\xe98', b'\x8cpZ\xeeL`', 84), (b'\xa8\x15M@\xe98', b'`\x834\xbd\xf5:', 1)]

Keyboard

j / / n
next pair
k / / p
previous pair
1 / / h
show query pane
2 / / l
show candidate pane
c
copy suggested comment
r
toggle reasoning
g i
go to index
?
show this help
esc
close overlays

press ? or esc to close

copied