I am trying to write a congestion control algorithm (like TCP cubic, reno) in net/ipv4/ folder. For that, I want to use the established TCP connection port number in the code. How to get a port number from any linux kernel files for the code.

1 Answer 1


Use htons((unsigned short int)inet_sk(sk)->inet_sport) and htons((unsigned short int)inet_sk(sk)->inet_dport) to get ports as per Wireshark port.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .