#include #include #define MAX_DEBITS 256 #define TAILLE_BUFFER_ERREUR 256 #define MAX_FLUX 256 int main(int argc, char *argv[]){ // : Notes">

NotesWhat is notes.io?

Notes brand slogan

Notes - notes.io


#include <stdio.h>
#include <stdlib.h>
#include "pcap/pcap.h"
#include <netinet/ip.h>
#include <netinet/tcp.h>
#include <arpa/inet.h>



#define MAX_DEBITS 256
#define TAILLE_BUFFER_ERREUR 256
#define MAX_FLUX 256

int main(int argc, char *argv[]){
// Contrôler la validité du paramètre
if(argc != 2)
{
printf("Erreur de syntaxe : AnalyseurTCP <fichier_pcap>n");
exit(-1);
}

// Ouvrir le fichier PCAP passé en paramètre
char *chemin_fichier = argv[1];
char buffer_erreur[TAILLE_BUFFER_ERREUR];
pcap_t * fichier_pcap;

fichier_pcap = pcap_open_offline(chemin_fichier, buffer_erreur);
if(fichier_pcap == NULL)
{
perror("pcap_open_offline");
exit(-1);
}


// Parcourir les paquets contenus dans le fichier PCAP
struct pcap_pkthdr entete_pkt;
const u_char * paquet;
struct ip * entete_ip = NULL;
struct tcphdr * entete_tcp = NULL;
tcp_seq seq;
struct timeval instant_zero;
struct timeval instant_courant;
int numeroFlux;

int i=0;
while((paquet = pcap_next(fichier_pcap, &entete_pkt)) != NULL && i<5)
{
// Obtenir l'en-tête IP du paquet
entete_ip = (struct ip *)(paquet + 14);
//~ printf("len-- : %un",ntohs(entete_ip->len));
printf("src-- : %st",inet_ntoa(entete_ip->ip_src));
printf("ipid- : %dt",(entete_ip->ip_hl &0x0f));

i++;



//~ // Contrôler la version d'IP du paquet : IPv4
//~ if(entete_ip->ip_v != 4)
//~ continue;
//~ // Contrôler le protocole du paquet : TCP
//~ if(entete_ip->ip_p != 6)
//~ continue;
//~ // Obtenir l'en-tête TCP du paquet
entete_tcp = (struct tcphdr *)(paquet + 14 + 20);
printf("tt testKatia : %un",ntohl(entete_tcp->ack_seq));
printf("tt testKatia : %u",ntohl(entete_tcp->th_ack));

}

//~
//~ char c;
//~ while((c=getchar())!=1){
//~ printf("%c",c);
//~ }
//~
//close file
pcap_close(fichier_pcap);

return 0;
}
     
 
what is notes.io
 

Notes.io is a web-based application for taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000 notes created and continuing...

With notes.io;

  • * You can take a note from anywhere and any device with internet connection.
  • * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
  • * You can quickly share your contents without website, blog and e-mail.
  • * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
  • * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.

Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.

Easy: Notes.io doesn’t require installation. Just write and share note!

Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )

Free: Notes.io works for 12 years and has been free since the day it was started.


You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;


Email: [email protected]

Twitter: http://twitter.com/notesio

Instagram: http://instagram.com/notes.io

Facebook: http://facebook.com/notesio



Regards;
Notes.io Team

     
 
Shortened Note Link
 
 
Looding Image
 
     
 
Long File
 
 

For written notes was greater than 18KB Unable to shorten.

To be smaller than 18KB, please organize your notes, or sign in.