LinuxQuestions.org
Latest LQ Deal: Linux Power User Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
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!

Notices


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

Rep: Reputation: Disabled
Network communication by task


Hi,
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, 09:05 AM   #2
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,604

Rep: Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241
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, 04:42 AM   #3
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.8, Centos 5.10
Posts: 17,240

Rep: Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324
Use
Code:
netstat -tanp # or uanp for udp
to see what port/host is involved.
Use tcpdump http://www.wains.be/pub/networking/t...ed_filters.txt matching on host & port to get the data.
 
  


Reply


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-21-2013 12:18 AM
Fault in KDE processes communication: Could not read network communication list Magnus Johansson MEPIS 0 03-30-2008 01:50 PM
Network Communication between two systems. ramaprasad.royal Linux - Networking 1 02-29-2008 01:52 AM
Network Communication Issues! jlea9378 Linux - Networking 1 12-11-2007 11:47 AM
another hard network task bigmoe Linux - Networking 3 05-08-2006 10:52 AM


All times are GMT -5. The time now is 12:35 PM.

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