Spectre traffic generator v.0.9
This commit is contained in:
commit
8959cbc0d5
8 changed files with 849 additions and 0 deletions
57
headers/n_packet.h
Normal file
57
headers/n_packet.h
Normal file
|
@ -0,0 +1,57 @@
|
|||
#ifndef NPACK_H
|
||||
#define NPACK_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <netinet/ip.h>
|
||||
#include <netinet/in.h>
|
||||
|
||||
#define DEFAULT_INTERFACE "enp0s3"
|
||||
|
||||
#define MY_DEST_MAC0 0x01
|
||||
#define MY_DEST_MAC1 0x01
|
||||
#define MY_DEST_MAC2 0x01
|
||||
#define MY_DEST_MAC3 0x01
|
||||
#define MY_DEST_MAC4 0x01
|
||||
#define MY_DEST_MAC5 0x01
|
||||
|
||||
#define MY_DEST_IP "192.168.0.111"
|
||||
#define MY_SRC_PORT 2134
|
||||
#define MY_DEST_PORT 3456
|
||||
#define MY_SEQ_NUMBER 4253
|
||||
|
||||
#define BUF_SIZ 2048
|
||||
|
||||
struct sockaddr_ll
|
||||
{
|
||||
unsigned short sll_family;
|
||||
unsigned short sll_protocol;
|
||||
int sll_ifindex;
|
||||
unsigned short sll_hatype;
|
||||
unsigned char sll_pkttype;
|
||||
unsigned char sll_halen;
|
||||
unsigned char sll_addr[8];
|
||||
};
|
||||
|
||||
struct pseudo_hdr
|
||||
{
|
||||
uint32_t saddr;
|
||||
uint32_t daddr;
|
||||
uint8_t zeros;
|
||||
uint8_t protocol;
|
||||
uint16_t tot_len;
|
||||
};
|
||||
|
||||
typedef enum
|
||||
{
|
||||
TCP = IPPROTO_TCP,
|
||||
UDP = IPPROTO_UDP
|
||||
} protocol;
|
||||
|
||||
unsigned short s_csum(unsigned short*, int);
|
||||
unsigned short l_csum(struct iphdr*, void*, int);
|
||||
uint16_t calc_ip_size(uint16_t);
|
||||
uint16_t calc_ip_csum(char*);
|
||||
uint16_t calc_udp_size(uint16_t);
|
||||
uint16_t calc_tr_csum(char*, uint16_t);
|
||||
|
||||
#endif
|
35
headers/n_plan.h
Normal file
35
headers/n_plan.h
Normal file
|
@ -0,0 +1,35 @@
|
|||
#ifndef NPLAN_H
|
||||
#define NPLAN_H
|
||||
|
||||
#include <stdio.h>
|
||||
#include <n_packet.h>
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint16_t p_size;
|
||||
uint32_t p_delay;
|
||||
} t_metaunit;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
char* p_buf;
|
||||
uint16_t p_size;
|
||||
protocol p_proto;
|
||||
uint16_t p_ip_size;
|
||||
uint16_t p_ip_csum;
|
||||
uint16_t p_tr_size;
|
||||
uint16_t p_tr_csum;
|
||||
} t_dataunit;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
t_dataunit d_unit;
|
||||
uint32_t time;
|
||||
} t_planunit;
|
||||
|
||||
|
||||
|
||||
t_metaunit* cr_meta(uint32_t, uint16_t, uint16_t, double, uint32_t, uint32_t, double, FILE*, FILE*);
|
||||
int destroy_meta(t_metaunit*);
|
||||
|
||||
#endif
|
26
headers/rand_exp.h
Normal file
26
headers/rand_exp.h
Normal file
|
@ -0,0 +1,26 @@
|
|||
#ifndef N_RANDEXP_H
|
||||
#define N_RANDEXP_H
|
||||
|
||||
#include <gsl/gsl_rng.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#define EXPONEN_D 1
|
||||
#define FLAT_D 2
|
||||
#define CUSTOM_D 3
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint16_t rows;
|
||||
double* data;
|
||||
} cd_unit;
|
||||
|
||||
int creat_cd_unit(FILE*, cd_unit*);
|
||||
int destroy_cd_unit(cd_unit*);
|
||||
|
||||
gsl_rng* init_exp_d();
|
||||
int destroy_exp_d(gsl_rng*);
|
||||
uint32_t get_exp(gsl_rng*, double, uint32_t, uint32_t);
|
||||
uint32_t get_custom(gsl_rng*, uint32_t, uint32_t, cd_unit*);
|
||||
|
||||
#endif
|
Loading…
Add table
Add a link
Reference in a new issue