Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

keepalive flag isnt working #683

Open
deepakdeore2004 opened this issue Feb 24, 2024 · 6 comments
Open

keepalive flag isnt working #683

deepakdeore2004 opened this issue Feb 24, 2024 · 6 comments

Comments

@deepakdeore2004
Copy link

Version and Runtime

$ vegeta -version
Version:
Commit:
Runtime: go1.14.2 linux/amd64
Date:

Expected Behaviour

connections should not have keepalive when --keepalive off is set

Actual Behaviour

netstat shows keepalive is set for the socket

$ netstat -panto |grep :443 |grep ESTA
(Not all processes could be identified, non-owned process info
 will not be shown, you would have to be root to see it all.)
tcp        0      0 10.244.1.70:33067       142.250.77.132:443      ESTABLISHED -                    keepalive (28.52/0/0)

Steps to Reproduce

  1. echo "GET https://www.google.com/" | vegeta attack --duration=10m --rate=3 --keepalive on | vegeta report -every 3s
  2. run netstat -panto |grep :443 |grep ESTA in another terminal to see connections details

Additional Context

@Choms
Copy link

Choms commented Feb 27, 2024

Hi, on your steps you have --kepalive on, it should be -keepalive=false.

However, and to not open a new issue, I do actually see an issue regarding connections falling back to keepalive, when I specify --rate of 1000 or more, with rate under 500 seems ok but with 1k seems it's reusing connections regardless specifying keepalive false.

I did some research and I see Vegeta's code has references to this library https://cs.opensource.google/go/x/net that was in use originally, but since then I think you are using the built in 'net' library (https://github.com/tsenart/vegeta/blob/master/lib/attack.go#L10). However, these two libraries differ on the Dialer function regarding keepalive:

original (https://cs.opensource.google/go/x/net/+/master:internal/quic/config.go;l=92):

	// an idle connection alive.
	// If zero, keep alive packets are not sent.
	// If greater than zero, the keep alive period is the smaller of KeepAlivePeriod and
	// half the connection idle timeout.

new (https://pkg.go.dev/net@go1.22.0#Dialer):

	// probes for an active network connection.
	// If zero, keep-alive probes are sent with a default value
	// (currently 15 seconds), if supported by the protocol and operating
	// system. Network protocols or operating systems that do
	// not support keep-alives ignore this field.
	// If negative, keep-alive probes are disabled.

so if you are actually using the built in library you should be passing a negative integer here and not a 0 so this works correctly: https://github.com/tsenart/vegeta/blob/master/lib/attack.go#L188

note: I don't usually work with go, this is an educated guess reading through a bit here trying to explain the behavior I'm seeing, hopefully it helps :)

@Choms
Copy link

Choms commented Feb 28, 2024

Hi all,

quick update, I did some more testing (using netstat -panto to verify the connections) with the current code it does indeed use for any rate keepalive and retransmissions, I did a custom build changing the line referenced to -1 and now I'm actually seeing connections with keepalive off (though strangely I still see a bunch of retransmissions and one or two sporadic keepalives - but at least now I can see most of the traffic not using keepalive).

Cheers

@deepakdeore2004
Copy link
Author

deepakdeore2004 commented Apr 8, 2024

thanks for the reply @Choms
there may be typo in my repoduction steps but i ran same command with keepalive off but still see the keepalives

# vegeta --version
Version: v12.11.1
Commit: 6fbe391628eeeae1adf39522a55078797e6e7f2e
Runtime: go1.20.8 linux/amd64
Date: 2023-10-02T09:05:05Z+0000
echo "GET https://www.google.com/" | vegeta attack --duration=10m --rate=3 --keepalive off | vegeta report -every 3s
root@48ec74f242ab:/# netstat -panto |grep :443 |grep ESTA
tcp        0      0 172.17.0.2:59877        142.250.182.132:443     ESTABLISHED 2926/qemu-x86_64     keepalive (24.63/0/0)
root@48ec74f242ab:/# netstat -panto |grep :443 |grep ESTA
tcp        0      0 172.17.0.2:59877        142.250.182.132:443     ESTABLISHED 2926/qemu-x86_64     keepalive (23.15/0/0)
root@48ec74f242ab:/# netstat -panto |grep :443 |grep ESTA
tcp        0     48 172.17.0.2:59877        142.250.182.132:443     ESTABLISHED 2926/qemu-x86_64     on (0.20/0/0)
root@48ec74f242ab:/# netstat -panto |grep :443 |grep ESTA
tcp        0      0 172.17.0.2:59877        142.250.182.132:443     ESTABLISHED 2926/qemu-x86_64     keepalive (21.24/0/0)
root@48ec74f242ab:/# netstat -panto |grep :443 |grep ESTA
tcp        0      0 172.17.0.2:59877        142.250.182.132:443     ESTABLISHED 2926/qemu-x86_64     keepalive (14.45/0/0)
root@48ec74f242ab:/# netstat -panto |grep :443 |grep ESTA
tcp        0      0 172.17.0.2:59877        142.250.182.132:443     ESTABLISHED 2926/qemu-x86_64     keepalive (11.93/0/0)
root@48ec74f242ab:/# netstat -panto |grep :443 |grep ESTA
tcp        0      0 172.17.0.2:59877        142.250.182.132:443     ESTABLISHED 2926/qemu-x86_64     keepalive (10.53/0/0)
root@48ec74f242ab:/# netstat -panto |grep :443 |grep ESTA
tcp        0     41 172.17.0.2:59877        142.250.182.132:443     ESTABLISHED 2926/qemu-x86_64     keepalive (9.82/0/0)

@Choms
Copy link

Choms commented Apr 8, 2024

yeah, for that to work you need to change this line to be -1 instead of 0 https://github.com/tsenart/vegeta/blob/master/lib/attack.go#L188

then recompile Vegeta :)

@deepakdeore2004
Copy link
Author

yeah, for that to work you need to change this line to be -1 instead of 0 https://github.com/tsenart/vegeta/blob/master/lib/attack.go#L188

then recompile Vegeta :)

i see, then its a bug, i will wait for the fix, for now i am good with keepalive :-)

@Choms
Copy link

Choms commented Apr 8, 2024

yea it's a bug, not sure if this project is still active though

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants