This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

NDK, SOCK_RAW, SOCK_RAWETH and questions...

Hi Ti Folks,

                     I am writing my own IP stack [in my user space] on top of NDK and for this purpose, i want to receive Raw packets. Kindly note i will be

writing even CONNECTION ESTABLISHMENT HANDSHAKE protocols. In NDK, i see
there is a way to receive Raw packets [#define SOCK_RAW 3 // raw-protocol interface] and on top of those packets, user can write their own applications in user space [creating a Daemon using RAW SOCK Mode]. I have few doubts on them,please clarify

1. As part of TCP connection establishment, there is a 3-way handshake being done. In raw socket mode, are those packets delivered to receiving entity.
2. Do i receive ethernet header [source mac address,destination mac address and type/length field] also as part of raw socket functionality in NDK. [i see it as yes, as part of raw socket

""In contrast, raw sockets usually receive raw packets including the header"" ---->wikipedia

http://en.wikipedia.org/wiki/Raw_socket]
3. Also please let me know if NDK meddles [Acks/Nacks/Replies/Responsds] to any incoming packets in raw socket mode. If so, what are those?
4. what is the difference between
SOCK_RAWETH // non-copy raw eth socket
and
SOCK_RAW //raw-protocol interface
based reception. what does it mean by non-copy. As my objective is "writing my own IP stack [in my user space] on top of NDK", which one is best suited for my application.

I see there is an example as part of client.c, will go through it.
meanwhile, kindly answer my questions

Thanks
RC Reddy

  • Hi Ti Folks,

                       I am awaiting your reply on this.

    Thanks

    RC Reddy

  • Hi,
    In case of no copy, no "additional" copy is made from the receive buffers. The buffers are directly obtained and need to be freed later.

    This is what i read from the Application guide.

    By default, neither UDP nor RAW sockets use send or receive buffers. However, the sockets API
    functions recv() and recvfrom() require a data buffer copy because of how the calling parameters to the
    functions are defined. In the stack library, two alternative functions (recvnc()and recvncfrom()) are
    provided to allow an application to get received data buffers directly without a copy operation. When the
    application is finished with these buffers, it returns them to the system via a call to recvncfree().

    So, if no copy would be used for efficient transmissions i would guess.

    Thanks

  • Thanks for your reply and i understand the difference now,

                                      Kindly answer my other questions too.

    Regards

    RC Reddy