linux
zhongyoubing
这个作者很懒,什么都没留下…
展开
-
linux中三大文本工具
1.grepgrep 根据模式搜索文本,并将符合模式的文本显示出来grep个格式用法如下:grep [option] [--color=auto] pattern filename -i:忽略大小写 --color:匹配到字符用其他颜色显示出来,默认是红色 -v:显示没有被模式匹配到的行 -o:只显示被模式匹配到的字符串,不显示行原创 2017-04-13 11:06:56 · 1453 阅读 · 0 评论 -
指定网卡发送数据包
1. 指定网卡发送数据指定网卡名需要使用struct sockaddr_ll,struct ifreq, 使用ioctl()函数获取网卡索引号,使用原始套接字发送UDP数据,代码如下:#include <stdio.h>#include <stdlib.h>#include <string.h>#include <net/if.h>...原创 2018-11-15 18:50:40 · 5503 阅读 · 2 评论 -
编译,连接,编译器做的一系列具体事项
通常在windows上编写代码后,需要将其在linux上编译之后才可以运行,以gcc 为例。对于简单的我们一般直接使用:gcc example.c -o example其中主要做了如下工作:对于复杂多个源码文件安装,一般有如下几个步骤:./configuremakemake install下面介绍这几个步骤所做的事:1. configure 这一步主要是检查系统的环境,检查函数库,指定...原创 2018-06-07 10:59:53 · 402 阅读 · 0 评论 -
pktgen-dpdk源码解析
pktgen-dpdk使用dpdk加速包的发送接收,也可以发送接收pcap包,命令行如下:./app/app/x86_64-native-linuxapp-gcc/pktgen -l 0-4 -n 3 -- -P -m "[11:3].0,[2:4].1" -s 0:[.pcap_filepath] (pktgen-dpdk.3.4.8)下面的源码讲述采用的也是3.4.8版本,主要讲述源码中的设计...原创 2018-03-09 20:24:45 · 3568 阅读 · 0 评论 -
tcpreplay介绍以及源码分析
tcpreplay介绍tcpreplay主要用于重放pcap数据包,还可以对pcap文件进行修改,比如修改ip地址和端口号等,其中主要包含了一下几个模块:tcpreplay:pcap重放模块,其中提供了包重放速度控制,循环控制,重放模式等功能。tcpreweite: 修改网络中mac,IP地址,端口信息。tcpbrige:利用tcprewrite的功能实现两个网络部分的桥tcpreplay的作者在...原创 2018-01-27 17:31:42 · 4464 阅读 · 0 评论 -
snprintf(), fwrite(),fread() ,fprintf() ,fseek() ,ftell()
1 .snprintf()函数原型如下:int _snprintf(char *buffer, size_t count,const char *format [,argument] ... );用于将格式化的数据写入字符串,If len count, then len characters are stored in buffer, a null-terminat原创 2017-08-25 10:02:31 · 340 阅读 · 0 评论 -
htons(), ntohs(),htonl(),ntohl(), inet_addr() ,inet_ntoa() || bzero()
htonl() , ntohl() ,htons(),ntohs()#include <netinet/in.h>uint32_t htonl(uint32_t hostlong);uint16_t htons(uint16_t hostshort);uint32_t ntohl(uint32_t netlong);uint16_t ntohs(uint16_t netshort);ht原创 2017-09-27 19:24:19 · 361 阅读 · 0 评论 -
htons(), ntohs(),htonl(),ntohl(), inet_addr() ,inet_ntoa() || bzero()
1. htonl() , ntohl() ,htons(),ntohs()htonl() :“Host to Network Long int” 32Bytesntohl() :“Network to Host Long int” 32Byteshtons():“Host to Network Short int” 16Bytesntohs():“Network to原创 2017-08-18 20:34:22 · 352 阅读 · 0 评论 -
struct ip 和struct iphdr的差别 , <netinet/*.h>和<linux/*.h>
(1)struct ip 和struct iphdrstruct ip {#if BYTE_ORDER == LITTLE_ENDIAN u_char ip_hl:4, /* header length */ ip_v:4; /* version */#endif#if BYTE_ORDER == BIG_ENDIAN原创 2017-08-20 21:50:50 · 8928 阅读 · 0 评论 -
gcc的使用
1. gccgcc是一个 GUN C compiler2. 简单编译test.c #includeint main(){printf("this is a test\n");return 0;}一步到位的编译时:gcc test.c -o test实际上,上面经过了四个阶段进行的,即预处理(也称预编译,Preprocessing)、编译(Compil原创 2017-08-28 16:17:36 · 294 阅读 · 0 评论 -
ubuntu使用桥接模式无法连接网络的问题
当使用vmware创建虚拟机ubuntu时,使用桥接模式后可以直接在在右上角设置网络,设置自己的IP地址与主机同一网段的IP即可,并且设置子网掩码,网关河DNS。但是当我们复制或是移动虚拟机到另外一台机器时会导致无法连接网络,这时就需要配置网络。1.配置虚拟机网络 首先,删除以前图形界面的网络配置,进入/etc/network/interfaces,配置IP,netmask,getway原创 2017-05-02 15:34:26 · 17193 阅读 · 0 评论 -
获取网卡信息
本代码通过ioctl获取的网卡只有网卡为up的,不能获取ifconfig查看的所有信息:#include <stdio.h>#include <string.h>#include <net/if.h>#include <sys/ioctl.h>#include <arpa/inet.h>#include <errno...原创 2018-11-15 22:36:25 · 868 阅读 · 0 评论