Git Product home page Git Product logo

sniff's Introduction

介绍

基于 C语言 网络流量在线分析系统

实验环境

1.操作系统:macOS Sierra 10.12.5

2.编程语言:C语言

3.网络数据包捕获函数包:libpcap

4.Xcode 8.3.3 + mac终端

环境配置

2.解压之后,在软件目录下执行./configure

3.执行 make

4.执行 make install,此时,在/usr/local/lib目录下会生成libpcap的动态链接库,如:libpcap.dylib

5.执行export DYLD_LIBRARY_PATH=/usr/local/lib 将此目录加入动态链接库的CLASSPATH

6.编写测试代码测试是否可用:

// vim device.c
#include <stdio.h>
#include <pcap/pcap.h>
int main(int argc,char *argv[]) {
  char *dev,errbuf[PCAP_ERRBUF_SIZE];
  dev=pcap_lookupdev(errbuf);
  if(dev==NULL) {
    printf("couldn't find default device: %s\n",errbuf);
    return(2);
  }
  printf("Device: %s\n",dev);
  return(0);
}

7.执行编译指令:

gcc -o device device.c -l pcap

8.测试例程:

sudo ./device

如果显示:Device: en0 说明测试成功。

运行程序

进入项目目录,在终端中运行下面的命令

sudo su
gcc -o catch pcap_catch.c -l pcap
./catch
gcc -o analysis pcap_analysis.c -l pcap
./analysis

实现功能

  • 实时抓取网络中的数据包
  • 离线存储网络中的数据包
  • 分析各个网络协议格式
  • 采用Hash链表的形式将网络数据以连接(双向流)的形式存储
  • 计算并显示固定时间间隔内网络连接(双向流)的统计量

sniff's People

Contributors

sunmaer avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.