Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Linkemulation pullreq #229

Open
wants to merge 54 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
83227f5
changed libmoon submodule to point to my fork of it
Apr 12, 2017
511ed75
some rate setting experimentation scripts
Apr 12, 2017
936f52d
update libmoon submodule to trackmaster branch
Apr 13, 2017
e50d758
a timestamping script I dug up
Apr 13, 2017
879f372
debugging the crc rate-setter script
Apr 13, 2017
9186d03
my last attempt at a rate-controlled pkt forwarder
Apr 18, 2017
7871e4c
when calling sendWithDelay, add the number of valid bufs being passed…
Apr 19, 2017
30216d7
some old change
Nov 20, 2017
a3467cd
Merge remote-tracking branch 'upstream/master'
brentondwalker Nov 20, 2017
b095375
l2-cbr-load-latency script
Nov 22, 2017
acedbd8
change l2-cbr-load-latency.lua to take rate in Mbps (wire) and add a …
brentondwalker Nov 24, 2017
81317d2
automatic determiniation of linkspeed in l2-cbr-load-latency.lua
brentondwalker Nov 24, 2017
5eeb3ff
add l2-cbr-load-ipt.lua, a script for sending frames and measuring in…
brentondwalker Nov 25, 2017
cf6ef0e
add numpackets argument to ipt-rate-set-crc.lua, which lets you set t…
brentondwalker Nov 29, 2017
951f15c
fix a packt size error in ipt-rate-set-crc.lua
brentondwalker Dec 11, 2017
b6e76b4
update libmoon submodule to latest
Dec 21, 2017
25fb398
some updates to the crc forwarding script l2-forward-rate-crc.lua
Dec 21, 2017
0111ea1
Merge branch 'master' of github.com:brentondwalker/MoonGen
Dec 21, 2017
bd3a8ff
add numpackets argument to l2-cbr-load-latency.lua
Dec 21, 2017
04dbc05
clean up ipt-rate-set-crc.lua
Dec 21, 2017
d111077
check in scripts directory
Dec 21, 2017
aeaa67d
added support for in-order latecy pipe and the script l2-forward-hybr…
brentondwalker Feb 26, 2018
fd1bb81
Merge branch 'master' of github.com:brentondwalker/MoonGen
brentondwalker Feb 26, 2018
86cedf4
add maxWait option to l2-cbr-load-latency.lua
brentondwalker Feb 26, 2018
dfff0d9
Make submodule tracking a branch
brentondwalker Feb 27, 2018
0555b5d
add forwarding script that uses BytesizedRing latency pipe
brentondwalker Feb 27, 2018
843cd94
add packet loss to crc rate control tools, and a forwarder script tha…
brentondwalker May 24, 2018
23dc530
add an extra exponentially distributed latency component to the crc-r…
brentondwalker May 24, 2018
7631812
hybrid latency/loss and concealed losses code
Aug 14, 2018
fba2fba
Merge branch 'master' of github.com:brentondwalker/MoonGen
Aug 14, 2018
d7edd7a
check back in the concealed losses code.
Aug 14, 2018
ccca1f8
implement catch-up mode in l2-forward-hybrid-latency-rate-loss.lua
brentondwalker Sep 14, 2018
d49d7d6
Merge branch 'master' of github.com:brentondwalker/MoonGen
brentondwalker Sep 14, 2018
d370fed
updated libmoon ref
brentondwalker Sep 17, 2018
7ad5c70
add loss, extra latency, concealed loss, catchup rate options to l2-f…
brentondwalker Sep 17, 2018
6c77833
an lot of debugging output added. will remove next
brentondwalker Sep 27, 2018
dbf6417
clean up l2-forward-bsring-hybrid-latency-rate.lua and remove debuggi…
brentondwalker Sep 28, 2018
18a66fd
cleaning up fancy forwarding scripts
brentondwalker Oct 1, 2018
8327704
integrate PktSizedRing into link emulation scripts
brentondwalker Oct 9, 2018
ab1c515
updating libmoon to latest
brentondwalker Nov 8, 2018
35426cd
update reference to libmoon
brentondwalker Nov 9, 2018
6c24b3a
update version of libmoon
Nov 15, 2018
3dde7a9
initial support for l2 latency and loss emulation
Nov 20, 2018
9fb3cf3
Merge branch 'master' of github.com:brentondwalker/MoonGen
Nov 20, 2018
11faf0b
initial support for l2 latency and loss emulation
Nov 20, 2018
a329865
libmoon version
Nov 20, 2018
81a7268
Merge branch 'master' of github.com:brentondwalker/MoonGen
Nov 20, 2018
c32564e
libmoon version
Nov 20, 2018
2a73c1f
explicitly free mbufs that are dropped due to emulated packet losses
Nov 27, 2018
2fc377e
libmoon version to explicitly free dropped mbufs
Nov 27, 2018
b4afc7a
Merge remote-tracking branch 'origin/linkemulation-pullreq'
brentondwalker Mar 27, 2019
e3ec335
changing libmoon submodule to use https
brentondwalker Mar 28, 2019
5ac5efa
check in script that uses pipe:newBytesizedtxRing
Mar 28, 2019
c17d480
Merge branch 'master' of github.com:brentondwalker/MoonGen into linke…
Mar 28, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
[submodule "libmoon"]
path = libmoon
url = https://github.com/libmoon/libmoon
url = https://github.com/brentondwalker/libmoon.git
branch = master

194 changes: 194 additions & 0 deletions examples/ipt-rate-set-crc.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,194 @@
local mg = require "moongen"
local memory = require "memory"
local device = require "device"
local ts = require "timestamping"
local hist = require "histogram"
local log = require "log"
local timer = require "timer"
local limiter = require "software-ratecontrol"
local stats = require "stats"

local ETH_DST = "11:12:13:14:15:16"


function master(txPort, rxPort, pattern, threads, pktSize, rate, waitTime)
if not rxPort or not txPort or not threads or not pktSize or not rate then
errorf("usage: txPort rxPort pattern threads pktSize rate [waitTime]")
return
end

--if (((pktSize+26)*8) > (1000*ipt)) then
-- errorf("requested packet size and inter-packet time is infeasible")
--end

--local rxDev = device.config{ port = rxPort, rxDescs = 4096, dropEnable = true }
--local txDev = device.config{ port = txPort, txQueues = threads, disableOffloads = true, dropEnable = false }
-- rxDev:wait()
-- txDev:wait()
<<<<<<< HEAD
--device.waitForLinks()
=======
device.waitForLinks()
>>>>>>> d1110772cdaf2ee21f1845884b2565922ef3bb12

local queue = rxDev:getRxQueue(0)
queue:enableTimestampsAllPackets()
local total = 0
local bufs = memory.createBufArray()
local times = {}
local sizes = {}
local timer = timer:new(waitTime)

local txDev = device.config({port = args.txDev, txQueues = 2, rxQueues = 2, disableOffloads = true})
local rxDev = device.config({port = args.rxDev, txQueues = 2, rxQueues = 2})
device.waitForLinks()

mg.startTask("loadSlave", txDev, rxDev, txDev:getTxQueue(0), args.rate, PKT_SIZE)
mg.startTask("timerSlave", txDev:getTxQueue(1), rxDev:getRxQueue(1), PKT_SIZE)
mg.waitForTasks()

for i = 1, threads do
-- local pktRate = (1000.0 * rate) / pktSize
mg.startTask("loadSlave", txDev:getTxQueue(i - 1), txDev, rate, i, threads, pktSize)
mg.startTask("timerSlave", txDev:getTxQueue(i), rxDev:getRxQueue(i), PKT_SIZE)
end

local hsz = hist:create()
local last = 0
while mg.running() do
local n = queue:recv(bufs)
for i = 1, n do
--if timer:expired() then
local ts = bufs[i]:getTimestamp()
times[#times + 1] = ts
local sz = bufs[i].pkt_len
-- print(i, sz, ts, ts-last)
last = ts
sizes[#sizes + 1] = sz
hsz:update(sz)
--end
end
total = total + n
bufs:free(n)
end

mg.waitForTasks()

hsz:print()
hsz:save("sizes.csv")
--for i, v in ipairs(sizes) do
-- print(i,v)
--end

local pkts = rxDev:getRxStats(port)
local h = hist:create()
local last
for i, v in ipairs(times) do
if last then
local diff = v - last
h:update(diff)
end
last = v
end

h:print()
h:save("histogram.csv")
log[(pkts - total > 0 and "warn" or "info")](log, "Lost packets: " .. pkts - total
.. " (this can happen if the NIC still receives data after this script stops the receive loop)")

end

function timerSlave(txQueue, rxQueue, size)
local timestamper = ts:newTimestamper(txQueue, rxQueue)
local hist = histogram:new()
-- wait for a second to give the other task a chance to start
mg.sleepMillis(1000)
local rateLimiter = timer:new(0.001)
while mg.running() do
rateLimiter:reset()
hist:update(timestamper:measureLatency(size))
rateLimiter:busyWait()
end
hist:print()
hist:save("histogram.csv")
end



function loadSlave2(queue, txDev, rate, threadId, numThreads, pktSize)
local ETH_DST = "11:12:13:14:15:16"
local PKT_SIZE = 60

local mem = memory.createMemPool(function(buf)
buf:getEthernetPacket():fill{
ethSrc = txDev,
ethDst = ETH_DST,
ethType = 0x1234
}
end)
local bufs = mem:bufArray()
while mg.running() do
bufs:alloc(PKT_SIZE)
queue:send(bufs)
end
end



function loadSlave333(queue, txDev, rate, threadId, numThreads, pktSize)
local ETH_DST = "11:12:13:14:15:16"
--local PKT_SIZE = 60

-- doing crc rate control requires us to know the link speed.
-- it is given in Mbps, just like the rate argument
local linkspeed = txDev:getLinkStatus().speed
print("linkspeed = "..linkspeed)

local mem = memory.createMemPool{n=4096, func=function(buf)
--local mem = memory.createMemPool(function(buf)
buf:getEthernetPacket():fill{
ethSrc = txDev,
ethDst = ETH_DST,
ethType = 0x1234
}
end}

-- larger batch size is useful when sending it through a rate limiter
local bufs = mem:bufArray() --(128)
-- local dist = pattern == "poisson" and poissonDelay or function(x) return x end
while mg.running() do
bufs:alloc(pktSize)
for _, buf in ipairs(bufs) do
--buf:setDelay(dist(10^10 / numThreads / 8 / (rate * 10^6) - pktSize - 24))
-- --buf:setDelay(1000000)
buf:setDelay((pktSize+24) * (linkspeed/rate - 1) )
end
-- the rate here doesn't affect the result afaict. It's just to help decide the size of the bad pkts
queue:sendWithDelay(bufs, rate * numThreads)
--queue:send(bufs)
end
end

function loadSlave(queue, dev, rate, threadId, numThreads, size)
print("using packet size "..size)
local linkspeed = dev:getLinkStatus().speed

local mem = memory.createMemPool(function(buf)
buf:getEthernetPacket():fill{
ethType = 0x1234
}
end)
local bufs = mem:bufArray()
local txStats = stats:newManualTxCounter(dev, "plain")
while mg.running() do
bufs:alloc(size)
for _, buf in ipairs(bufs) do
buf:setDelay((size+24) * (linkspeed/rate - 1) )
end
txStats:updateWithSize(queue:sendWithDelay(bufs), size)
end
txStats:finalize()
end



92 changes: 92 additions & 0 deletions examples/ipt-rate-set.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
local mg = require "moongen"
local memory = require "memory"
local device = require "device"
local ts = require "timestamping"
local hist = require "histogram"
local log = require "log"
local timer = require "timer"
local limiter = require "software-ratecontrol"

local ETH_DST = "11:12:13:14:15:16"


function master(txPort, rxPort, pattern, threads, pktSize, ipt, waitTime)
if not rxPort or not txPort or not threads or not pktSize or not ipt then
errorf("usage: txPort rxPort threads pktSize interpacket_time(us) [waitTime]")
end

if (((pktSize+26)*8) > (1000*ipt)) then
errorf("requested packet size and inter-packet time is infeasible")
end

local rxDev = device.config{ port = rxPort, rxDescs = 4096, dropEnable = true }
local txDev = device.config{port = txPort, txQueues = threads, disableOffloads = true}
-- rxDev:wait()
-- txDev:wait()
device.waitForLinks()

local queue = rxDev:getRxQueue(0)
queue:enableTimestampsAllPackets()
local total = 0
local bufs = memory.createBufArray()
local times = {}
local timer = timer:new(waitTime)

for i = 1, threads do
-- local pktRate = (1000.0 * rate) / pktSize
local rateLimiter = limiter:new(txDev:getTxQueue(i - 1), pattern, 1000*ipt)
mg.startTask("loadSlave", txDev:getTxQueue(i - 1), txDev, rateLimiter, i, threads, pktSize)
end

while mg.running() do
local n = queue:recv(bufs)
for i = 1, n do
if timer:expired() then
local ts = bufs[i]:getTimestamp()
times[#times + 1] = ts
end
end
total = total + n
bufs:free(n)
end

mg.waitForTasks()

local pkts = rxDev:getRxStats(port)
local h = hist:create()
local last
for i, v in ipairs(times) do
if last then
local diff = v - last
h:update(diff)
end
last = v
end
h:print()
h:save("histogram.csv")
log[(pkts - total > 0 and "warn" or "info")](log, "Lost packets: " .. pkts - total
.. " (this can happen if the NIC still receives data after this script stops the receive loop)")
end



function loadSlave(queue, txDev, rateLimiter, threadId, numThreads, pktSize)
local mem = memory.createMemPool(4096, function(buf)
buf:getEthernetPacket():fill{
ethSrc = txDev,
ethDst = ETH_DST,
ethType = 0x1234
}
end)

-- larger batch size is useful when sending it through a rate limiter
local bufs = mem:bufArray(128)
while mg.running() do
bufs:alloc(pktSize)
rateLimiter:send(bufs)
end
end




29 changes: 29 additions & 0 deletions examples/l2-cbr-ipt-runner.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/bin/bash

hist_base=$1

if [ "$#" -lt 2 ] || [ ${hist_base:0:1} == "-" ] ; then
echo "usage: l2-cbr-ipt-runner.sh <histfile_base> <other_arguments_for_lus_script...>"
exit
fi

declare rates=("10" "20" "40" "80" "160" "320" "640" "1000")
declare sizes=("1400" "688" "332" "154" "65" "60")

# get the path where this script is
dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
echo $dir

for size in "${sizes[@]}"
do
for rate in "${rates[@]}"
do
sudo $dir/../build/MoonGen $dir/../examples/l2-cbr-load-ipt.lua -r $rate -s $size "${@:2}"
$dir/../normalizer-ipt.pl histogram.csv > $hist_base-r$rate-s$size.csv
#echo $rate $hist_base"-r"$rate"-s"$size".csv"
#echo "${@:2}"
done
done



30 changes: 30 additions & 0 deletions examples/l2-cbr-latency-runner.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/bin/bash

hist_base=$1

if [ "$#" -lt 2 ] || [ ${hist_base:0:1} == "-" ] ; then
echo "usage: l2-cbr-latency-runner.sh <histfile_base> <other_arguments_for_lus_script...>"
exit
fi

declare rates=("10" "20" "40" "80")
# "160" "320" "640" "1000")
declare sizes=("1400" "688" "332" "154" "65" "60")

# get the path where this script is
dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
echo $dir

for size in "${sizes[@]}"
do
for rate in "${rates[@]}"
do
sudo $dir/../build/MoonGen $dir/../examples/l2-cbr-load-latency.lua -r $rate -s $size "${@:2}"
$dir/../normalizer.pl histogram.csv > $hist_base-r$rate-s$size.csv
#echo $rate $hist_base"-r"$rate"-s"$size".csv"
#echo "${@:2}"
done
done



Loading