Using strace for troubleshoot an UDP port issue

Issue description:

One of my program(A) got binded with an UDP port (20500) which should be assigned to another program(B), here are the steps for trace down where A binded this port:

1. start the process with strace log:
strace -f -s 128 -o proxy.strace ./pxyserverapp_redhat

2. Find out the PID of the process, also check whether the port was taken.
netstat -anp | grep pxy

3. show socket handle list created by this process
cd /proc/28803/fd

4. show process status
cat /proc/28803/status

5. convert port: ntohs(20500) = 5012
cat /proc/net/udp |grep “5014”

6. check the strace log file, and search with keyword 20500:
less proxy.strace


7. Filter the systemcall log list
As you can see, call history list below are relevant:

28803 socket(PF_INET, SOCK_DGRAM, IPPROTO_IP) = 26
28803 bind(26, {sa_family=AF_INET, sin_port=htons(20500), sin_addr=inet_addr(“”)}, 16) = 0

28803 select(26, [24 25], [], NULL, {0, 10000} <unfinished …>

8. Check your codes
Then check the codes to see whether there are implements like that(Still under investigation).


Leave a comment

Your email address will not be published. Required fields are marked *