How to send big chunk of data in one UDP packet?

半城伤御伤魂 提交于 2019-12-06 05:30:14

The problem is because netcat reads in chunks of a specific size and writes in these chunk sizes. And since it is reading from a stream (i.e. stdin) there is no way to define something like message boundary anyway. I cannot see any options to change the read size with nc but if you need some command line to send larger packets you could use Perl or similar like this:

$ dd if=/dev/zero bs=1024 count=32 | perl -MIO::Socket::INET -e \
   'IO::Socket::INET->new(PeerAddr => q[127.0.0.1:1234], Proto => q[udp])->send(do { local $/; <STDIN> })'

$ tcpdump -i lo -n port 1234
... IP 127.0.0.1.42061 > 127.0.0.1.1234: UDP, length 32768                                                                                                                       
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!