Results 1 to 2 of 2

Thread: Portable library for custom frames?

  1. #1
    Very good friend of the forum Virchanza's Avatar
    Join Date
    Jan 2010

    Default Portable library for custom frames?

    At the moment I'm using the Berkeley Sockets API for sending custom Ethernet frames (i.e. frames that I design entirely by myself starting with the Ethernet header).

    I start off with the Ethernet header and go from there, e.g.:

    uint8 frame[] =
          /* Offset 0 : Beginning of Ethernet frame */
          0x00,0x03,0x6f,0x23,0x25,0x4a,  /* Destination MAC */
          0x00,0x40,0x12,0x1b,0x77,0x36,  /* Source  MAC */
                              0x08,0x00,  /* Protocol == IP */
          /* Offset 14 : Beginning of IP packet */
          0x45,        /* IP Version and header length */
          0x00,        /* TOS */
          0x00,0x3c,   /* Total Length */
          0x00,0x00,   /* Identification */
          0x40,0x00,   /* Flags and Fragment Offset */
          0x40,        /* Time To Live */
          0x11,        /* Transport Layer Protocol == UDP */
          0,0,         /* IP Header Checksum */
          192,168,0,55,     /* Source IP */
          208,67,222,222,     /* Destination IP */
          /* Offset 34 : Beginning of UDP segment */
          0x80,0x01,   /* Source port */
          0x00,0x35,   /* Destination port */
          ... and so forth ...
    I'd like to hear people's opinions as to what's the best library to use for sending custom frames (I think some people refer to the sending of custom frames as "raw sockets")?

    I know that the Berkeley Sockets API is pretty ubiquitous, and it's also implemented (with a few minor changes) in Windows as "Winsock". I've heard of other libraries though such as pcap, so I'm curious as to which is the best one?

    I would like for my program to be able to run on Linux, Windows, Mac, Solaris, and if possible, game consoles such as XBox360, Playstation 3.

    A good example of a program that does the kind of stuff I need to do is "netdiscover", which sends out custom frames in the form of ARP requests, and then also listens for ARP replies. I have the source code for netdiscover and I've had a look over it, but I'm wondering if I'd be better off using the Berkeley Sockets API if I want my program to be as portable as possible?

  2. #2
    Junior Member SBerry's Avatar
    Join Date
    Dec 2007


    As you mentioned pcap. You have a choice here of using libpcap and the port winpcap(Windows). With both these you can send arp packets.

    You should have a look at libnet
    Libnet will also let you accomplish this.

    Also with you raw sockets you can send arp packets

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts