#!/bin/bash NIC="eth1" DST_IP="192.168.1.2" DST_MAC="52:54:00:43:99:65" modprobe pktgen pg() { echo inject > $PGDEV cat $PGDEV } pgset() { local result echo $1 > $PGDEV result=`cat $PGDEV | fgrep "Result: OK:"` if [ "$result" = "" ]; then cat $PGDEV | fgrep Result: fi } # Config Start Here ----------------------------------------------------------- # thread config # Each CPU has own thread. Two CPU exammple. We add ens7, eth2 respectivly. PGDEV=/proc/net/pktgen/kpktgend_0 echo "Removing all devices" pgset "rem_device_all" echo "Adding ${NIC}" pgset "add_device ${NIC}" # device config # delay 0 means maximum speed. CLONE_SKB="clone_skb " # NIC adds 4 bytes CRC PKT_SIZE="pkt_size 64" # COUNT 0 means forever COUNT="count 0" DELAY="delay 0" PGDEV=/proc/net/pktgen/${NIC} echo "Configuring $PGDEV" pgset "$COUNT" pgset "$CLONE_SKB" pgset "$PKT_SIZE" pgset "$DELAY" pgset "dst ${DST_IP}" pgset "dst_mac ${DST_MAC}" # Time to run PGDEV=/proc/net/pktgen/pgctrl echo "Running... ctrl^C to stop" pgset "start" echo "Done" # Result can be vieved in /proc/net/pktgen/eth[3,4]
pktgen-dpdk
# 固定ip固定mac set 0 dst ip 192.168.10.240 set 0 src ip 192.168.10.245/24 set 0 dst mac c8:1f:66:d7:58:ba set 0 src mac a0:36:9f:ec:4a:28 # 可变source ip可变source mac stop 0 range 0 src ip 192.168.0.1 192.168.0.1 192.168.200.200 0.0.0.1 range 0 dst ip 10.1.1.241 10.1.1.241 10.1.1.241 0.0.0.0 range 0 dst mac c8:1f:66:d7:58:ba c8:1f:66:d7:58:ba c8:1f:66:d7:58:ba 00:00:00:00:00:00 range 0 src mac a0:36:9f:ec:4a:28 a0:36:9f:ec:4a:28 a0:36:9f:ec:ff:ff 00:00:00:00:01:01 range 0 src port 100 100 65530 1 range 0 dst port 100 100 65530 1 range 0 size 64 64 64 0 enable 0 range enable 0 latency start 0 # 按50%的速率发包 set 0 rate 50
转载:shmget参数详解shmgetintshm key t nbsp key size t nbsp size int nbsp flag key 标识符的规则 size 共享存储段的字节数 flag 读写的权限返回值 成功返回共享存储的 id 失败返回 1key tkey nbsp nbsp nbsp key 标识共享内存的键值 nbsp 0