C Board  

Go Back   C Board > Platform Specific Boards > Linux Programming

Reply
 
LinkBack Thread Tools Display Modes
Old 09-03-2009, 01:28 PM   #1
Registered User
 
Join Date: Jul 2009
Posts: 57
Question Network Interface Card Traffic

Hi,
I want to get send/receive of my PC NICs in Linux?! For windows I can use "GetIfTable" and process the output. And about linux?! UI have to install some software ?!

Thanks everyone
hosseinyounesi is offline   Reply With Quote
Old 09-03-2009, 02:33 PM   #2
Jaxom's & Imriel's Dad
 
Kennedy's Avatar
 
Join Date: Aug 2006
Location: Alabama
Posts: 801
Translating. . .
Quote:
Originally Posted by hosseinyounesi
How do I get my IP addresses on all of my network cards in Linux?
Easy, at the command prompt type:
Code:
ifconfig
In windows you can do about the same thing from the cmd prompt (Start->run-> Then type cmd and click okay)
Code:
ipconfig /all
If this ain't wha'jer lookin fer, I ain't got no clue.
Kennedy is offline   Reply With Quote
Old 09-03-2009, 02:44 PM   #3
Registered User
 
Join Date: Jul 2009
Posts: 57
Thanks,
I have to use a program to do that!!! What is "ifstat" ?!
hosseinyounesi is offline   Reply With Quote
Old 09-03-2009, 03:54 PM   #4
Jaxom's & Imriel's Dad
 
Kennedy's Avatar
 
Join Date: Aug 2006
Location: Alabama
Posts: 801
EDIT: What do you mean you have to use a program to do that???? ifconfig IS a program.


Code:
        fd = socket(AF_INET, SOCK_DGRAM, 0);
        strcpy(ifr.ifr_name, devname);
        ifr.ifr_addr.sa_family = AF_INET;
        ioctl(fd, SIOCGIFADDR, &ifr);
        sin = (struct sockaddr_in *) &ifr.ifr_addr;
I dug this out of the vault.

You'll have to figure it out from there.
Kennedy is offline   Reply With Quote
Old 09-03-2009, 05:04 PM   #5
Registered User
 
Join Date: Jul 2009
Posts: 57
Thanks,
I mean that I have to write a software and I need to get nic traffic!!! Clear?
But what the code you've written is ?!!!!
hosseinyounesi is offline   Reply With Quote
Old 09-03-2009, 05:20 PM   #6
and the Hat of Guessing
 
tabstop's Avatar
 
Join Date: Nov 2007
Posts: 8,740
Quote:
Originally Posted by hosseinyounesi View Post
Thanks,
I have to use a program to do that!!! What is "ifstat" ?!
Why not ask man?
Quote:
Originally Posted by hosseinyounesi View Post
Thanks,
I mean that I have to write a software and I need to get nic traffic!!! Clear?
No. Do you need to actually talk to the nic yourself, or are you just interested in using the network? (Maybe I'm just out of the loop, but I don't associate "traffic" with "writing a driver to talk to a piece of hardware".)
tabstop is offline   Reply With Quote
Old 09-03-2009, 05:23 PM   #7
Registered User
 
Join Date: Jul 2009
Posts: 57
I need the send/receive of each interfaces
hosseinyounesi is offline   Reply With Quote
Old 09-03-2009, 08:28 PM   #8
Jaxom's & Imriel's Dad
 
Kennedy's Avatar
 
Join Date: Aug 2006
Location: Alabama
Posts: 801
Your English is not that good, or you just don't know how to express yourself. The bottom line is it is NOT clear what you are asking for.

If you need to get all network packets, you don't have to write software to do that. It is available in the Linux kernel. You'll have to configure network packet filter (iptables) and write rules that log all network traffic on each network interface.

If you are attempting to tell us that you have some project for school, then at least let us know what your requirements are. Just saying "I need send/receive of each interfaces" is NOT enough information. I can send and receive from each interface with hundreds of tools, Firefox to name one.

What are your requirements and what is your goal? Though English may not be your native language, you could always give us a 1000 word dissertation on the subject (a picture is worth a thousand words).
Kennedy is offline   Reply With Quote
Old 09-04-2009, 09:01 AM   #9
Registered User
 
Join Date: Jul 2009
Posts: 57
Thanks, But I think that you don't understand my question! I said that I've used "GetIfTable" to collect information in windows. I introduced ifstat, ...
By the way, Excuse me if I didn't ask my question clearly
This is not homework I want to use it for my software! I want to collect the send/receive of my COMPUTER (all interfaces) such as what we can see by right clicking on the connection icon in the taskbar of Windows XP I could do this by "GetIfTable" in windows. My question is that how can I do this in Linux? CLEAR? (Tell me If any of sentences is not right)

Thanks again
hosseinyounesi is offline   Reply With Quote
Old 09-04-2009, 09:05 AM   #10
subminimalist
 
MK27's Avatar
 
Join Date: Jul 2008
Location: NYC
Posts: 3,946
So what's wrong with ifconfig, which was suggested in post #2?

Code:
eth0      Link encap:Ethernet  HWaddr 00:E0:4D:89:B5:73  
          inet addr:192.168.1.2  Bcast:192.168.1.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:5792 errors:0 dropped:0 overruns:0 frame:0
          TX packets:6309 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:4451227 (4.2 MiB)  TX bytes:1435602 (1.3 MiB)
          Interrupt:23 Base address:0x8000 

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:354 errors:0 dropped:0 overruns:0 frame:0
          TX packets:354 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:180029 (175.8 KiB)  TX bytes:180029 (175.8 KiB)
I believe RX is short for "received" and TX is short for "transmitted".
__________________

Accuracy and integrity mean nothing if you don't make it past the censors...PYTHAGORAS
MK27 is offline   Reply With Quote
Old 09-04-2009, 03:55 PM   #11
Registered User
 
Join Date: Jul 2009
Posts: 57
yes, but isn't there any function or library that can be used in C or C++ ?!
hosseinyounesi is offline   Reply With Quote
Old 09-04-2009, 04:04 PM   #12
subminimalist
 
MK27's Avatar
 
Join Date: Jul 2008
Location: NYC
Posts: 3,946
Quote:
Originally Posted by hosseinyounesi View Post
yes, but isn't there any function or library that can be used in C or C++ ?!
I think pcap() will provide you with that info too, but really I look at that and see that it will take about 10 lines of code to parse, so why bother using a library?

There are probably a cazillion little GUI apps around for this stuff, eg, it is one thing that the incredibly awesome gkrellm covers, if you learn to use one of those new "search engines" everyone talks about, such as "google.com" you might find something...
__________________

Accuracy and integrity mean nothing if you don't make it past the censors...PYTHAGORAS
MK27 is offline   Reply With Quote
Old 09-04-2009, 04:06 PM   #13
and the Hat of Guessing
 
tabstop's Avatar
 
Join Date: Nov 2007
Posts: 8,740
So I went here, clicked on section 3 of the manual which is where the library functions are, then scrolled down to I and looked for things that started with if. Some of them look like what you want.
tabstop is offline   Reply With Quote
Old 09-04-2009, 04:10 PM   #14
subminimalist
 
MK27's Avatar
 
Join Date: Jul 2008
Location: NYC
Posts: 3,946
Quote:
Originally Posted by tabstop View Post
So I went here, clicked on section 3 of the manual which is where the library functions are, then scrolled down to I and looked for things that started with if. Some of them look like what you want.
Yes, if you are using a web browser "ctrl-f" will help. Research is just like coding, the more you do it, the easier it gets.
__________________

Accuracy and integrity mean nothing if you don't make it past the censors...PYTHAGORAS
MK27 is offline   Reply With Quote
Old 09-05-2009, 02:42 PM   #15
Registered User
 
Join Date: Jul 2009
Posts: 57
I know what is "google" !!!!!! I hope that you are joking I just thought that maybe someone has did this before
I will report my attempt here about libpcap and ifstat or ...

Thanks again
hosseinyounesi is offline   Reply With Quote
Reply

Tags
card, interface, network, traffic

Thread Tools
Display Modes

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Bitwise Unwanted Output pobri19 C++ Programming 4 09-15-2008 04:07 AM
Vector out of range program crash. Shamino C++ Programming 11 01-18-2008 05:37 PM
Segmentation Fault - aaaaaaaah! yogibear C Programming 6 10-01-2007 03:21 AM
Blackjack Tommo C Programming 10 06-20-2007 08:07 PM
How can I access a struct (from a header file)? loxslay C++ Programming 3 10-07-2006 01:25 PM


All times are GMT -6. The time now is 09:31 AM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.0 RC2

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22