Product
Introducing SSO
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
udp-packet
Advanced tools
Readme
var udp = require('udp-packet')
console.log(udp.encode({
sourceIp: '10.0.0.1',
sourcePort: 58936,
destinationIp: '10.0.0.2',
destinationPort: 80,
data: Buffer('whatever')
}))
output:
<Buffer e6 38 00 50 00 10 61 7d 77 68 61 74 65 76 65 72>
var udp = require('udp-packet')
var buf = Buffer([
0xea, 0x61, 0xe2, 0xde, 0x00, 0x50, 0xd5, 0x20, 0x80, 0x00, 0x00, 0x00, 0x00,
0x04, 0x41, 0x81, 0xc6, 0xe0, 0x46, 0xba, 0xfd, 0xc6, 0x87, 0x22, 0x10, 0xd7,
0xeb, 0xda, 0xd7, 0x4f, 0x62, 0x45, 0xac, 0x6b, 0xce, 0x7e, 0x6a, 0x8d, 0x4d,
0xbc, 0xd2, 0x57, 0x32, 0x76, 0xcf, 0xa0, 0xde, 0x22, 0x38, 0xf7, 0xe0, 0xd8,
0xee, 0x6e, 0xe0, 0xa1, 0xe8, 0xb3, 0x3e, 0x29, 0x6e, 0x08, 0x9a, 0x4a, 0xad,
0x6e, 0x51, 0xed, 0x0b, 0xf6, 0x13, 0xff, 0xd8, 0x24, 0xbf, 0xba, 0xa4, 0x0b,
0x05, 0xad
])
console.log(udp.decode(buf))
output:
{ sourcePort: 60001,
destinationPort: 58078,
length: 80,
checksum: 54560,
data: <Buffer 80 00 00 00 00 04 41 81 c6 e0 46 ba fd c6 87 22 10 d7 eb da d7 4f 62 45 ac 6b ce 7e 6a 8d 4d bc d2 57 32 76 cf a0 de 22 38 f7 e0 d8 ee 6e e0 a1 e8 b3 ... > }
var udp = require('udp-packet')
Encode a packet
:
packet.sourcePort
packet.destinationPort
packet.data
- buffer payloadOptionally, for checksums:
packet.sourceIp
- ipv4 address string or 4-byte bufferpacket.destinationIp
- ipv4 address string or 4-byte bufferpacket.protocol
- protocol number (default: 0x11 for UDP)Decode a given a UDP data packet buf
:
packet.sourcePort
packet.destinationPort
packet.length
- length of total udp packet, including 8 byte headerpacket.checksum
packet.data
Return the checksum for a decoded packet
.
npm install udp-packet
MIT
FAQs
encode/decode raw udp packets
The npm package udp-packet receives a total of 40 weekly downloads. As such, udp-packet popularity was classified as not popular.
We found that udp-packet demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.