Steve Borba

My notes, I hope they help you, feel free to comment/add to them

Generate a UDP Packet

$IP   = '192.0.2.1'
$Port = 1234

$MTU = 1500
#IP (20) and UDP (8) - IPv6 is another 20, maybe detect and take off another add 20?
$Data  = ([System.Text.Encoding]::ASCII).GetBytes(("abcdefghijklmonpqrstuvwxyz0123456789"*42*6).Substring(0,$MTU-28))

#This is 
#$Data  = ([System.Text.Encoding]::ASCII).GetBytes(("abcdefghijklmonpqrstuvwxyz012345678"*6*42+"abc"*42+"012345678912"))
$UDPclient = new-Object System.Net.Sockets.UdpClient
$UDPclient.Connect([Net.IPAddress]::Parse($IP),$port)
[void]$UDPclient.Send($Data, $Data.Length)

Leave a Reply

Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>