Monitor network traffic “during a specific time” in linux

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP








up vote
3
down vote

favorite












I need to measure network usage on a specific interface during a specific time. I'm doing some experiments on an application so I need to know how much data is being passed around on a specific interface. So things go like:



1- start recording network usage
2- start the program
3- end the program
4- stop recording network usage


I know tools like vnstat and nload exist, but they don't seem to have the feature I need










share|improve this question

















  • 1




    Does it matter which application the traffic comes from? If not, there's a plaintext table maintained by the kernel at /proc/net/dev with network stats for each interface including bytes received and transmitted.
    – dsstorefile1
    Mar 4 at 0:52














up vote
3
down vote

favorite












I need to measure network usage on a specific interface during a specific time. I'm doing some experiments on an application so I need to know how much data is being passed around on a specific interface. So things go like:



1- start recording network usage
2- start the program
3- end the program
4- stop recording network usage


I know tools like vnstat and nload exist, but they don't seem to have the feature I need










share|improve this question

















  • 1




    Does it matter which application the traffic comes from? If not, there's a plaintext table maintained by the kernel at /proc/net/dev with network stats for each interface including bytes received and transmitted.
    – dsstorefile1
    Mar 4 at 0:52












up vote
3
down vote

favorite









up vote
3
down vote

favorite











I need to measure network usage on a specific interface during a specific time. I'm doing some experiments on an application so I need to know how much data is being passed around on a specific interface. So things go like:



1- start recording network usage
2- start the program
3- end the program
4- stop recording network usage


I know tools like vnstat and nload exist, but they don't seem to have the feature I need










share|improve this question













I need to measure network usage on a specific interface during a specific time. I'm doing some experiments on an application so I need to know how much data is being passed around on a specific interface. So things go like:



1- start recording network usage
2- start the program
3- end the program
4- stop recording network usage


I know tools like vnstat and nload exist, but they don't seem to have the feature I need







networking






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Mar 4 at 0:48









Manuel

233




233







  • 1




    Does it matter which application the traffic comes from? If not, there's a plaintext table maintained by the kernel at /proc/net/dev with network stats for each interface including bytes received and transmitted.
    – dsstorefile1
    Mar 4 at 0:52












  • 1




    Does it matter which application the traffic comes from? If not, there's a plaintext table maintained by the kernel at /proc/net/dev with network stats for each interface including bytes received and transmitted.
    – dsstorefile1
    Mar 4 at 0:52







1




1




Does it matter which application the traffic comes from? If not, there's a plaintext table maintained by the kernel at /proc/net/dev with network stats for each interface including bytes received and transmitted.
– dsstorefile1
Mar 4 at 0:52




Does it matter which application the traffic comes from? If not, there's a plaintext table maintained by the kernel at /proc/net/dev with network stats for each interface including bytes received and transmitted.
– dsstorefile1
Mar 4 at 0:52










1 Answer
1






active

oldest

votes

















up vote
1
down vote



accepted











vnstat -l does do what you need



Simply open a terminal window and type vnstat -l. Then start your program that consumes network bandwidth. When your program ends return to the terminal window and press Ctrl+C. The terminal will then show time elapsed and network traffic consumed:



$ vnstat -l
Monitoring enp59s0... (press CTRL-C to stop)

rx: 1.74 Mbit/s 149 p/s tx: 32 kbit/s 62 p/s^C


enp59s0 / traffic statistics

rx | tx
--------------------------------------+------------------
bytes 7.40 MiB | 142 KiB
--------------------------------------+------------------
max 1.84 Mbit/s | 35 kbit/s
average 1.68 Mbit/s | 31.53 kbit/s
min 1.51 Mbit/s | 29 kbit/s
--------------------------------------+------------------
packets 5215 | 2187
--------------------------------------+------------------
max 157 p/s | 68 p/s
average 144 p/s | 60 p/s
min 129 p/s | 55 p/s
--------------------------------------+------------------
time 36 seconds





share|improve this answer




















  • Thank you so much. Somehow I managed to miss this, just how I can log it into a file and stop it if I'm doing this in a script? (other than killing it)
    – Manuel
    Mar 4 at 6:12










  • @Manuel If you are calling it in a script then you would use vnstat -q > starttotal at start of your script. Do your processing then use vnstat -q > endtotal. Then parse the two output files to calculate endtotal - starttotal = bytesused.
    – WinEunuuchs2Unix
    Mar 4 at 12:55











Your Answer







StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "89"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: false,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













 

draft saved


draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1011678%2fmonitor-network-traffic-during-a-specific-time-in-linux%23new-answer', 'question_page');

);

Post as a guest






























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
1
down vote



accepted











vnstat -l does do what you need



Simply open a terminal window and type vnstat -l. Then start your program that consumes network bandwidth. When your program ends return to the terminal window and press Ctrl+C. The terminal will then show time elapsed and network traffic consumed:



$ vnstat -l
Monitoring enp59s0... (press CTRL-C to stop)

rx: 1.74 Mbit/s 149 p/s tx: 32 kbit/s 62 p/s^C


enp59s0 / traffic statistics

rx | tx
--------------------------------------+------------------
bytes 7.40 MiB | 142 KiB
--------------------------------------+------------------
max 1.84 Mbit/s | 35 kbit/s
average 1.68 Mbit/s | 31.53 kbit/s
min 1.51 Mbit/s | 29 kbit/s
--------------------------------------+------------------
packets 5215 | 2187
--------------------------------------+------------------
max 157 p/s | 68 p/s
average 144 p/s | 60 p/s
min 129 p/s | 55 p/s
--------------------------------------+------------------
time 36 seconds





share|improve this answer




















  • Thank you so much. Somehow I managed to miss this, just how I can log it into a file and stop it if I'm doing this in a script? (other than killing it)
    – Manuel
    Mar 4 at 6:12










  • @Manuel If you are calling it in a script then you would use vnstat -q > starttotal at start of your script. Do your processing then use vnstat -q > endtotal. Then parse the two output files to calculate endtotal - starttotal = bytesused.
    – WinEunuuchs2Unix
    Mar 4 at 12:55















up vote
1
down vote



accepted











vnstat -l does do what you need



Simply open a terminal window and type vnstat -l. Then start your program that consumes network bandwidth. When your program ends return to the terminal window and press Ctrl+C. The terminal will then show time elapsed and network traffic consumed:



$ vnstat -l
Monitoring enp59s0... (press CTRL-C to stop)

rx: 1.74 Mbit/s 149 p/s tx: 32 kbit/s 62 p/s^C


enp59s0 / traffic statistics

rx | tx
--------------------------------------+------------------
bytes 7.40 MiB | 142 KiB
--------------------------------------+------------------
max 1.84 Mbit/s | 35 kbit/s
average 1.68 Mbit/s | 31.53 kbit/s
min 1.51 Mbit/s | 29 kbit/s
--------------------------------------+------------------
packets 5215 | 2187
--------------------------------------+------------------
max 157 p/s | 68 p/s
average 144 p/s | 60 p/s
min 129 p/s | 55 p/s
--------------------------------------+------------------
time 36 seconds





share|improve this answer




















  • Thank you so much. Somehow I managed to miss this, just how I can log it into a file and stop it if I'm doing this in a script? (other than killing it)
    – Manuel
    Mar 4 at 6:12










  • @Manuel If you are calling it in a script then you would use vnstat -q > starttotal at start of your script. Do your processing then use vnstat -q > endtotal. Then parse the two output files to calculate endtotal - starttotal = bytesused.
    – WinEunuuchs2Unix
    Mar 4 at 12:55













up vote
1
down vote



accepted







up vote
1
down vote



accepted







vnstat -l does do what you need



Simply open a terminal window and type vnstat -l. Then start your program that consumes network bandwidth. When your program ends return to the terminal window and press Ctrl+C. The terminal will then show time elapsed and network traffic consumed:



$ vnstat -l
Monitoring enp59s0... (press CTRL-C to stop)

rx: 1.74 Mbit/s 149 p/s tx: 32 kbit/s 62 p/s^C


enp59s0 / traffic statistics

rx | tx
--------------------------------------+------------------
bytes 7.40 MiB | 142 KiB
--------------------------------------+------------------
max 1.84 Mbit/s | 35 kbit/s
average 1.68 Mbit/s | 31.53 kbit/s
min 1.51 Mbit/s | 29 kbit/s
--------------------------------------+------------------
packets 5215 | 2187
--------------------------------------+------------------
max 157 p/s | 68 p/s
average 144 p/s | 60 p/s
min 129 p/s | 55 p/s
--------------------------------------+------------------
time 36 seconds





share|improve this answer













vnstat -l does do what you need



Simply open a terminal window and type vnstat -l. Then start your program that consumes network bandwidth. When your program ends return to the terminal window and press Ctrl+C. The terminal will then show time elapsed and network traffic consumed:



$ vnstat -l
Monitoring enp59s0... (press CTRL-C to stop)

rx: 1.74 Mbit/s 149 p/s tx: 32 kbit/s 62 p/s^C


enp59s0 / traffic statistics

rx | tx
--------------------------------------+------------------
bytes 7.40 MiB | 142 KiB
--------------------------------------+------------------
max 1.84 Mbit/s | 35 kbit/s
average 1.68 Mbit/s | 31.53 kbit/s
min 1.51 Mbit/s | 29 kbit/s
--------------------------------------+------------------
packets 5215 | 2187
--------------------------------------+------------------
max 157 p/s | 68 p/s
average 144 p/s | 60 p/s
min 129 p/s | 55 p/s
--------------------------------------+------------------
time 36 seconds






share|improve this answer












share|improve this answer



share|improve this answer










answered Mar 4 at 3:03









WinEunuuchs2Unix

36k759134




36k759134











  • Thank you so much. Somehow I managed to miss this, just how I can log it into a file and stop it if I'm doing this in a script? (other than killing it)
    – Manuel
    Mar 4 at 6:12










  • @Manuel If you are calling it in a script then you would use vnstat -q > starttotal at start of your script. Do your processing then use vnstat -q > endtotal. Then parse the two output files to calculate endtotal - starttotal = bytesused.
    – WinEunuuchs2Unix
    Mar 4 at 12:55

















  • Thank you so much. Somehow I managed to miss this, just how I can log it into a file and stop it if I'm doing this in a script? (other than killing it)
    – Manuel
    Mar 4 at 6:12










  • @Manuel If you are calling it in a script then you would use vnstat -q > starttotal at start of your script. Do your processing then use vnstat -q > endtotal. Then parse the two output files to calculate endtotal - starttotal = bytesused.
    – WinEunuuchs2Unix
    Mar 4 at 12:55
















Thank you so much. Somehow I managed to miss this, just how I can log it into a file and stop it if I'm doing this in a script? (other than killing it)
– Manuel
Mar 4 at 6:12




Thank you so much. Somehow I managed to miss this, just how I can log it into a file and stop it if I'm doing this in a script? (other than killing it)
– Manuel
Mar 4 at 6:12












@Manuel If you are calling it in a script then you would use vnstat -q > starttotal at start of your script. Do your processing then use vnstat -q > endtotal. Then parse the two output files to calculate endtotal - starttotal = bytesused.
– WinEunuuchs2Unix
Mar 4 at 12:55





@Manuel If you are calling it in a script then you would use vnstat -q > starttotal at start of your script. Do your processing then use vnstat -q > endtotal. Then parse the two output files to calculate endtotal - starttotal = bytesused.
– WinEunuuchs2Unix
Mar 4 at 12:55


















 

draft saved


draft discarded















































 


draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1011678%2fmonitor-network-traffic-during-a-specific-time-in-linux%23new-answer', 'question_page');

);

Post as a guest













































































Popular posts from this blog

pylint3 and pip3 broken

Missing snmpget and snmpwalk

How to enroll fingerprints to Ubuntu 17.10 with VFS491