6

I have the following tcpdump -i eth0 -n tcp port 5000 to filter every packet flowing between 2 hosts. However, one of the hosts always sends an ACK.

How do I hide this ACK?

bulkmoustache
  • 679
  • 2
  • 10
  • 22
  • 3
    Do you mean a TCP packet with the "ACK" TCP flag set or an ACK in another protocol on top of TCP? Note that many TCP packets usually have the ACK flag set. Do you mean packets with only that flag and no data? – Stéphane Chazelas May 20 '14 at 19:55

3 Answers3

6

tcpdump -i eth0 -n 'tcp port 5000 and (tcp[tcpflags] & tcp-ack == 0)' should do what you want. It does bitwise and between TCP flags and ACK-only bitmask, so if there's no ACK, the result should equal to zero.

TNW
  • 2,110
  • ACK is just a flag in a packet, one of many. By blindly skipping packets with the ACK bit set, you can lose data because a packet can carry data and have the ACK bit set. – rustyx Apr 25 '16 at 08:46
2

you can hide it by piping the command to grep:

tcpdump -i eth0 -n tcp port 5000 | grep -e ACK -v

-e option is to select a pattern (ACK in your case)
-v (to invert the grep function : grep all except the defined pattern) 
Nidal
  • 8,956
1

I copied this straight from man tcpdump filters example:

To print all IPv4 HTTP packets to and from port 80, i.e. print only packets that contain data, not, for example, SYN and FIN packets and ACK-only packets. (IPv6 is left as an exercise for the reader.)

tcpdump 'tcp port 80 and (((ip[2:2] - ((ip[0]&0xf)<<2)) - ((tcp[12]&0xf0)>>2)) != 0)'

Pete
  • 274