https://github.com/mauricioabreu/tcp_nodelay_demo
Using the TCP_NODELAY flag
https://github.com/mauricioabreu/tcp_nodelay_demo
Last synced: about 1 month ago
JSON representation
Using the TCP_NODELAY flag
- Host: GitHub
- URL: https://github.com/mauricioabreu/tcp_nodelay_demo
- Owner: mauricioabreu
- Created: 2022-11-25T12:21:01.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2023-06-20T22:52:17.000Z (almost 2 years ago)
- Last Synced: 2025-02-01T03:17:43.534Z (3 months ago)
- Language: Go
- Size: 2.93 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.org
Awesome Lists containing this project
README
* TCP_NODELAY demo
This repository contains pratical examples [[https://www.samambaia.dev/network/tcp-nodelay/][for one of my notes about TCP]]
** Running
We need the go compiler installed.
First we can start the server:
~go run server/main.go~
Before running the client, we need to start inspecting TCP packets. For this task we can use the /tcpdump/ tool
~sudo tcpdump -X -i lo0 'port 8080'~
About the TCP flags:
- -X -> print the data of the packet
- -i -> network interface to be inspected (/lo/)
- 'port 8000' is server port we connectChoose the appropriate network interface for your operating system.
And finally, we run the client:
~go run client/main.go~
Save the /tcpdump/ output.
Re-run the program but this time set ~conn.SetNoDelay(false)~ to /true/, like this
~conn.SetNoDelay(true)~
Save the /tcpump/ output again.
** Checking the output
Now it is time to compare the outputs. Write down the differences you can see. What did you notice?
When ~SetNoDelay~ is /true/ it sends the data everytime you write bytes in the connection.
When it is /false/ the program sends the word /test/ multiple times because it buffered the data before flushing.