Skip to content

Commit

Permalink
Used logger in the more up-to-date sample scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
Dominik Scholz committed Sep 15, 2015
1 parent 1a9aa8a commit ee43a46
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 17 deletions.
7 changes: 4 additions & 3 deletions examples/compare-rate-control-mechanisms.lua
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ local filter = require "filter"
local timer = require "timer"
local stats = require "stats"
local hist = require "histogram"
local log = require "log"

-- required here because this script creates *a lot* of mempools
memory.enableCache()
Expand All @@ -22,7 +23,7 @@ local PKT_SIZE = 60
function master(...)
local txPort, rxPort, maxRate, steps = tonumberall(...)
if not txPort or not rxPort then
errorf("usage: txPort rxPort [maxRate (Mpps)] [steps]")
return log:info("usage: txPort rxPort [maxRate (Mpps)] [steps]")
end
local minRate = 0.02
maxRate = maxRate or 7.44
Expand All @@ -40,7 +41,7 @@ function master(...)
table.insert(results, result)
for i = 1, REPS do
for _, method in ipairs{"hardware", "software"} do
printf("Testing rate %f Mpps with %s rate control, test run %d", rate, method, i)
log:info("Testing rate %f Mpps with %s rate control, test run %d", rate, method, i)
txQueue:setRateMpps(method == "hardware" and rate or 0)
local loadTask = dpdk.launchLua("loadSlave", txQueue, rxDev, method == "software" and rate)
local timerTask = dpdk.launchLua("timerSlave", txDev, rxDev, txQueueTs, rxQueueTs, ("%s-%s-%d"):format(method, rate, i))
Expand Down Expand Up @@ -101,7 +102,7 @@ function loadSlave(queue, rxDev, rate)
txStats:finalize()
rxStats:finalize()
local loss = txStats.total - rxStats.total
printf("Packet loss: %d (%f%%)", loss, loss / txStats.total * 100)
log:info("Packet loss: %d (%f%%)", loss, loss / txStats.total * 100)
end

function timerSlave(txDev, rxDev, txQueue, rxQueue, id)
Expand Down
7 changes: 4 additions & 3 deletions examples/icmp-arp-responder.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ local dpdk = require "dpdk"
local memory = require "memory"
local device = require "device"
local utils = require "utils"
local log = require "log"

local arp = require "proto.arp"
local ip = require "proto.ip4"
Expand All @@ -14,7 +15,7 @@ function master(funny, port, ...)
end
port = tonumber(port)
if not port or select("#", ...) == 0 or ... == nil then
printf("usage: [--do-funny-things] port ip [ip...]")
log:info("usage: [--do-funny-things] port ip [ip...]")
return
end

Expand Down Expand Up @@ -54,8 +55,8 @@ end

function pingResponder(dev, funny)
if funny then
print("Note: most ping 'clients' do not support the --do-funny-things option and ignore our responses :(")
print("One notable exception is Linux ping from the iputils package")
log:info("Most ping 'clients' do not support the --do-funny-things option and ignore our responses :(")
log:info("One notable exception is Linux ping from the iputils package")
end

local devMac = dev:getMac()
Expand Down
3 changes: 2 additions & 1 deletion examples/l2-poisson-load-latency.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,15 @@ local filter = require "filter"
local stats = require "stats"
local timer = require "timer"
local histogram = require "histogram"
local log = require "log"


local PKT_SIZE = 60

function master(...)
local txPort, rxPort, rate = tonumberall(...)
if not txPort or not rxPort then
errorf("usage: txPort rxPort [rate (Mpps)]")
return log:info("usage: txPort rxPort [rate (Mpps)]")
end
rate = rate or 2
local txDev = device.config(txPort, 2, 2)
Expand Down
11 changes: 6 additions & 5 deletions examples/l3-load-latency.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ local hist = require "histogram"
local stats = require "stats"
local timer = require "timer"
local arp = require "proto.arp"
local log = require "log"

-- set addresses here
local DST_MAC = nil -- resolved via ARP on GW_IP or DST_IP, can be overriden with a string here
Expand All @@ -26,7 +27,7 @@ local ARP_IP = SRC_IP_BASE
function master(...)
local txPort, rxPort, rate, flows, size = tonumberall(...)
if not txPort or not rxPort then
return print("usage: txPort rxPort [rate [flows [pktSize]]]")
return log:info("usage: txPort rxPort [rate [flows [pktSize]]]")
end
flows = flows or 4
rate = rate or 2000
Expand Down Expand Up @@ -64,14 +65,14 @@ end

local function doArp()
if not DST_MAC then
printf("Performing ARP lookup on %s", GW_IP)
log:info("Performing ARP lookup on %s", GW_IP)
DST_MAC = arp.blockingLookup(GW_IP, 5)
if not DST_MAC then
printf("ARP lookup failed, using default destination mac address")
log:info("ARP lookup failed, using default destination mac address")
return
end
end
printf("Destination mac: %s", DST_MAC)
log:info("Destination mac: %s", DST_MAC)
end

function loadSlave(queue, rxDev, size, flows)
Expand Down Expand Up @@ -104,7 +105,7 @@ end
function timerSlave(txQueue, rxQueue, size, flows)
doArp()
if size < 84 then
printf("WARNING: packet size %d is smaller than minimum timestamp size 84. Timestamped packets will be larger than load packets.", size)
log:warn("Packet size %d is smaller than minimum timestamp size 84. Timestamped packets will be larger than load packets.", size)
size = 84
end
rxQueue.dev:filterTimestamps(rxQueue)
Expand Down
7 changes: 4 additions & 3 deletions examples/quality-of-service-test.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ local filter = require "filter"
local stats = require "stats"
local hist = require "histogram"
local timer = require "timer"
local log = require "log"

local PKT_SIZE = 124 -- without CRC
-- check out l3-load-latency.lua if you want to get this via ARP
Expand All @@ -20,7 +21,7 @@ local PORT_BG = 43

function master(txPort, rxPort, bgRate, fgRate)
if not txPort or not rxPort then
return print("usage: txPort rxPort [bgRate [fgRate]]")
return log:info("usage: txPort rxPort [bgRate [fgRate]]")
end
fgRate = fgRate or 100
bgRate = bgRate or 1500
Expand All @@ -41,8 +42,8 @@ function master(txPort, rxPort, bgRate, fgRate)
end
-- wait until the links are up
device.waitForLinks()
printf("Sending %d MBit/s background traffic to UDP port %d", bgRate, PORT_BG)
printf("Sending %d MBit/s foreground traffic to UDP port %d", fgRate, PORT_FG)
log:info("Sending %d MBit/s background traffic to UDP port %d", bgRate, PORT_BG)
log:info("Sending %d MBit/s foreground traffic to UDP port %d", fgRate, PORT_FG)
-- setup rate limiters for CBR traffic
-- see l2-poisson.lua for an example with different traffic patterns
txDev:getTxQueue(0):setRate(bgRate)
Expand Down
5 changes: 3 additions & 2 deletions examples/router.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ local dpdk = require "dpdk"
local memory = require "memory"
local device = require "device"
local stats = require "stats"
local log = require "log"
local lpm = require "lpm"
local serpent = require "Serpent"
local ffi = require "ffi"
Expand Down Expand Up @@ -30,7 +31,7 @@ function master(txPort, ...)
local arpRxQueue = txDev:getRxQueue(5)
local arpTxQueue = txDev:getTxQueue(3)
dpdk.launchLuaOnCore(2, arp.arpTask, {rxQueue = arpRxQueue, txQueue = arpTxQueue, ips = {"10.0.0.130", "10.0.0.10", "10.0.0.11", "10.0.0.12", "10.0.0.13", "10.0.0.129"}})
print("ARP slave running")
log:info("ARP slave running")

-- Create a new routing table.
-- The Table entry is given as our user specified C datatype:
Expand Down Expand Up @@ -105,7 +106,7 @@ function slave(lpmTable, distributor, rxQueues, maxBurstSize)
-- try to receive a maximum of maxBurstSize of packets/mbufs:
nrx = rxQueue:tryRecv(bufs, 0)
if (nrx > 0) then
print("rxed on queue " .. tostring(rxQueue.qid))
log:info("rxed on queue " .. tostring(rxQueue.qid))
-- prepare in_mask for the received packets
in_mask:clearAll()
in_mask:setN(nrx)
Expand Down

0 comments on commit ee43a46

Please sign in to comment.