Solved

how to write to and read from the ethernet card directly?

Posted on 1997-07-11
2
191 Views
Last Modified: 2006-11-17
Hi,

    I am doing a series of experiments about network lantency under  
    Linux. I try to write to and read from the ethernet card
    directly.

    However, because ethernet device is dynamically detected by
    Linux, that means there is no device named ether0 under /dev.
    (like /dev/ether0 in HP-UX ), I can't use open("/dev/ether0",..)
    to create a file handler like what I did under HP-UX.
   
     My problem is that how to access to such a device (eth0)
     under Linux.

     Is there anyone who knows how to do? Thanks.



   Shih-wei Li       sli@cis.ohio-state.edu


    ====================================
    System : Redhat 4.0, kernel 2.0.30
    Ethernet Card:  3Com 3c905 Boomerang 100bassTx
   
   
    --- message when booting -----
    eth0: 3Com 3c905 Boomerang 100baseTx at 0xef00,  
    00:60:97:d4:09:25, IRQ 10
    8K word-wide RAM 3:5 Rx:Tx split, autoselect/MII interface.
    Rx Pacing bug exists, disabling bus-master receives.
0
Comment
Question by:shihwei
2 Comments
 

Expert Comment

by:unitymtg
ID: 1585418
You have to use the streams interface I belive.  As to how to do that, I don't know.
0
 
LVL 1

Accepted Solution

by:
jantypas earned 50 total points
ID: 1585419
Actually, to the previous answer, Linux doesn't have STREAMS.  AT&T would want too much money for that...

Basically, UNIX ethernet drivers are not character devices ala /dev/cua0.  They are packet devices.  In most systems, there is something called a Link Level Control (LLC) interface.  Typically, it works as follows:

- Open a socket(SOCK_RAW...)
   This gives you a handle to the IP layer

- Throw an ioctl to the socket handle to ask what
  ethernet device is bound to that socket.  You'll get
  back eth0.  It doesn't really matter though, that socket
  is now used in sending RAW IP frames in and out.

- If you really need 802.2 ethernet frames, no IP even,
  use the handle information returned in the above call
  to get the device switch ID (cdevsw) of the device from
  the kernel and then use the LLC calls to read/write
  from raw ethernet.
0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I have seen several blogs and forum entries elsewhere state that because NTFS volumes do not support linux ownership or permissions, they cannot be used for anonymous ftp upload through the vsftpd program.   IT can be done and here's how to get i…
Note: for this to work properly you need to use a Cross-Over network cable. 1. Connect both servers S1 and S2 on the second network slots respectively. Note that you can use the 1st slots but usually these would be occupied by the Service Provide…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question