sockets - Python decoding UDP -


code:

import socket, binascii, struct  s = socket.socket(socket.af_inet, socket.sock_raw, socket.ipproto_udp) while true:     print s.recv(2048) 

output:

ek�9@@�f5��w�jq��� stackexchangecom� electronics �
h h

stackexchangecomda�scifi et@@�<���� stackoverflowcom���meta ,��� stackoverflowcom�a���meta ,��� stackexchangecomg��security ee@@�+���� stackexchangecom���scifi

as can see of data has been decoded/interpreted rest isn't not sure why

can help?

you're printing raw udp packets, contain arbitrary binary data. of bytes in printable range, aren't in range converted �.

you can better @ data printing representation, shows printable bytes normal , shows unprintable ones hexadecimal escape codes. that, change print statement to:

    print repr(s.recv(2048)) 

i suspect you'd decode packets. that's quite possible, it's bit technical, , should study topic bit first. :) article silver moon, code network packet sniffer in python linux, looks quite helpful.


Comments

Popular posts from this blog

javascript - Karma not able to start PhantomJS on Windows - Error: spawn UNKNOWN -

c# - Display ASPX Popup control in RowDeleteing Event (ASPX Gridview) -

Nuget pack csproj using nuspec -