/********************************************************************************************
* SYN Flood, Test on Red Hat Enterprise Linux AS release 3 (Taroon Update 5), gcc 3.23
* gcc -o syn_test -O3 syn_test.c
* change log:
* 2006-12-01, code by yunshu([email protected]), thx luoluo for fixing a bug.
* 2006-12-05, yunshu fix a bug, version 1.0
* 2006-12-26, thx bocai for reporting a bug, version 1.1
* 2008-04-26 luoluo add type options to support syn_ack and fin_ack flood v1.2
* 2010-11-10 yunshu fix a little bug
* 2010-11-19 yunshu modify the sleep funtion, version 1.3.
* 2011-06-26 yunshu delete attack code, make it to be a testing tool.
*
* it used to test loadblance, you have to change some code for attacking.
*********************************************************************************************/
#include <stdio.h>
#include <netinet/in.h>
#include <netdb.h>
#include <sys/time.h>
#include <sys/types.h>
#include <unistd.h>
#include <stdlib.h>
#include <signal.h>
#include <pthread.h>
#include <errno.h>
typedef struct ip_hdr
{
unsigned char h_verlen;
unsigned char tos;
unsigned short total_len;
unsigned short ident;
unsigned short frag_and_flags;
unsigned char ttl;
unsigned char proto;
unsigned short checksum;
unsigned int sourceIP;
unsigned int destIP;
}IP_HEADER;
typedef struct tcp_hdr
{
unsigned short th_sport;
unsigned short th_dport;
unsigned int th_seq;
unsigned int th_ack;
unsigned char th_lenres;
unsigned char th_flag;
unsigned short th_win;
unsigned short th_sum;
unsigned short th_urp;
}TCP_HEADER;
typedef struct tsd_hdr
{
unsigned long saddr;
unsigned long daddr;
char mbz;
char ptcl;
unsigned short tcpl;
}PSD_HEADER;