Find the answer to your Linux question:
Results 1 to 2 of 2
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1

    sendto system call modification for sending to multiple IP addresses

    HI All ,

    Iam new to Kernel programing and presently trying to add a new system call similar to sendto but it can accept multiple IP addresses and port number and can be able to send same payload to group of IP addresses/port numbers . As the same payload needs to be send to different destinations calling sendto system call each time is overhead and does not suit for our application .
    PLan is to call sendto_many() with array of IP address/port numbers so that a single sendto system call can bel to able to send to 1000 destinations at one shot .

    I see following benifits with this .

    We feel that the overall cost savings are really an amalgam of cost reductions in several different components
    1) Context switch time
    2) Validating the system call parameters( Ensuring the data being sent is in the process address space )
    3) Copying the data from user to kernel space : memory copy may not be necessarily the dominating cost component for many applications using
    group communication. But it is also a one of the component .
    4) Link Layer Processing : The packet buffer is then submitted for link layer processing and eventually DMA-transferred to the network interface card (NIC)
    5) Interrupt Handlers : significant reduction in the number of interrupts and improved caching behaviour.
    with user-groupcast only a single packet is transmitted to the NIC each time. After the NIC has finished transmitting this packet, it generates an
    asynchronous hard ware interrupt. With kernel-groupcast, multiple packets are enqueued in a tight execution loop and a single interrupt is
    generated after all are transmitted. As the number of hardware interrupts is roughly proportional to the number of actual send
    system calls, the Intrrupt count reduces and might increase the chances of reduction in sending time .
    6)Cache Utilization : kernel-groupcast seems to benefit substantially from improved cache utilization as a result of the tight low-level execution loop
    when sending out multiple clones of the same packet. For example,Some reports shows that invocations of the main Ethernet
    processing routine ether_output() completes roughly 10 times faster for kernel-groupcast compared to user-groupcast, despite the same number
    of calls and the same operations being executed in both cases

    So Please help if Ithere is any such system call existing in open source ?

    I have done some initial analysis with this . THese are the application sturcture which sends message size of 100 bytes , and array of IP and port numbers .

    struct sockaddr_in {
    short sin_family; // e.g. AF_INET, AF_INET6
    unsigned short sin_port; // e.g. htons(3490)
    struct in_addr sin_addr; // see struct in_addr, below
    char sin_zero[8]; // zero this if you want to

    struct IP_List
    struct IP_List *next ;
    struct sockaddr_in current;

    struct IP_List *head ;
    Application calls sendto_many() , new system call with a new paramenter as below .

    sendto(s, buf, BUFLEN, 0, &head->current, slen)==-1

    Here iam passing IP_LIst Head pointer which contains a linked list of 1000 IP and 1000 port numbers .

    The new system call added is as follows . PLease review if this is correct .

    SYSCALL_DEFINE6(sendto, int, fd, void __user *, buff, size_t, len,
    unsigned, flags, struct IP_List __user *, addr,
    int, addr_len)
    struct socket *sock;
    struct sockaddr_storage address;
    struct sockaddr_in cliadr;
    int err;
    struct msghdr msg;
    struct iovec iov;
    int fput_needed;

    sock = sockfd_lookup_light(fd, &err, &fput_needed);
    if (!sock)
    goto out;

    iov.iov_base = buff;
    iov.iov_len = len;
    msg.msg_name = NULL;
    msg.msg_iov = &iov;
    msg.msg_iovlen = 1;
    msg.msg_control = NULL;
    msg.msg_controllen = 0;
    msg.msg_namelen = 0;

    flags |= MSG_DONTWAIT;
    msg.msg_flags = flags;

    msg.msg_namelen = addr_len;

    while(addr != NULL)

    err = move_addr_to_kernel(addr.current, addr_len, (struct sockaddr *)&address);
    if (err < 0)
    goto out_put;
    msg.msg_name = (struct sockaddr *)&address;

    err = sock_sendmsg(sock, &msg, len);
    addr = addr->next;

    fput_light(sock->file, fput_needed);
    return err;

    This is my changes in kernel for new system call . Iam yet to test this . I need your valuable help if something is wrong in this code .
    I appreciate any help regarding this .

    THanks ,
    AGP .

  2. #2
    Linux Guru Rubberman's Avatar
    Join Date
    Apr 2009
    I can be found either 40 miles west of Chicago, in Chicago, or in a galaxy far, far away.
    Use a multicast address scheme. Since you are not placing your code in a set of code blocks (user-friendly formatting), and it is rather long and involved, don't expect a lot of help beyond this...
    Sometimes, real fast is almost as good as real time.
    Just remember, Semper Gumbi - always be flexible!

Posting Permissions

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