Skip to content

Commit

Permalink
perf test with l2tp random packets
Browse files Browse the repository at this point in the history
  • Loading branch information
lukego committed Jan 27, 2016
1 parent a07ab72 commit 86300cf
Show file tree
Hide file tree
Showing 14 changed files with 105 additions and 28 deletions.
1 change: 0 additions & 1 deletion src/program/lisper/dev-env-perftest/blast

This file was deleted.

1 change: 1 addition & 0 deletions src/program/lisper/dev-env-perftest/blast01
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
snabb/src/snabb packetblaster replay lisper01.pcap 0000:01:00.1
1 change: 1 addition & 0 deletions src/program/lisper/dev-env-perftest/blast02
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
snabb/src/snabb packetblaster replay lisper02.pcap 0000:01:00.1
56 changes: 29 additions & 27 deletions src/program/lisper/dev-env-perftest/gen_pcap.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,18 @@ local pcap = require'lib.pcap.pcap'
local eth = require'lib.protocol.ethernet'
local ipv6 = require'lib.protocol.ipv6'
local ffi = require'ffi'
local lib = require'core.lib'

local f
local function file(filename)
local f = io.open(filename, "w")
if f then f:close() end
if not filename then return end
print('opening '..filename)
f = io.open(filename, "w")
pcap.write_file_header(f)
return f
end

local function write(f, p)
local function write(p)
local buf, len = p.data, p.length
pcap.write_record_header(f, len)
print(string.format('writing %d bytes packet', p.length))
Expand Down Expand Up @@ -46,42 +50,40 @@ local l2tp_ct = ffi.typeof[[
local l2tp_ct_size = ffi.sizeof(l2tp_ct)
local l2tp_ctp = ffi.typeof("$*", l2tp_ct)

local function gen(len, smac, dmac, src_ip, dst_ip, sid, cookie)
local dp = packet.allocate()
local function gen(len, smac, dmac, src_ip, dst_ip, sid, cookie, l2tp_smac, l2tp_dmac)
local dp = packet.allocate()
local hsize = src_ip and l2tp_ct_size or 12
dp.length = hsize + len
ffi.copy(dp.data + hsize, ('x'):rep(len))
local p = ffi.cast(l2tp_ctp, dp.data)
ffi.copy(p.smac, smac, 6)
ffi.copy(p.dmac, dmac, 6)
local p = ffi.cast(l2tp_ctp, dp.data)
ffi.copy(p.smac, eth:pton(smac), 6)
ffi.copy(p.dmac, eth:pton(dmac), 6)
if src_ip then
p.ethertype = 0xdd86 --ipv6
p.flow_id = 0x60 --ipv6
p.payload_length = htons(len + 12 + 12) --payload + ETH + L2TPv3
p.payload_length = lib.htons(len + 12 + 12) --payload + ETH + L2TPv3
p.next_header = 115 --L2TPv3
p.hop_limit = 64 --default
ffi.copy(p.src_ip, src_ip, 16)
ffi.copy(p.dst_ip, dst_ip, 16)
p.session_id = htonl(sid)
ffi.copy(p.src_ip, ipv6:pton(src_ip), 16)
ffi.copy(p.dst_ip, ipv6:pton(dst_ip), 16)
p.session_id = lib.htonl(sid)
ffi.copy(p.cookie, cookie, 8)
ffi.copy(p.l2tp_smac, eth:pton(l2tp_smac), 6)
ffi.copy(p.l2tp_dmac, eth:pton(l2tp_dmac), 6)
end
return dp
write(dp)
end

local f = file'lisper01.pcap'
local p = gen(150, '00:00:00:00:02:01', '00:00:00:00:02:02')
write(f, p)
f:close()
file'lisper01.pcap'
gen(150, '00:00:00:00:02:01', '00:00:00:00:02:02')

local f = file'lisper02.pcap'
for i=1,math.random(100, 200) do
local smac = eth:pton(smac)
local dmac = eth:pton(dmac)
local src_ip = ipv6:pton(scr_ip)
local dst_ip = ipv6:pton(dst_ip)
local sid = 1
file'lisper02.pcap'
local n = math.random(100, 200)
for i=1,n do
local len = math.random(20, 200)
local cookie = '\0\0\0\0\0\0\0\0'
local len = math.random(50, 500)
gen(len, smac, dmac, src_ip, dst_ip, sid, cookie)
gen(len, '00:00:00:00:00:21', '00:00:00:00:00:01', 'fd80::21', 'fd80::01', 1, cookie, '00:00:00:00:01:01', '00:00:00:00:01:02')
gen(len, '00:00:00:00:00:22', '00:00:00:00:00:01', 'fd80::22', 'fd80::01', 1, cookie, '00:00:00:00:01:02', '00:00:00:00:01:01')
end
f:close()

file()
6 changes: 6 additions & 0 deletions src/program/lisper/dev-env-perftest/lisp
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/usr/bin/env bash
run() { ./lisp.lua ${LISP_N}; }
start() { run >/dev/null & }
stop() { pgrep -f "lisp.lua ${LISP_N}" | xargs kill -9; }
restart() { stop; start; }
if [ "$1" ]; then $1; else stop; run; fi
1 change: 1 addition & 0 deletions src/program/lisper/dev-env-perftest/lisp.lua
7 changes: 7 additions & 0 deletions src/program/lisper/dev-env-perftest/lisp02.fib
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{ "instance-id": 1, "eid-prefix": "000000-00aa05/48", "rlocs": [{ "rloc": "fd80::12", "priority": 1, "weight": 50 }] }

{ "instance-id": 1, "eid-prefix": "000000-00aa06/48", "rlocs": [{ "rloc": "fd80:8::2", "priority": 1, "weight": 50 }] }

{ "instance-id": 1, "eid-prefix": "000000-00aa07/48", "rlocs": [{ "rloc": "fd80:8::2", "priority": 1, "weight": 50 }] }

{ "instance-id": 1, "eid-prefix": "ffffff-ffffff/48", "rles": [{ "rle": "fd80:8::2" }] }
Binary file not shown.
4 changes: 4 additions & 0 deletions src/program/lisper/dev-env-perftest/lisper02-restart
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#./mklisper
export LISP_N=02
./lisp restart
./lisper restart
4 changes: 4 additions & 0 deletions src/program/lisper/dev-env-perftest/lisper02-stop
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#./mklisper
export LISP_N=02
./lisp stop
./lisper stop
27 changes: 27 additions & 0 deletions src/program/lisper/dev-env-perftest/lisper02.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"control_sock" : "/var/tmp/lisp-ipc-map-cache",
"punt_sock" : "/var/tmp/lispers.net-itr",
"arp_timeout" : 60, // seconds

"interfaces": [
{ "name": "e0", "mac": "00:00:00:00:00:01", "pci": "0000:01:00.0" }
],

"exits": [
{ "name": "e0", "ip": "fd80::1", "interface": "e0" }
],

"lispers": [
{ "ip": "fd80::11", "exit": "e0" },
{ "ip": "fd80::12", "exit": "e0" },
{ "ip": "fd80::13", "exit": "e0" },
{ "ip": "fd80::14", "exit": "e0" }
],

"local_networks": [
{ "iid": 1, "type": "L2TPv3", "ip": "fd80::21", "exit": "e0", "session_id": 1, "cookie": "" },
{ "iid": 1, "type": "L2TPv3", "ip": "fd80::22", "exit": "e0", "session_id": 1, "cookie": "" },
{ "iid": 1, "type": "L2TPv3", "ip": "fd80::23", "exit": "e0", "session_id": 2, "cookie": "" },
{ "iid": 1, "type": "L2TPv3", "ip": "fd80::24", "exit": "e0", "session_id": 2, "cookie": "" }
]
}
24 changes: 24 additions & 0 deletions src/program/lisper/dev-env-perftest/lisper02.log
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
Links:
if_e0.tx -> lisper.e0
punt.tx -> punt_sock.rx
lisper.e0 -> if_e0.rx
ctl_sock.tx -> ctl.rx
Params:
ctl_sock :
listen : true
mode : packet
filename : /var/tmp/lisp-ipc-map-cache
punt_sock :
listen : false
mode : packet
filename : /var/tmp/lispers.net-itr
if_e0 :
pciaddr : 0000:01:00.0
macaddr : 00:00:00:00:00:01
punt :
ctl :
lisper :
LEARN: [1] 000000-000101 <- type: l2tpv3, ip: fd80::22, session_id: 0x0001, cookie: 0
LEARN: [1] 000000-000102 <- type: l2tpv3, ip: fd80::22, session_id: 0x0001, cookie: 0
PUNT: {"eid-prefix" : "0000-0000-0102", "interface" : "e0"}
PUNT: {"eid-prefix" : "0000-0000-0101", "interface" : "e0"}
Binary file added src/program/lisper/dev-env-perftest/lisper02.pcap
Binary file not shown.
1 change: 1 addition & 0 deletions src/program/lisper/dev-env-perftest/packetblaster.lua

0 comments on commit 86300cf

Please sign in to comment.