local dpdk      = require "dpdk"
local memory    = require "memory"
local device    = require "device"
local stats     = require "stats"
function master(txPorts, minIp, numIps, rate)
    if not txPorts then
        printf("usage: txPort1[,txPort2[,...]] [minIP numIPs rate]")
 
        return
    end
    txPorts = tostring(txPorts)
    minIp = minIp or "10.0.0.1"
    numIps = numIps or 100
    rate = rate or 0
    for currentTxPort in txPorts:gmatch("(%d+),?") do
        currentTxPort = tonumber(currentTxPort) 
        local txDev = device.
config{ port = currentTxPort }
 
        txDev:wait()
        dpdk.
launchLua("loadSlave", currentTxPort, 0, minIp, numIps)
 
    end
end
function loadSlave(port, queue, minA, numIPs)
    --- parse and check 
ip addresses
 
    if minIP then
        printf("INFO: Detected an %s address.", minIP and "IPv4" or "IPv6")
 
    else
        errorf("ERROR: Invalid minIP: %s", minA)
 
    end
    -- min TCP packet size for IPv6 is 74 bytes (+ CRC)
    local packetLen = ipv4 and 60 or 74
    
    -- continue normally
    local queue = device.get(port):getTxQueue(queue)
            ethSrc="90:e2:ba:2c:cb:02", ethDst="90:e2:ba:35:b5:81", 
            ip4Dst="192.168.1.1", 
            ip6Dst="fd06::1",
            tcpSyn=1,
            tcpSeqNumber=1,
            tcpWindow=10,
            pktLength=packetLen }
    end)
    local counter = 0
    local c = 0
        bufs:alloc(packetLen)
        for i, buf in ipairs(bufs) do           
            
            --increment IP
            if ipv4 then
            else
            end
            if c < 3 then
                c = c + 1
            end
        end 
        --offload checksums to NIC
        bufs:offloadTcpChecksums(ipv4)
        
        queue:send(bufs)
        txStats:update()
    end
end