【vpp2206 测试】

本文详细介绍了如何编译VPP,配置DPDK、接口设置、插件启用、VCL配置以及启动流程,包括设置appns、使用iperf3和nginx。涵盖了从环境搭建到运行应用的全过程。
摘要由CSDN通过智能技术生成

vpp 2206编译

# ./extras/vagrant/build.sh 

# make build
# make run


startup-default.conf 的内容

cpu {
	main-core 0
}


unix {
	interactive cli-listen 127.0.0.1:5002
	log /tmp/vpp.log
	full-coredump
	startup-config /home/king/share/vpp/startup.txt
}

dpdk {

	uio-driver igb_uio

	dev 0000:03:00.0 {
		name dpdk0
	}

}

session {
	enable
	use-app-socket-api
	evt_qs_memfd_seg
}

socksvr {
	socket-name /var/run/vpp/vcl-api.sock
}

api-trace {
	on
}

plugins {
#	path /home/king/share/vpp/build-root/build-vpp-native/vpp/lib/x86_64-linux-gnu/vpp_plugins/
	plugin oddbuf_plugin.so { enable }
}




vcl配置

vcl {
	heapsize 64M
	segment-size 4000000000
	add-segment-size 4000000000
	rx-fifo-size 4000000
	tx-fifo-size 4000000
	app-socket-api /run/vpp/app_ns_sockets/default
}



startup.txt

set interface state dpdk0 up
set interface ip address dpdk0 192.168.0.29/24
show interface address  dpdk0


插入igb_uio.ko

# cd /path/to/dpdk-kmods/linux/igb_uio

# insmod igb_uio.ko




dpdk参数配置


# mount -t hugetlbfs nodev /mnt/huge/
# echo 1024 > /sys/devices/system/node/node0/hugepages/hugepages-2048kB/nr_hugepages



网口

# ifconfig eth0 down



启动vpp

# cd /path/to/vpp
# export STARTUP_CONF=/etc/vpp/startup-default.conf
# make run



设置 app ns

# app ns add id 123 secret 0 sw_if_index 1 if dpdk0
# show app ns



启动 vpp+iperf3+vcl

# LD_PRELOAD=/home/king/share/vpp/build-root/install-vpp-native/vpp/lib/x86_64-linux-gnu/libvcl_ldpreload.so VCL_CONFIG=/etc/vpp/vcl
-default.conf iperf3 -s --bind=192.168.0.29



启动 vpp + vcl + nginx

# LD_PRELOAD=/home/king/share/vpp/build-root/build-vpp-native/vpp/lib/x86_64-linux-gnu/libvcl_ldpreload.so VCL_CONFIG=/etc/vpp/vcl-default.conf ./sbin/nginx -c ./conf/nginx.conf
  • 7
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
以下是使用 VPP 实现 Hash 表的示例代码: ```c #include <vlib/vlib.h> #include <vppinfra/hash.h> typedef struct { u32 key; u32 value; } hash_pair_t; typedef struct { u64 hits; u64 misses; uword *hash; } hash_table_t; typedef struct { hash_table_t ht; } hash_main_t; hash_main_t hash_main; static uword hash_pair_hash (void *item) { hash_pair_t *p = item; return hash_combine (0, p->key); } static int hash_pair_cmp (void *a1, void *a2) { hash_pair_t *p1 = a1; hash_pair_t *p2 = a2; return (p1->key == p2->key); } static void hash_table_init (hash_table_t *ht) { ht->hits = 0; ht->misses = 0; ht->hash = hash_create (0, sizeof (hash_pair_t), sizeof (uword)); } static void hash_table_add (hash_table_t *ht, u32 key, u32 value) { hash_pair_t pair = { .key = key, .value = value, }; hash_set_mem (ht->hash, &pair, hash_pair_hash (&pair)); } static u32 hash_table_find (hash_table_t *ht, u32 key) { hash_pair_t query = { .key = key, }; uword *p = hash_get_mem (ht->hash, &query); if (p) { ht->hits++; hash_pair_t *pair = (hash_pair_t *) p[0]; return pair->value; } else { ht->misses++; return ~0; } } static clib_error_t * hash_init (vlib_main_t *vm) { hash_table_init (&hash_main.ht); return 0; } VLIB_INIT_FUNCTION (hash_init); static clib_error_t * hash_cli (vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd) { u32 key, value; if (!unformat (input, "add %u %u", &key, &value)) { return clib_error_return (0, "unknown input `%U'", format_unformat_error, input); } hash_table_add (&hash_main.ht, key, value); return 0; } VLIB_CLI_COMMAND (hash_cli_command, static) = { .path = "hash-table", .short_help = "hash table commands", .function = hash_cli, }; static clib_error_t * hash_test (vlib_main_t *vm) { u32 key, value, result; key = 42; value = 1337; hash_table_add (&hash_main.ht, key, value); result = hash_table_find (&hash_main.ht, key); if (result == value) { vlib_cli_output (vm, "Test 1 passed\n"); } else { vlib_cli_output (vm, "Test 1 failed: expected %u, got %u\n", value, result); } key = 43; result = hash_table_find (&hash_main.ht, key); if (result == ~0) { vlib_cli_output (vm, "Test 2 passed\n"); } else { vlib_cli_output (vm, "Test 2 failed: expected ~0, got %u\n", result); } return 0; } VLIB_EARLY_CONFIG_FUNCTION (hash_test); ``` 在此示例代码中,我们定义了一个`hash_pair_t`结构体,它包含一个键和一个值。我们还定义了一个`hash_table_t`结构体,它包含命中次数、未命中次数和一个哈希表。我们使用`hash_create()`函数初始化哈希表。`hash_pair_hash()`函数计算哈希值,`hash_pair_cmp()`函数比较两个键是否相等。`hash_table_add()`函数将一个键值对添加到哈希表中,`hash_table_find()`函数在哈希表中查找一个键对应的值。`hash_init()`函数在加载模块时初始化哈希表。`hash_cli()`函数处理 CLI 命令。`hash_test()`函数测试哈希表的功能。 请注意,此示例代码仅用于演示 VPP 中哈希表的实现,实际使用中可能需要更改代码以符合您的需求。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值