Send a packet of data literally via UDP in Python
Question: I want to my UDP data packet to have literately this information for example:

    
    
    data = "83053163021478010102010370020000000000"
    

I'm using the follow code to send it which works fine(I can see it going out
on wireshark):

    
    
    listener = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
    listener.sendto(data, (IP, PORT))
    

When I look at the data packet in wireshark i want the (wireshark)data packet
== data. How do I declare/convert the data type to make this happen.


Answer: I think this should do the trick:

    
    
    import codecs
    data = codecs.decode("83053163021478010102010370020000000000", "hex_codec")
    

Then you can send `data` same as you are doing now.

ref: [How to create python bytes object from long hex
string?](http://stackoverflow.com/questions/443967/how-to-create-python-bytes-
object-from-long-hex-string)

