-
Notifications
You must be signed in to change notification settings - Fork 861
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Patch] Bandwidth Utilization Patch. #202
Comments
Submitted by guy_harris Logged In: YES "-M", in the current top-of-tree CVS version of tcpdump, is used to |
Contents of the original patch is below: *** tcpdump-3.8.3/tcpdump.c 2004-03-17 14:47:48.000000000 -0500
--- tcpdump-3.8.3-mark/tcpdump.c 2004-09-29 19:34:18.000000000 -0400
***************
*** 74,79 ****
--- 74,80 ----
int fflag; /* don't translate "foreign" IP address */
int Lflag; /* list available data link types and exit */
int nflag; /* leave addresses as numbers */
+ int Mflag; /* see bandwidth stats */
int Nflag; /* remove domains from printed host names */
int Oflag = 1; /* run filter code optimizer */
int pflag; /* don't go promiscuous */
***************
*** 104,109 ****
--- 105,111 ----
int32_t thiszone; /* seconds offset from gmt to local time */
+ time_t bw_gtime; /* global time for bandwidth stats */
/* Forwards */
static RETSIGTYPE cleanup(int);
static void usage(void) __attribute__((noreturn));
***************
*** 119,124 ****
--- 121,127 ----
static void info(int);
static u_int packets_captured;
+ static u_int bytes_captured;
/* Length of saved portion of packet. */
int snaplen = DEFAULT_SNAPLEN;
***************
*** 346,352 ****
opterr = 0;
while (
! (op = getopt(argc, argv, "aA" B_FLAG "c:C:d" D_FLAG "eE:fF:i:lLm:nNOpqr:Rs:StT:u" U_FLAG "vw:xXy:Y")) != -1)
switch (op) {
case 'a':
--- 349,355 ----
opterr = 0;
while (
! (op = getopt(argc, argv, "aA" B_FLAG "c:C:d" D_FLAG "eE:fF:i:lLMm:nNOpqr:Rs:StT:u" U_FLAG "vw:xXy:Y")) != -1)
switch (op) {
case 'a':
***************
*** 499,504 ****
--- 502,511 ----
#endif
break;
+ case 'M':
+ Mflag = 1;
+ time(&bw_gtime);
+ break;
case 'O':
Oflag = 0;
break;
***************
*** 1000,1005 ****
--- 1007,1032 ----
++packets_captured;
++infodelay;
+
+ if(Mflag)
+ {
+ time_t bw_curtime;
+
+ bytes_captured += h->len;
+
+ time(&bw_curtime);
+ if((bw_curtime-bw_gtime) >= 1)
+ {
+ int Kbps = bytes_captured*8/1024;
+ int Mbps = Kbps/1048576;
+ ts_print(&h->ts);
+ printf("Bandwidth: %10dBytes/s | %8dKbps | %6dMbps\n",bytes_captured,Kbps,Mbps);
+ time(&bw_gtime);
+ packets_captured=0;
+ }
+ return;
+ }
+
ts_print(&h->ts);
print_info = (struct print_info *)user; |
I had briefly looked into this and could note the following:
|
So I understand that this calculates bandwidth based upon pcap time stamps and packet sizes. That's kinda interesting. |
This feature is very close to what |
Converted from SourceForge issue 1037376, submitted by ellzey
A very simple patch that add's a -M flag to see the
current bandwidth in bps/Kbps/Mbps.
The text was updated successfully, but these errors were encountered: