Visit Jeremy's Blog.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 02-02-2014, 07:19 AM   #1
LQ Newbie
Registered: Feb 2013
Posts: 19

Rep: Reputation: Disabled
Network communication by task

Let's say i have PID of task and I want to get all bytes that this process is sending through network.

How to ?
Old 02-02-2014, 08:05 AM   #2
Senior Member
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,707

Rep: Reputation: 1270Reputation: 1270Reputation: 1270Reputation: 1270Reputation: 1270Reputation: 1270Reputation: 1270Reputation: 1270Reputation: 1270
By itself, you can't.

Unless the socket is currently open you won't get anything.

The problem is that looking at such diverse information will not be atomic - the socket indicated by the /proc/<pid>/fd may close before you can look at anything else (as it does for a web browser).

It is actually easier to do a netstat -t (list all tcp open sockets), then search through the list for processes that have those open, and look for your process.

But capturing the data doesn't work... you have to first capture ALL the data, then identify the pid/socket you are interested in, then look through the captured data for that socket.

There could be a better way, but I don't know it offhand...
Old 02-03-2014, 03:42 AM   #3
LQ Guru
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.9, Centos 7.3
Posts: 17,406

Rep: Reputation: 2396Reputation: 2396Reputation: 2396Reputation: 2396Reputation: 2396Reputation: 2396Reputation: 2396Reputation: 2396Reputation: 2396Reputation: 2396Reputation: 2396
netstat -tanp # or uanp for udp
to see what port/host is involved.
Use tcpdump matching on host & port to get the data.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
issues with network communication in kernel aasthakm Linux - Networking 3 03-20-2013 11:18 PM
Fault in KDE processes communication: Could not read network communication list Magnus Johansson MEPIS 0 03-30-2008 12:50 PM
Network Communication between two systems. ramaprasad.royal Linux - Networking 1 02-29-2008 12:52 AM
Network Communication Issues! jlea9378 Linux - Networking 1 12-11-2007 10:47 AM
another hard network task bigmoe Linux - Networking 3 05-08-2006 09:52 AM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 05:49 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration