Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 994087
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T06:31:36+00:00 2026-05-16T06:31:36+00:00

How can I send a datagram with an Ethernet trailer? If I use SocketType.Raw,

  • 0

How can I send a datagram with an Ethernet trailer? If I use SocketType.Raw, I’ll have to send the whole IP header and I have no idea how to do that.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T06:31:37+00:00Added an answer on May 16, 2026 at 6:31 am

    Something like this perhaps?

    #include <stdio.h>
    #include <stdlib.h>
    #include <string.h>
    
    #include <unistd.h>
    
    #include <sys/socket.h>
    #include <linux/if_packet.h>
    #include <linux/if_ether.h>
    #include <linux/if_arp.h>
    
    #include <sys/ioctl.h>
    
    int s;
    
    unsigned char buffer[513];
    
    struct sockaddr_ll socket_address;
    
    int main ( void )
    {
        unsigned char seq;
        unsigned int ra;
        int length;
        struct ifreq ifr;
    
        s = socket(AF_PACKET, SOCK_RAW, htons(ETH_P_ALL));
        if (s == -1)
        {
            printf("error creating socket\n");
            return(1);
        }
    
        memset(&ifr,0, sizeof(struct ifreq));
        strncpy(ifr.ifr_name,"eth0",IFNAMSIZ);
        if(ioctl(s, SIOCGIFINDEX, &ifr) < 0)
        {
            perror("ioctl SIOCGIFINDEX");
            exit(1);
        }
    
        printf("index %d\n",ifr.ifr_ifindex);
    
    
        printf("socket created\n");
    
        memset(&socket_address,0,sizeof(socket_address));
    
        socket_address.sll_family = PF_PACKET;
        socket_address.sll_protocol = htons(ETH_P_ALL);
        socket_address.sll_ifindex = ifr.ifr_ifindex;
    
        if (bind(s, (struct sockaddr *)(&socket_address), sizeof(socket_address)) < 0)
        {
            perror("bind error");
            exit(1);
        }
    
        printf("bound\n");
    
        length=27;
    
        memset(buffer,0,sizeof(buffer));
    //destination
        buffer[ 0]=0xFF;
        buffer[ 1]=0xFF;
        buffer[ 2]=0xFF;
        buffer[ 3]=0xFF;
        buffer[ 4]=0xFF;
        buffer[ 5]=0xFF;
    //source
        buffer[ 6]=0x00;
        buffer[ 7]=0x19;
        buffer[ 8]=0xd1;
        buffer[ 9]=0x02;
        buffer[10]=0xdc;
        buffer[11]=0xb3;
    //length
        buffer[12]=((length-14)>>8)&0xFF;
        buffer[13]=((length-14)>>0)&0xFF;
    //payload
        buffer[14]=0x12;
        buffer[15]=0x34;
    
        for(ra=0;ra<20;ra++)
        {
            buffer[16]=ra;
            if(send(s,buffer,length,0) < 0 )
            {
                printf("sendto failed\n");
                break;
            }
            else
            {
                printf("sent\n");
            }
        }
    
        close(s);
        return(1);
    
    }
    

    That should give a raw packet that you can see on wireshark. if you want to have the ip eader, or make it a udp or something like that you can use this method and build the header yourself (it is trivial look at the rfcs or just use wireshark to look at a bunch of other packet headers). Note that for udp you do not have to compute a checksum 0x0000 is a valid checksum that is supposed to pass on through.

    If all you want is a udp packet with zeros at the end that is somewhat the same, probably easier, let me know.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.