Wireless networking using sockets :Help !

Discussion in 'Linux Networking' started by devesh, Jan 10, 2005.

  1. devesh

    devesh Guest

    I am a newbie to writing networking programs over wireless. Firstly I
    am not sure if this is the appropriate group to post this , my
    apologies , can someone guide to appropriate groups which cover
    wireless using sockets ? .
    Basically what I have to do is this : given a ip address , I wish to
    send a ip packet to it.For this I have a raw socket with IP_HDRINCL and
    SO_BROADCAST set , and then to send I just use sendto specifying the ip
    However I am puzzled where does the ip-mac translation come in , is
    there something similar like arp in 802.11b ? Or is the packet just
    send on a broadcast mac address and each node works in promiscuous mode
    and then filters at the ip layer , based on the ip address.
    Devesh Agrawal.
    devesh DOT agrawal AT gmail DOT com
    (You are welcome to send your replies via email)
    devesh, Jan 10, 2005
    1. Advertisements

  2. When you program using TCP/IP sockets, the the media type is not
    normally an issue. As far as applications are concerned, there's no
    difference between Ethernet, WiFi, dialup, etc. You just send to an IP
    address and the network stack takes care of the rest.
    Why do you need to use a raw socket instead of an ordinary TCP or UDP
    802.11b/g uses ARP just like Ethernet.
    Barry Margolin, Jan 10, 2005
    1. Advertisements

  3. devesh

    devesh Guest

    Thanks for replying to my post .
    Plz let me be more clear about my problem :
    I am working on someone's code which basically is an implementation of
    source routing using a custom IP option. I have a socket on which I
    need to send an IP packet in nodes with wireless card's configured in
    adhoc mode, which I assemble with the destIp as the next hop's IP,
    which I get from the incoming IP packet (normal source routing) .
    On this socket I just use sendto(sockfd,rawIpPacket) . Now my question
    is : 1) Where does the ip to mac translation occur ? , for it to
    occur obviously neighbour info will have to be maintained (cached) or
    something like a arp request will have to be send (bcast), with that
    neighbour replying with its mac address , and then the device shall
    just forward the packet to that particular node.
    2)Or will this packet be simply mac broadcasted ? , where in my code
    does the ip level filtering (ie accept packets only whose destIp
    matches my own).
    I am using the ornico wlan device driver in linux . Is this arp called
    by a different name in 802.11b ? , (I wasn't able to find something
    like a arp request in the driver source code.).
    Thanks a lot in advance ...
    Devesh Agrawal
    devesh, Jan 10, 2005
  4. devesh

    manugarg Guest

    ARP in 802.11 works exactly same way as in ethernet. When the system
    gets (before driver) the packet, it tries to determine the
    corresponding address before giving the packet to device. For that, it
    sends an ARP broadcast request looking for MAC address corresponding to
    IP address. Of course this request goes through your wl card. After
    getting ARP reply, your system updates the packet with MAC address and
    gives it to your card.

    Device driver just handles frames. It doesn't have any protocol code
    inside it. So don't look there. You'll find that code in protocol

    Hope it clears your doubt.
    manugarg, Jan 10, 2005
  5. No the packet is sent directly to the client, none of the other clients can
    pick it up. Smartass.

    Obviously it's broadcast and when a client adapter is "connected" to an AP,
    it only translates packets marked with it's MAC address. Promisc mode simply
    means it's not filtering. Get some sleep brah.

    Arp is a tcp-ip thing. 802.11 is what it's encapsulated in, with it's own
    packet overheads, nothing like ethernet, yet totally transparent to most
    programming interfaces. Unless you're writing a radio scanner and
    communicating directly with the hardware/NDIS/Prism interfaces.

    AM I Not right, you Wi Fi Geniuses?!
    Coenraad Loubser, Jan 13, 2005
  6. I'm afraid I'm not able to help on the problem the thread-originator is
    having but you seem to be a knowledgeable bunch (which is a rare thing
    on Linux help-groups) and I hope you won't mind my picking your (WIFI)
    brains, for I'm having a networking problem of my own. (It may not be
    entirely separate from the aforementioned problems. We'll see).

    The Problem:
    I have LAN access but cannot access any remote (WAN) host (or website).

    What I CAN do:
    a) Able to ping router on
    b) Able to ping colleague's PC
    c) Able to configure router using web interface on fine.

    What I CANNOT do:
    http://www.google.co.uk (Error = "www.google.co.uk could not be found.
    Please check the name and try again.")

    Linux Suse 9.2

    Belkin ADSL Modem with Built-in Wireless Router
    Model: F5D7630-4A (ver 1212uk)

    D-Link DWL-610 Wireless PCMCIA Card
    Driver: DriverLoader

    DHCP Enabled
    Channel 11
    IP Forwarding ON
    128 bit WEP (enabled) HEX
    ESSID belkin54g

    Failed attempts:
    X) I've disabled the firewall.
    X) I've disabled WEP.
    x) I've upgraded router's firmware.
    x) Various command-line utilities (see below)

    (Console Output):


    (Using DNS)
    localhost:~# traceroute www.google.co.uk <return>
    www.google.co.uk: Temporary failure in name resolution

    (Using IP Address)
    localhost:~# traceroute <return>
    traceroute to (, 30 hops max, 40 byte packets
    Unable to connect to Network is unreachable

    localhost:~# iwconfig <return>

    wlan0 IEEE 802.11-DS ESSID:"belkin54g" Nickname:"atlantis"
    Mode:Managed Frequency:2.462 GHz Access Point:
    Bit Rate=11 Mb/s Tx-Power=20 dBm
    RTS thr:eek:ff Fragment thr:eek:ff
    Encryption key:<KEY> Security mode:restricted
    Power Management:eek:ff
    Link Quality:35/94 Signal level:-51 dBm Noise level:-154
    Rx invalid nwid:0 Rx invalid crypt:0 Rx invalid frag:0
    Tx excessive retries:0 Invalid misc:0 Missed beacon:0

    localhost:~# ifconfig <return>

    wlan0 Link encap:Ethernet HWaddr 00:12:66:58:23:1C
    inet addr: Bcast:
    inet6 addr: fe80::20d:88ff:fe58:531c/64 Scope:Link
    RX packets:530 errors:0 dropped:0 overruns:0 frame:0
    TX packets:590 errors:0 dropped:0 overruns:0 carrier:0
    collisions:0 txqueuelen:1000
    RX bytes:195057 (190.4 Kb) TX bytes:56885 (55.5 Kb)

    localhost:~# ifup wlan0 <return>

    wlan0 device: D-Link System Inc DWL-510 2.4GHz Wireless PCI Adapter
    (rev 20)
    wlan0 configuration: wlan-id-00:12:66:58:23:1C
    Starting DHCP Client Daemon on wlan0... . IP/Netmask: /

    Contents of /etc/resolv.conf (actual IP addresses are of course
    search home
    godffreypratt, Jan 13, 2005
  7. devesh

    manu Guest

    godffreypr..., Can you post the output of 'netstat -rn' or 'route'?
    Seems like your gateway is not getting configured properly. Also, check
    the status of WAN link from web interface of the router

    Coenraad, you need to get some rest/medicine. you sound insane :)

    manu, Jan 14, 2005
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.