wireguard.lists.zx2c4.com archive mirror
 help / color / mirror / Atom feed
* Netstat bytes count doesn't match with Wireguard
@ 2021-09-14 20:53 Manikandan Thiagarajan
  2021-09-15  7:31 ` Aaron Jones
  0 siblings, 1 reply; 2+ messages in thread
From: Manikandan Thiagarajan @ 2021-09-14 20:53 UTC (permalink / raw)
  To: wireguard

Hi,

I use the Wireguard Go C API to integrate with my packet tunnel network extension to forward traffic to the WG tunnel on Mac OS. I also use the wgGetConfig() API to get tunnel status information.

During my testing, I noticed some differences between what the netstat -ib reports and what Wireguard reports as rx and tx bytes. Usually the Wireguard numbers are higher than netstat numbers.

Is it normal to see so much difference? Can you be able to provide me some information or point me to a doc on how Wireguard calculates the tx/rx bytes?


Netstat -ib output:
Name  Mtu   Network       Address            Ipkts Ierrs     Ibytes    Opkts Oerrs     Obytes  Coll
utun2 1420  <Link#23>                          130     0      42713      180     0      15245     0
utun2 1420  100.101.113.5 100.101.113.54       130     -      42713      180     -      15245     -

Wireguard output:
last_handshake_time_sec=1631646164
last_handshake_time_nsec=79839000
tx_bytes=21328
rx_bytes=47980
persistent_keepalive_interval=0
allowed_ip=155.2.135.28/32
allowed_ip=192.168.128.4/32

Thanks,
Mani

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Netstat bytes count doesn't match with Wireguard
  2021-09-14 20:53 Netstat bytes count doesn't match with Wireguard Manikandan Thiagarajan
@ 2021-09-15  7:31 ` Aaron Jones
  0 siblings, 0 replies; 2+ messages in thread
From: Aaron Jones @ 2021-09-15  7:31 UTC (permalink / raw)
  To: WireGuard mailing list; +Cc: Manikandan Thiagarajan


[-- Attachment #1.1: Type: text/plain, Size: 606 bytes --]

Hello.

Netstat is only counting traffic sent or received on the interface; e.g.
the tunnelled bytes themselves, as it should. WireGuard however is
counting that, plus all of the encapsulation overhead (header, MAC,
etc), plus packets not sending or receiving tunnelled data (for example,
keep-alives and periodic re-handshaking), plus periodic response packets
when traffic is only flowing one way (common if you run unidirectional
protocols over it; for example, UDP video streaming).

These extra packets are documented in the WireGuard whitepaper on the
website.

Regards,
Aaron Jones


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-09-15  7:31 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-14 20:53 Netstat bytes count doesn't match with Wireguard Manikandan Thiagarajan
2021-09-15  7:31 ` Aaron Jones

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).