#!/usr/bin/python3 # -*- coding: utf-8 -*- # Run the UDP server from our last lecture page first. # UDP raw socket import socket import struct s = socket.socket(socket.AF_INET, socket.SOCK_RAW, socket.IPPROTO_UDP) data = "string" sport = 1337 # arbitrary source port dport = 12000 # arbitrary destination port length = 8 + len(data) checksum = 0 udp_header = struct.pack("!HHHH", sport, dport, length, checksum) s.sendto(udp_header + data.encode(), ("", dport))