Thread: Sending ARP packets

  1. #1
    Registered User
    Join Date
    Jan 2009
    Posts
    103

    Sending ARP packets

    I want to write a program to send a ARP packet. Is there some method where I can load up all the hex as an array and then it just sends it off to a specified IP address? How would I do this? Could someone forward me to a good raw sockets tutorial or just show me how to do this (latter prefered, I learn faster with just code)?


    Thanks

  2. #2
    Registered User slingerland3g's Avatar
    Join Date
    Jan 2008
    Location
    Seattle
    Posts
    603
    Something like this maybe:

    Code:
       fd = socket( AF_PACKET, SOCK_RAW, htons(ETH_P_ARP));
    A simple google search on this brought me to some example using ETH_P_ARP

    ARP-Request!!!!1

  3. #3
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,708
    >> I want to write a program to send a ARP packet. Is there some method where I can load up all the hex as an array and then it just sends it off to a specified IP address? How would I do this? Could someone forward me to a good raw sockets tutorial or just show me how to do this (latter prefered, I learn faster with just code)?

    Do your own research, write some code, and ask *specific* questions pertaining to the problems you encounter. Don't just expect others to hand you everything on a silver platter.
    Code:
    #include <cmath>
    #include <complex>
    bool euler_flip(bool value)
    {
        return std::pow
        (
            std::complex<float>(std::exp(1.0)), 
            std::complex<float>(0, 1) 
            * std::complex<float>(std::atan(1.0)
            *(1 << (value + 2)))
        ).real() < 0;
    }

  4. #4
    Registered User
    Join Date
    Jan 2009
    Posts
    103
    Quote Originally Posted by Sebastiani View Post
    >> I want to write a program to send a ARP packet. Is there some method where I can load up all the hex as an array and then it just sends it off to a specified IP address? How would I do this? Could someone forward me to a good raw sockets tutorial or just show me how to do this (latter prefered, I learn faster with just code)?

    Do your own research, write some code, and ask *specific* questions pertaining to the problems you encounter. Don't just expect others to hand you everything on a silver platter.
    Sigh...
    I should have expected this. See, I've been working on this for two days and I have found lots of results and programs but all of them have been written in like the 90's and skip a lot of the includes and their makefiles have errors and gcc pukes upon compiling.

  5. #5
    spurious conceit MK27's Avatar
    Join Date
    Jul 2008
    Location
    segmentation fault
    Posts
    8,300
    Quote Originally Posted by Poincare View Post
    Sigh...
    I should have expected this. See, I've been working on this for two days and I have found lots of results and programs but all of them have been written in like the 90's and skip a lot of the includes and their makefiles have errors and gcc pukes upon compiling.
    You're whining.

    Have you done stuff already using tcp/ip sockets, or is this your first socket based experience? There is definitely much less material about raw sockets around, possibly because if you can already use the tcp/ip stuff, raw sockets should seem simple. But I don't know that for sure...just a suggestion.
    C programming resources:
    GNU C Function and Macro Index -- glibc reference manual
    The C Book -- nice online learner guide
    Current ISO draft standard
    CCAN -- new CPAN like open source library repository
    3 (different) GNU debugger tutorials: #1 -- #2 -- #3
    cpwiki -- our wiki on sourceforge

  6. #6
    Registered User slingerland3g's Avatar
    Join Date
    Jan 2008
    Location
    Seattle
    Posts
    603
    Written back in the '90s? Hmm, most of the Kernel API has not changed much. Also if you are simply trying to compile a simple 'one off' ARP request/reply app, there should be no make files to contend with. I take it that you are bitting off more than you can chew here. Start off very simple and small.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. sending and recieveing packets with dynamic size.
    By c++.prog.newbie in forum Game Programming
    Replies: 1
    Last Post: 05-31-2006, 01:06 PM
  2. Sending requests with packets
    By joeprogrammer in forum Networking/Device Communication
    Replies: 14
    Last Post: 05-21-2006, 07:33 PM
  3. Sending Raw Packets?
    By Coder87C in forum Networking/Device Communication
    Replies: 7
    Last Post: 12-03-2003, 01:27 PM
  4. Sending data packets
    By neandrake in forum Networking/Device Communication
    Replies: 6
    Last Post: 11-26-2003, 01:41 PM
  5. Sending raw packets.
    By Denethor2000 in forum C++ Programming
    Replies: 3
    Last Post: 06-04-2002, 02:08 PM