hping recv ?-hexdata? interface ?timeout? ?count?
Receive packets as a Tcl list in the APD format. interface is
the interface from wich to read packets, timeout is an optional
argument to set a timeout value in milliseconds, with the
exception that a zero timeout means to return as soon as possible
the packets that was already in queue when the hping recv subcommand
was called, while a -1 timeout value means to expect forever
for packets (no timeout). If timeout is specified, an additional
(optional) count parameter can be specified, modifing the recv
subcommand behaviour to return as soon as count packets were
already received. A special count value of zero means
to collect an infinite number of packets (at least until the
timeout is not reached).
The optional -hexdata switch specify to return packets payload
as hex digits instead of quoted strings. To use -hexdata is encouraged
for all the applications, but the ones that needs to display packets
in a human readable format.
For default the timeout is set to -1, and count to 1 (in other
words hping will wait forever if no packets are available, but
will return when the first packet is received).
Examples
# Capture a packet from eth0
hping3.0.0-alpha> hping recv eth0
{ip(ihl=5,ver=4,tos=02,totlen=58,id=63474,fragoff=0,mf=0,df=1,rf=0,ttl=64,proto=6,cksum=9ecb,saddr=192.168.1.6,daddr=213.82.224.41)+tcp(sport=33295,dport=110,seq=2486133764,ack=2745754339,x2=0,off=8,flags=pa,win=5840,cksum=7a69,urp=0)+tcp.nop()+tcp.nop()+tcp.timestamp(val=1021017,ecr=355869116)+data(str=STAT\0d\0a)}
# Caputure a packet using the hex format for data payload
hping3.0.0-alpha> hping recv -hexdata eth0
ip(ihl=5,ver=4,tos=00,totlen=84,id=2435,fragoff=0,mf=0,df=0,rf=0,ttl=49,proto=1,cksum=25be,saddr=216.239.39.99,daddr=192.168.1.6)+icmp(type=0,code=0,id=55048,seq=512)+data(hex=3f565c1b000d7e4008090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f3031323334353637)
# Wait for all the packets received in 5 seconds, and print how many they are
hping3.0.0-alpha> puts [llength [hping recv eth0 5000 0]]
36
|