Thread: 802.11 vs 802.3 programming confusion

  1. #1
    Registered User
    Join Date
    Nov 2008
    Posts
    3

    802.11 vs 802.3 programming confusion

    Hello everyone,

    I've just started to learn about how wireless network operates, and specifically 802.11 standard. I then thought about how the Linux works it out. In particular, normally when I want to send a ethernet frame over wired network, I use SOCK_RAW and "fill in the form", after which send() is invoked to write those bytes to the NIC.

    However, wouldn't it be a problem with 802.11, since the frame header is of different form than Ethernet? How is it resolved then, or does the OS/wireless card do the transformation for me? Woudn't this be a problem with all applications that assumes Ethernet to be Data Link protocol?

    Almost the same issue, but expressed differently: I've got a WinXP laptop, with Wireshark installed. The wireless card is Atheros something. When I try to sniff some packets from this interface, they turned out to be of Ethernet, so I'm totally lost on where the transformation happens.

    Any experience? And thanks in advance.

    Regards,

    SG.

  2. #2
    Resu Deretsiger Nightowl's Avatar
    Join Date
    Nov 2008
    Location
    /dev/null
    Posts
    186
    AFAIK, there's no difference in Linux between a wireless interface and a wired interface. Only difference is that you plug in the cord via iwconfig and finding a WAP . . .

    Windows, I have no idea. Can't imagine it would be any different, though.

  3. #3
    Registered User
    Join Date
    Nov 2008
    Posts
    3
    I don't really understand your argument. I thought, in case of a wired interface, what the OS can read in from the interface will be 802.3 frames, whereas in the case of a wireless interface, what the OS can read in will be 802.11 frames, and they are of different formats.

    Should this cause a problem in programming point of view, as some network applications may expect to receive and send only 802.3 frames? Otherwise I suppose there must be a process stood in the mid-way (either in the card itself, or in the OS device driver) that does the transformation.

    If that is the case, I wonder what principles they used to write program to break WEP and WPA such as Aircrack, etc.

  4. #4
    Malum in se abachler's Avatar
    Join Date
    Apr 2007
    Posts
    3,195
    From a programmign point fo view, an 802.11 and an 802.3 network are logically equivelant. The differences are beneaththe API level in teh drivers adn hardware. From yoru applications poitn fo view they are (mostly) the same, although you may have to write some code to handle the potentially less reliable wireless network.

  5. #5
    Resu Deretsiger Nightowl's Avatar
    Join Date
    Nov 2008
    Location
    /dev/null
    Posts
    186
    What abachler says is correct, to the best of my knowledge.

    There's no difference in programming between 802.11 and 802.3. Aircrack and such use wireless monitoring mode, which is kinda different in this case. It interfaces directly with the kernel driver (I think it may use HAL, not certain.) and asks it to go into monitoring mode, from which it records the packets on that channel.

    Completely different application.

  6. #6
    Registered User
    Join Date
    Nov 2008
    Posts
    3
    abachler and Nightowl, thanks a lot for your explanation. You said the programming is the same for 802.11 and 802.3, so if I want to send a frame of my choice, should I just stick to the Ethernet (802.3) header format? If so, what if I want to create a 802.11 frame of my own to send it over the wireless medium, would it be possible?

    Million thanks anyway for such efforts.

    SG.

  7. #7
    Resu Deretsiger Nightowl's Avatar
    Join Date
    Nov 2008
    Location
    /dev/null
    Posts
    186
    If you are working at the frame level . . . well, that could be different. I'm not sure, I've never gone beyond level 7 on the OSI model.

    But, as I said before, if you are simply using the standard UNIX socket library, there's absolutely no difference between 802.11 and 802.3.
    Do as I say, not as I do . . .

    Experimentation is the essence of programming. Just remember to make a backup first.

    "I'm a firm believer that <SomeGod> gave us two ears and one mouth for a reason - we are supposed to listen, twice as much as we talk." - LEAF

    Questions posted by these guidelines are more likely to be answered.

    Debian GNU/Linux user, with the awesome window manager, the git version control system, and the cmake buildsystem generator.

  8. #8
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Quote Originally Posted by StarGhost View Post
    abachler and Nightowl, thanks a lot for your explanation. You said the programming is the same for 802.11 and 802.3, so if I want to send a frame of my choice, should I just stick to the Ethernet (802.3) header format? If so, what if I want to create a 802.11 frame of my own to send it over the wireless medium, would it be possible?

    Million thanks anyway for such efforts.

    SG.
    I'm fairly sure that even the low-lever driver is unaware of the difference in the actual transmission protocol. For all intents and purposes from a SOFTWARE perspective, they are identical.

    Yes, of course, the data transmitted over the radio-frequency is slightly different from what is transmitted over the wire. But that should not make any difference to the software in an applicaiton at the very least, and the driver is, as far as I understand, only different in the way that it actually sets up the physical interface itself (e.g. selecting a radio frequency).

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  9. #9
    Registered User
    Join Date
    Dec 2009
    Posts
    2
    Hi star ghost,

    have you found out the answer?

    well, i am also facing the same problem...

    I wanna send 'layer-2' frames using raw sockets from one node (sta) to another node (ap)...

    Can you/anybody provide me 'quickstart guide' or good study material for this?

  10. #10
    Malum in se abachler's Avatar
    Join Date
    Apr 2007
    Posts
    3,195
    There is no way for an application to reliably tell. Nor is there any need. The differences are all at or below the data link layer (2), which is well below anything even the driver would be aware of. The driver itself wouldn't need to know anything below the network layer (3) and usually nothing below the transport layer (4). Your application on the other hand is dealing with things at layers 5-7.
    Last edited by abachler; 12-02-2009 at 10:52 AM.

  11. #11
    Carnivore ('-'v) Hunter2's Avatar
    Join Date
    May 2002
    Posts
    2,879
    The driver itself wouldn't need to know anything below the network layer (3)
    Abachler, IIRC raw sockets on unix allow you access to the ethernet frame level, e.g. before even the MAC address is put on the packet. Wouldn't that indicate level-2 access? This seems suspect, because I would expect level-2 access to be reserved to device drivers, unless of course these drivers expose a pseudo-level2 API to user-space applications, which abstracts away some level of the hardware-specific protocol but still allows control over some aspects of the level-2 protocol that tend to be common between multiple hardware mediums. On the other hand, the raw sockets I've worked with may or may not have been on a platform with a kernel modified in that area, so I'm not sure if this is generally how raw sockets behave, or only in this specific system...

    *shrug* I'm still trying to figure this stuff out myself, since I'm working at interfacing to a custom ethernet peripheral that I'm designing (and nothing's working yet).

    @jnaneshvb: Look into the pcap library, or if you're on Windows, WinPCap. Not sure if that goes as low as you want, but it's the lowest level I know how to get access to.
    Last edited by Hunter2; 12-02-2009 at 12:06 PM.
    Just Google It. √

    (\ /)
    ( . .)
    c(")(") This is bunny. Copy and paste bunny into your signature to help him gain world domination.

  12. #12
    Malum in se abachler's Avatar
    Join Date
    Apr 2007
    Posts
    3,195
    No, Ethernet frames are level 4.

    I'm using ISBN 0-13-219999-8 pp 106-107 as a reference.
    Last edited by abachler; 12-02-2009 at 12:27 PM.

  13. #13
    Officially An Architect brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,396
    Sending and receiving raw Ethernet frames to a wireless interface works fine in Linux. I've done it. For all intents and purposes, you can treat it as a wired Ethernet device.

    I do not know if, or what sort of, frame translation occurs, but it works.
    Code:
    //try
    //{
    	if (a) do { f( b); } while(1);
    	else   do { f(!b); } while(1);
    //}

  14. #14
    Ex scientia vera
    Join Date
    Sep 2007
    Posts
    477
    Quote Originally Posted by abachler View Post
    No, Ethernet frames are level 4.

    I'm using ISBN 0-13-219999-8 pp 106-107 as a reference.
    OSI model - Wikipedia, the free encyclopedia

    Unless I'm misunderstanding your post and this thread, it seems you're wrong. Ethernet is in the 'physical layer', which is the topmost layer. There is nothing above it(Or below it, depends on how you look at it).
    "What's up, Doc?"
    "'Up' is a relative concept. It has no intrinsic value."

  15. #15
    Registered User
    Join Date
    Dec 2009
    Posts
    2
    Thanks Brewbuck....
    I observed now properly in wireshark.. and it is working fine... I got amazed by this... I was thinking that there would be special api and library files to do raw socket programming in wireless networks.

    Well, the only problem I see now is: In wireshark, it is showing as malformed packet. I should send a meaningful data now.. and will post it soon....!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Terrible confusion with time variables
    By LowlyIntern in forum C++ Programming
    Replies: 12
    Last Post: 08-01-2008, 07:23 AM
  2. a Bit of confusion (haha - Pun)
    By Junior89 in forum C++ Programming
    Replies: 1
    Last Post: 06-15-2007, 11:22 PM
  3. C++ Classes: Use, Misuse...Confusion.
    By Snorpy_Py in forum C++ Programming
    Replies: 4
    Last Post: 10-23-2006, 01:46 AM
  4. for loop confusion
    By Enges in forum C++ Programming
    Replies: 6
    Last Post: 04-26-2006, 08:21 AM
  5. confusion with increment and decrement operators
    By cBegginer in forum C Programming
    Replies: 6
    Last Post: 03-19-2005, 03:45 PM