Giter VIP home page Giter VIP logo

libmoon's Introduction

Abstract

LuaJIT + DPDK = fast and flexible packet processing at speeds above 100 Gbit/s.

Read and try out one of the examples to get started.

libmoon started out as the packet generator MoonGen which evolved into a more general framework for packet processing. You can read our IMC 2015 Research Paper (BibTeX) for a discussion of our architecture which remained unchanged in libmoon. Please use this paper as a canonical reference to libmoon if you are writing a paper or thesis.

The libmoon Framework

libmoon is a high-speed framework to develop DPDK applications in Lua and C/C++. Its main goal is to simplify the initial creation of new DPDK applications by providing a concise and solid framework to build upon. The core is a Lua wrapper for DPDK that simplifies operations that are typically extremely verbose in DPDK, e.g., device initialization. libmoon also simplifies protocol implementations and tests by providing an extensible packet header processing and parsing library.

Explicit multi-core support is at the heart of libmoon. Scripts define a master task that is executed on startup. This task configures devices and queues and then starts one or more slave tasks that then handle packet IO.

Note that Lua does not have any native support for multi-threading. libmoon therefore starts a new and completely independent LuaJIT VM for each task. Tasks can only share state through communication primitives provided by libmoon. The example script inter-task-communication.lua showcases the available communication methods.

Further Examples and Applications Built on libmoon

The MoonGen packet generator features user scripts that are essentially small libmoon applications. Hence, MoonGen's examples may be useful.

FlowScope is a traffic analysis tool using libmoon. It's a good example on integration libmoon with custom C++ code.

Installation

Just run build.sh, bind-interfaces.sh, and setup-hugetlbfs.sh. When using Mellanox NICs additional steps are neccessary.

# install dependencies and compile libmoon
sudo apt-get install git build-essential cmake linux-headers-`uname -r` lshw libnuma-dev
git clone https://github.com/libmoon/libmoon
cd libmoon
./build.sh
# bind all NICs that are not actively used (no IP configured) to DPDK
sudo ./bind-interfaces.sh
# configure hugetlbfs
sudo ./setup-hugetlbfs.sh
# run the hello-world example
sudo ./build/libmoon examples/hello-world.lua

Note: Use deps/dpdk/tools/dpdk-devbind.py to manage NIC drivers manually to get them back into the OS.

Dependencies

  • gcc >= 4.8
  • make
  • cmake
  • kernel headers (for the DPDK igb-uio driver)
  • lspci (for dpdk-devbind.py)
  • libnuma-dev

FAQ

Which NICs do you support?

libmoon supports all NICs supported by DPDK. Note that some NICs (e.g., Mellanox) require external components to work with DPDK. Refer to the DPDK documentation for further information. We test and develop libmoon on various NICs of the ixgbe, i40e, and igb family.

Why should I use this instead of DPDK directly?

It's easier to get started. Seriously, have you tried reading one of the DPDK examples?

Why should I use this instead of Snabb?

Snabb has a completely different approach. They build their own drivers and generally do not rely on hardware capabilities (e.g., filtering and offloading). libmoon is just a wrapper for DPDK and heavily uses hardware-specific features.

libmoon's People

Contributors

ap-frank avatar ashokkumarprajapati avatar bmichalo avatar bonkf avatar csbisa avatar drizzt avatar emmericp avatar fstreun avatar holzingk avatar james-jra avatar johndickinson avatar knifemaster007 avatar manuel-simon avatar pudelkom avatar sn0cr avatar taeroen avatar thomas-schultz avatar todfreed avatar xaki23 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

libmoon's Issues

cpu usage reduction

Hi,

I started using libmoon and it is a great project. It captures and dumps packets without any drops. Our packets are much larger than minimum packet size, we receive approximately 1.5Mpps for 10Gbps. Therefore I wonder, if it is possible to reduce cpu usage of libmoon. Currently it uses all the cpu (i.e for 8 threads, 8 x 100% = 800% cpu usage), since it is polling all the time. There is a sample application in DPDK documentation[1] for power management. I want to use C-states (i.e sleep when possible). How can I achieve that when using dump-pkts.lua (https://github.com/libmoon/libmoon/blob/master/examples/dump-pkts.lua)?

Dump-pkts uses tryRecv with 100 microseconds

local rx = queue:tryRecv(bufs, 100)

And it seems that tryRecv method sleeps for 1 micro seconds for every loop:

libmoon/lua/device.lua

Lines 860 to 875 in e9a933b

function rxQueue:tryRecv(bufArray, maxWait)
maxWait = maxWait or math.huge
while maxWait >= 0 do
local rx = dpdkc.rte_eth_rx_burst_export(self.id, self.qid, bufArray.array, bufArray.size)
if rx > 0 then
return rx
end
maxWait = maxWait - 1
-- don't sleep pointlessly
if maxWait < 0 then
break
end
libmoon.sleepMicros(1)
end
return 0
end

Is 1 micro seconds not enough in order to reduce CPU usage? Should I change the libmoon code to something higher or is there any other way to achive that? Could you please help me or point me the right direction?

[1] http://doc.dpdk.org/guides/sample_app_ug/l3_forward_power_man.html

libmoon can't find qlogic QL41000 nic while dpdk example app can work

I can succesfully run the dpdk example application (e.g. l2fwd) with this qlogic 41000 seriese nic card, howerver I can't get it work with libmoon example application. It shows "there are only 0 ports, tried to configure port id 0".

Please help, I 've been stuck with this issue for almost a week.

"dpdk-devbind -s "
Network devices using DPDK-compatible driver

0000:19:00.0 'FastLinQ QL41000 Series 10/25/40/50GbE Controller 8070' drv=igb_uio unused=
0000:19:00.1 'FastLinQ QL41000 Series 10/25/40/50GbE Controller 8070' drv=igb_uio unused=
0000:19:00.2 'FastLinQ QL41000 Series 10/25/40/50GbE Controller 8070' drv=igb_uio unused=
0000:19:00.3 'FastLinQ QL41000 Series 10/25/40/50GbE Controller 8070' drv=igb_uio unused=
0000:86:00.0 'FastLinQ QL41000 Series 10/25/40/50GbE Controller 8070' drv=igb_uio unused=
0000:86:00.1 'FastLinQ QL41000 Series 10/25/40/50GbE Controller 8070' drv=igb_uio unused=

=====libmoon example app fails =========================
build/libmoon examples/l2-forward.lua 0 1
[INFO] Initializing DPDK. This will take a few seconds...
EAL: Detected 40 lcore(s)
EAL: No free hugepages reported in hugepages-1048576kB
EAL: Probing VFIO support...
[INFO] Found 0 usable devices:
[FATAL] Lua error in task master
/home/ct_tongxz/libmoon/lua/device.lua:100: there are only 0 ports, tried to configure port id 0

======dpdk example app succeeds=========================

./l2fwd -- -port 0x3

EAL: Detected 40 lcore(s)
EAL: No free hugepages reported in hugepages-1048576kB
EAL: Probing VFIO support...
EAL: PCI device 0000:19:00.0 on NUMA socket 0
EAL: probe driver: 1077:8070 net_qede
EAL: PCI device 0000:19:00.1 on NUMA socket 0
EAL: probe driver: 1077:8070 net_qede
EAL: PCI device 0000:19:00.2 on NUMA socket 0
EAL: probe driver: 1077:8070 net_qede
EAL: PCI device 0000:19:00.3 on NUMA socket 0
EAL: probe driver: 1077:8070 net_qede
EAL: PCI device 0000:86:00.0 on NUMA socket 1
EAL: probe driver: 1077:8070 net_qede
EAL: PCI device 0000:86:00.1 on NUMA socket 1
EAL: probe driver: 1077:8070 net_qede
MAC updating enabled
Lcore 0: RX port 0
Lcore 1: RX port 1
Lcore 2: RX port 2
Lcore 3: RX port 3
Lcore 4: RX port 4
Lcore 5: RX port 5
Initializing port 0... done:
Port 0, MAC address: 34:80:0D:43:32:1C

Initializing port 1... done:
Port 1, MAC address: 34:80:0D:43:32:1D

Initializing port 2... done:
Port 2, MAC address: 34:80:0D:43:32:1E

Initializing port 3... done:
Port 3, MAC address: 34:80:0D:43:32:1F

Initializing port 4... done:
Port 4, MAC address: 34:80:0D:4A:FC:82

Initializing port 5... done:
Port 5, MAC address: 34:80:0D:4A:FC:83

Checking link status..........................................................................................done
Port 0 Link Down
Port 1 Link Down
Port 2 Link Up - speed 1000 Mbps - full-duplex
Port 3 Link Up - speed 1000 Mbps - full-duplex
Port 4 Link Down
Port 5 Link Down
L2FWD: entering main loop on lcore 1
L2FWD: -- lcoreid=1 portid=1
L2FWD: entering main loop on lcore 3
L2FWD: -- lcoreid=3 portid=3
L2FWD: entering main loop on lcore 2
L2FWD: lcore 7 has nothing to do
L2FWD: entering main loop on lcore 4
L2FWD: -- lcoreid=4 portid=4
L2FWD: lcore 6 has nothing to do
L2FWD: lcore 14 has nothing to do
L2FWD: lcore 8 has nothing to do
L2FWD: -- lcoreid=2 portid=2
L2FWD: lcore 12 has nothing to do
L2FWD: lcore 13 has nothing to do
L2FWD: lcore 9 has nothing to do
L2FWD: lcore 15 has nothing to do
L2FWD: entering main loop on lcore 5
L2FWD: -- lcoreid=5 portid=5
L2FWD: lcore 11 has nothing to do
L2FWD: lcore 10 has nothing to do
L2FWD: lcore 16 has nothing to do
L2FWD: lcore 17 has nothing to do
L2FWD: lcore 18 has nothing to do
L2FWD: lcore 19 has nothing to do
L2FWD: lcore 21 has nothing to do
L2FWD: lcore 22 has nothing to do
L2FWD: lcore 28 has nothing to do
L2FWD: lcore 30 has nothing to do
L2FWD: lcore 25 has nothing to do
L2FWD: lcore 27 has nothing to do
L2FWD: lcore 23 has nothing to do
L2FWD: lcore 35 has nothing to do
L2FWD: lcore 20 has nothing to do
L2FWD: lcore 32 has nothing to do
L2FWD: lcore 33 has nothing to do
L2FWD: lcore 24 has nothing to do
L2FWD: lcore 36 has nothing to do
L2FWD: lcore 31 has nothing to do
L2FWD: lcore 26 has nothing to do
L2FWD: entering main loop on lcore 0
L2FWD: -- lcoreid=0 portid=0

Port statistics ====================================
Statistics for port 0 ------------------------------
Packets sent: 0
Packets received: 0
Packets dropped: 0
Statistics for port 1 ------------------------------
Packets sent: 0
Packets received: 0
Packets dropped: 0
Statistics for port 2 ------------------------------
Packets sent: 0
Packets received: 6296
Packets dropped: 0
Statistics for port 3 ------------------------------
Packets sent: 6298
Packets received: 0
Packets dropped: 0
Statistics for port 4 ------------------------------

Serpent serializer may corrupt data

MoonGen uses Serpent to pass data between it's tasks. The problem is Serpent is unable to serialize some objects. For instance, a queue object (both RX and TX) appears to be broken after deserilization. Also the problem is with MAC address, which is represented by a floating point value in Lua (since Lua does not have 64-bit integers), so the less significant bits may be corrupted after deserialization.

In both issues I used some workaroud in my cloned MoonGen:

Memory leaks due to missing destructors

Using the both the slow and fast pipes inevitably leads to memory leaks as there are no functions to delete them after use.

Direct leak of 616 byte(s) in 1 object(s) allocated from:
    #0 0x7fcd4c9bf532 in operator new(unsigned long) (/usr/lib/gcc/x86_64-linux-gnu/5/libasan.so+0x99532)
    #1 0x437f31 in pipe_mpmc_new /home/pudelko/FlowScope/libmoon/src/pipe.cpp:35
Direct leak of 88 byte(s) in 1 object(s) allocated from:
    #0 0x7fcd4c9bf532 in operator new(unsigned long) (/usr/lib/gcc/x86_64-linux-gnu/5/libasan.so+0x99532)
    #1 0x4378d9 in pipe_spsc_new /home/pudelko/FlowScope/libmoon/src/pipe.cpp:13
    #2 0x480dd5 in lj_ccall_func (/home/pudelko/FlowScope/libmoon/build/libmoon+0x480dd5)

I think the easiest way to solve this is adding pipe_{mpmc,spsc}_delete() functions in pipe.cpp which simply call delete *queue; and appropriate wrappers in pipe.lua.

attempt to index local 'fw' error with Pktgen

Hi, I'm getting this error

root@vm1-dpi:/home/vm1/Desktop/libmoon# sudo ./build/libmoon examples/pktgen.lua 0

root@vm1-dpi:/home/vm1/Desktop/libmoon# sudo ./build/libmoon examples/pktgen.lua 0
[INFO]  Initializing DPDK. This will take a few seconds...
EAL: Detected 8 lcore(s)
EAL: Probing VFIO support...
EAL: VFIO support initialized
EAL: WARNING: cpu flags constant_tsc=yes nonstop_tsc=no -> using unreliable clock cycles !
EAL: PCI device 0000:00:08.0 on NUMA socket -1
EAL:   Invalid NUMA socket, default to 0
EAL:   probe driver: 8086:154c net_i40e_vf
EAL:   using IOMMU type 8 (No-IOMMU)
EAL: PCI device 0000:00:09.0 on NUMA socket -1
EAL:   Invalid NUMA socket, default to 0
EAL:   probe driver: 8086:154c net_i40e_vf
[INFO]  Found 1 usable devices:
   Device 0: 42:7D:17:31:2B:6A (Intel Corporation XL710/X710 Virtual Function)
[INFO]  Check out MoonGen (built on lm) if you are looking for a fully featured packet generator
[INFO]  https://github.com/emmericp/MoonGen
[WARN]  Failed to get firmware version: -95
[FATAL] Lua error in task master
/home/vm1/Desktop/libmoon/lua/device.lua:210: attempt to index local 'fw' (a nil value)
Stack Traceback
===============
(2) Lua function 'master' at file 'examples/pktgen.lua:47' (best guess)
	Local variables:
	 args = table: 0x40eb9670  {dev:table: 0x41bd4ec8, threads:1}
	 arpQueues = table: 0x41af9b40  {}
	 (for generator) = C function: builtin#6
	 (for state) = table: 0x41bd4ec8  {1:0}
	 (for control) = number: 1
	 i = number: 1
	 dev = number: 0
(3) global C function 'xpcall'
(4) Lua upvalue 'master' at file '/home/vm1/Desktop/libmoon/lua/main.lua:96'
	Local variables:
	 _ = string: "./build/libmoon"
	 file = string: "examples/pktgen.lua"
	 args = table: 0x4126d988  {1:0}
	 cfgFile = nil
	 ok = boolean: true
	 parsedArgs = table: 0x41b580c0  {1:table: 0x40eb9670}
(5) Lua function 'main' at file '/home/vm1/Desktop/libmoon/lua/main.lua:146' (best guess)
	Local variables:
	 task = string: "master"
	/home/vm1/Desktop/libmoon/lua/device.lua:210: attempt to index local 'fw' (a nil value)

I have enabled IOMMU because otherwise my port would not bind.

I'm using Intel X710 card and have created virtual functions.

DPDK 18.02.2 compatibility

Hello there.
In current project i am trying to build MoonGen+libmoon on machine, that must run the specific version of DPDK(other applications are using it). Your mirror repository do not currently have tag for DPDK 18.02.2 so a have to come up with some workaround of build scripts (and buildin dependencies) of MoonGen+libmoon.
This is the part of build script that i use:

if [[ $GET_MOON ]]; then
	(	#get moongen
		cd $BUILD_ROOT
		if [[ -d "MoonGen" ]]; then
			rm -rf MoonGen
		fi
		git clone https://github.com/emmericp/MoonGen.git
		cd MoonGen
		git submodule update --init libmoon
		(	#get libmoon
			cd libmoon
			#init libmoon submodules
			git submodule init
			git submodule deinit deps/dpdk
			git submodule update
			#replace dpdk submodule with one builded by us
			rm -rf ./deps/dpdk
			ln -s $DPDK_SDK ./deps/dpdk
		)	
	)
fi

if [[ $BUILD_MOON ]]; then
	(	#build moongen
		cd $BUILD_ROOT/MoonGen
		(	#build libmoon deps
			cd libmoon
			(	#luajit
				cd deps/luajit
				make -j $CPU_COUNT BUILDMODE=static 'CFLAGS=-DLUAJIT_NUMMODE=2 -DLUAJIT_ENABLE_LUA52COMPAT'
				make install DESTDIR=$(pwd)
			)
			(	#lua/lb/turbo
				cd lua/lib/turbo
				make 2> /dev/null
				if [[ $? > 0 ]]; then
					make SSL=none
				fi
			)
		)
		cd build && cmake ..
		make -j $CPU_COUNT
	)
fi

Where DPDK_SDK is the path current DPDK SKD instance.
This scrip is a carfull copy of build.sh from MoonGen and libmoon repos.
But, when building a libmoon the next error messages are occur:

MoonGen/libmoon/src/kni.c: In function ‘mg_create_kni’:
MoonGen/libmoon/src/kni.c:45:31: error: dereferencing pointer to incomplete type ‘struct rte_pci_device’
   conf.addr = dev_info.pci_dev->addr;
                               ^~
MoonGen/libmoon/src/kni.c:56:18: warning: assignment from incompatible pointer type [-Wincompatible-pointer-types]
   ops.change_mtu = kni_change_mtu;
                  ^
MoonGen/libmoon/src/kni.c:58:25: warning: assignment from incompatible pointer type [-Wincompatible-pointer-types]
   ops.config_network_if = kni_config_network_interface;
                         ^
make[2]: *** [libmoon/CMakeFiles/moon.dir/src/kni.c.o] Error 1
make[2]: *** Waiting for unfinished jobs....
MoonGen/libmoon/src/device.c: In function ‘dpdk_configure_device’:
MoonGen/libmoon/src/device.c:173:53: error: dereferencing pointer to incomplete type ‘struct rte_pci_device’
   registers[cfg->port] = (uint8_t*) dev_info.pci_dev->mem_resource[0].addr;
                                                     ^~
MoonGen/libmoon/src/device.c: In function ‘dpdk_get_pci_function’:
MoonGen/libmoon/src/device.c:192:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^
MoonGen/libmoon/src/device.c: In function ‘dpdk_get_pci_id’:
MoonGen/libmoon/src/device.c:216:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^
In file included from MoonGen/libmoon/deps/dpdk/drivers/net/ixgbe/ixgbe_ipsec.h:8:0,
                 from MoonGen/libmoon/deps/dpdk/drivers/net/ixgbe/ixgbe_ethdev.h:13,
                 from MoonGen/libmoon/src/timestamping_ixgbe.c:4:
MoonGen/libmoon/deps/dpdk/x86_64-native-linuxapp-gcc/include/rte_security.h: In function ‘rte_security_attach_session’:
MoonGen/libmoon/deps/dpdk/x86_64-native-linuxapp-gcc/include/rte_security.h:428:2: warning: ‘__rte_security_attach_session’ is deprecated: Symbol is not yet part of stable ABI [-Wdeprecated-declarations]
  return __rte_security_attach_session(op->sym, sess);
  ^~~~~~
MoonGen/libmoon/deps/dpdk/x86_64-native-linuxapp-gcc/include/rte_security.h:389:1: note: declared here
 __rte_security_attach_session(struct rte_crypto_sym_op *sym_op,
 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
make[2]: *** [libmoon/CMakeFiles/moon.dir/src/device.c.o] Error 1
make[1]: *** [libmoon/CMakeFiles/moon.dir/all] Error 2
make: *** [all] Error 2

Which indicates that struct rte_pci_device which is defined in /dpdk/drivers/bus/pci/rte_bus_pci.h can't be accessed from libmoon/src/device.c and libmoon/src/kni.c
I like to hear your thoughts about this problem. I think that it is some incompatibility with newer version of DPDK

negative TCP sequence numbers

getSeqNumber() and getAckNumber() as well as the get*String() methods will return negative values.
Additionally the comment should say 32 instead of 8 bit integer.

long protocol stacks crash buf:dump() with colors enabled

got this error when I tried to call dump() on a packet that decodes as:
ethernet -> ip4 -> udp -> vxlan -> ethernet -> ip4 -> udp -> sflow

/root/phobos/build/../lua/colors.lua:49: attempt to concatenate local 'color' (a nil value)
Stack Traceback
===============
(2) Lua global 'dumpHex' at file '/root/phobos/build/../lua/utils.lua:322'
    Local variables:
     bytes = number: 1365
     stream = file (0x7f9b92edc2a0)
     seps = table: 0x405a3ba8  {1:14, 2:34, 3:42, 4:50, 5:64, 6:84, 7:92, 8:120}
     cSep = number: 9
     cColor = string: ""
     (for index) = number: 120
     (for limit) = number: 1364
     (for step) = number: 1
     i = number: 120
(3) Lua method 'dump' at file '/root/phobos/build/../lua/packet.lua:425'
    Local variables:
     bytes = number: 1365
     stream = file (0x7f9b92edc2a0)
     colorized = boolean: true
     seps = table: 0x405a3ba8  {1:14, 2:34, 3:42, 4:50, 5:64, 6:84, 7:92, 8:120}
     colorCode = string: "\27[1;33m"
(4) Lua method 'dump' at file '/root/phobos/build/../lua/packet.lua:127'
    Local variables:
     bytes = nil
     stream = nil
     colorized = boolean: true
(5) Lua function 'master' at file 'vxlan-flood-analyze.lua:18' (best guess)
    Local variables:
     args = table: 0x413971a8  {file:/raid0/bursts-16-10-06-16-28.pcap}
     bufs = table: 0x412aec10  {array:cdata<struct rte_mbuf *[?]>: 0x40bc08d8, maxSize:63, size:63, mem:cdata<struct mempool *>: 0x7f9b50e3b100 (more...)}
     pcapFile = table: 0x41e9acf0  {fd:cdata<struct 1314>: 0x4127a0f0, offset:541674, size:44354468227, ptr:cdata<unsigned char *>: 0x7f90f823e000 (more...)}
     n = number: 63
     (for index) = number: 3
     (for limit) = number: 63
     (for step) = number: 1
     i = number: 3
(6) global C function 'xpcall'
(7) Lua upvalue 'master' at file '/root/phobos/build/../lua/main.lua:96'
    Local variables:
     _ = string: "./phobos/build/phobos"
     file = string: "vxlan-flood-analyze.lua"
     args = table: 0x412f5158  {1:/raid0/bursts-16-10-06-16-28.pcap}
     cfgFile = nil
     ok = boolean: true
     parsedArgs = table: 0x40a23c78  {1:table: 0x413971a8}
(8) Lua function 'main' at file '/root/phobos/build/../lua/main.lua:141' (best guess)
    Local variables:
     task = string: "master"
    /root/phobos/build/../lua/colors.lua:49: attempt to concatenate local 'color' (a nil value)

Logo design

I am a designer who loves to help open sources. I designed a logo for you. I can give you a gift if you want to use it. What do you think?

libmoon

The relationship between numpkts and bufs.size, and the impact of batching on performance after receiving packets

In the dump-pkts.lua,the function tryrecv() sets the maximum number of packets to 100, but the length of bufs.size is 63.The number of packets obtained from the rx queue at a time is the minimum of the array length and the numpkt.what is the setting effect of 100?
Second, after receiving the packet, if I add a necessary processing to the program, it will definitely affect performance. Whether I set a reasonable grouping to operate can reduce the impact on performance.Sixty-three data packets are stored in a single batch, not one by one.
I look forward to receiving your reply.

fast enough fastpipes?

Hi,

I am working on a script to count and analyse packets by frequency sketchs. As you can see in the attached simplified script rx-count-pipe.lua.txt (based on rx-pkts-distribution.lua), the sketchUpdate function holds a counter according to the data that it receives from counterSlave via a fast pipe. I am having some trouble to count with the "sketch" function a similar amount of packets than counterSlave. After sending ~100M packets from a generator at 10Gbps rate, I am having results like this (~20M from those 100M):

^C[Device: id=0] RX: 6.25 (StdDev 5.85) Mpps, 4200 (StdDev 3932) Mbit/s (5200 Mbit/s with framing), total 100000026 packets with 8400002184 bytes (incl. CRC)
[Packets counted] RX: 6.25 (StdDev 5.85) Mpps, 4200 (StdDev 3932) Mbit/s (5200 Mbit/s with framing), total 100000026 packets with 8400002184 bytes (incl. CRC)
Pipe-relying function counted: 21193438

Are the fast pipes suitable for this kind of fast intertask communication, without "losing" packets?

Cheers, and thanks for this great framework!

Santiago

Additional packet types

Would you be able to add constructors for ethernet vlan packets with udp and/or tcp fields built in? It is straightforward to do ( for example, in my case, I directly edited packet.lua to add a vlan field to getUdpPacket), is there any reason why you opted not to given how many different options you built in? Can do a pull request if needed, but it is only a couple of lines of code.

ARP packets show false SRC-IP

src and dst ip is the same in arp.lua (line 510)
pkt.arp:setProtoDst(parseIPAddress(nic.ips[1]))
pkt.arp:setProtoSrc(parseIPAddress(nic.ips[1]))

startArpTask can be called with a table for 'ips', but only the first is used.

Still, arp works, but it looks wrong if monitored via tcpdump:
arp who-has 192.168.110.100 (ff:ff:ff:ff:ff:ff) tell 192.168.110.100

IcmpTask takes control of RxQueue causing other functions to wait forever.

In my master function i started Icmp Task followed by counter slave:

icmp.startIcmpTask({txQueue= txQueue, rxQueue = rxQueue, ips = args.ip}) mg.startTask("counterSlave", rxQueue, args)

counter function is as below:
`
function counterSlave(rxQueue, txQueue, args)

local bufs = memory.bufArray(128)
ctr = stats:newPktRxCounter("Port " .. args.dstPort, "plain")
while mg.running() do
    local rx = rxQueue:tryRecvIdle(bufs, 1) 
    for i = 1, rx do
        local buf = bufs[i]
        local pkt = buf:getUdpPacket()
        local port = pkt.udp:getDstPort()
        ctr:countPacket(buf)
    end
    ctr:update(1)
    bufs:freeAll()
    if (runtime:running() == false) then
        arp.stopArpTask()
        mg.stop()
    end
end
ctr:finalize()

`

My receiver counter is not getting any packets due to ICMP Task. if i comment IcmpTask then it gets working.

Build error

Host Details
Linux 5.3.0-40-generic x86_64
Intel(R) Xeon(R) CPU E5-2630 v3 @ 2.40GHz

Created a new docker using
docker pull ubuntu

Inside docker,
commands used:

  1. apt-get update && apt-get install -y build-essential automake python-pip libcap-ng-dev gawk pciutils linux-headers-$(uname -a | awk '{print $3}') vim kmod
    (took this from somewhere as dependancies for dpdk installation)
  2. sudo apt-get install -y build-essential cmake linux-headers-uname -r pciutils libnuma-dev
    (from moongen's official github repository as dependancies for Moongen)
  3. apt-get install git
  4. git clone https://github.com/emmericp/MoonGen
  5. cd MoonGen
  6. ./build.sh

`root@10ce5f37273b:/home/MoonGen# ./build.sh
Submodule 'libmoon' (https://github.com/libmoon/libmoon) registered for path 'libmoon'
Cloning into '/home/MoonGen/libmoon'...
Submodule path 'libmoon': checked out '606ccdae62a4a2104ad8fc7225407f08235bf309'
Build libmoon with MoonGen
Submodule 'deps/dpdk' (https://github.com/emmericp/dpdk) registered for path 'deps/dpdk'
Submodule 'deps/highwayhash' (https://github.com/google/highwayhash.git) registered for path 'deps/highwayhash'
Submodule 'deps/luajit' (https://github.com/emmericp/LuaJIT) registered for path 'deps/luajit'
Submodule 'deps/pciids' (https://github.com/emmericp/pciids) registered for path 'deps/pciids'
Submodule 'deps/tbb' (https://github.com/01org/tbb.git) registered for path 'deps/tbb'
Submodule 'lua/lib/pf' (https://github.com/emmericp/pflua) registered for path 'lua/lib/pf'
Submodule 'lua/lib/syscall' (https://github.com/emmericp/ljsyscall) registered for path 'lua/lib/syscall'
Submodule 'lua/lib/turbo' (https://github.com/emmericp/turbo) registered for path 'lua/lib/turbo'
Cloning into '/home/MoonGen/libmoon/deps/dpdk'...
Cloning into '/home/MoonGen/libmoon/deps/highwayhash'...
Cloning into '/home/MoonGen/libmoon/deps/luajit'...
Cloning into '/home/MoonGen/libmoon/deps/pciids'...
Cloning into '/home/MoonGen/libmoon/deps/tbb'...
Cloning into '/home/MoonGen/libmoon/lua/lib/pf'...
Cloning into '/home/MoonGen/libmoon/lua/lib/syscall'...
Cloning into '/home/MoonGen/libmoon/lua/lib/turbo'...
Submodule path 'deps/dpdk': checked out '90005150af162cf536e93dd7405774d47a69a479'
Submodule path 'deps/highwayhash': checked out '14dedecd1de87cb662f7a882ea1578d2384feb2f'
Submodule path 'deps/luajit': checked out '8271c643c21d1b2f344e339f559f2de6f3663191'
Submodule path 'deps/pciids': checked out 'eea0f7199045fbaf3800a499e867ef1a4e5d1f9e'
Submodule path 'deps/tbb': checked out 'd7e150913467f3c168ba6319c985cf341fd81012'
Submodule path 'lua/lib/pf': checked out 'b16b31aed678a3b8ce809391c9e6bcd67f70be0e'
Submodule path 'lua/lib/syscall': checked out '2a18b1b62947c597b4e573bb042483ff18434b6f'
Submodule path 'lua/lib/turbo': checked out 'd69c85a255a6ceed329813f04e40bd2a9cefcf5e'
==== Building LuaJIT 2.1.0-beta3 ====
make -C src
make[1]: Entering directory '/home/MoonGen/libmoon/deps/luajit/src'
HOSTCC host/minilua.o
HOSTCC host/buildvm_asm.o
HOSTCC host/buildvm_peobj.o
HOSTCC host/buildvm_lib.o
HOSTCC host/buildvm_fold.o
CC lj_gc.o
CC lj_char.o
CC lj_obj.o
CC lj_buf.o
CC lj_str.o
CC lj_tab.o
CC lj_func.o
CC lj_udata.o
CC lj_meta.o
CC lj_debug.o
CC lj_state.o
CC lj_vmevent.o
CC lj_vmmath.o
CC lj_strscan.o
CC lj_strfmt_num.o
CC lj_api.o
CC lj_strfmt.o
CC lj_profile.o
CC lj_lex.o
CC lj_parse.o
CC lj_bcread.o
CC lj_bcwrite.o
CC lj_load.o
CC lj_ir.o
CC lj_opt_mem.o
CC lj_opt_narrow.o
CC lj_opt_dce.o
CC lj_opt_loop.o
CC lj_opt_split.o
CC lj_opt_sink.o
CC lj_mcode.o
CC lj_snap.o
CC lj_asm.o
CC lj_trace.o
CC lj_gdbjit.o
CC lj_ctype.o
CC lj_cdata.o
CC lj_cconv.o
CC lj_ccall.o
CC lj_ccallback.o
CC lj_carith.o
CC lj_clib.o
CC lj_cparse.o
CC lj_lib.o
CC lj_alloc.o
CC lib_aux.o
CC lib_package.o
CC lib_init.o
CC luajit.o
HOSTLINK host/minilua
DYNASM host/buildvm_arch.h
HOSTCC host/buildvm.o
HOSTLINK host/buildvm
BUILDVM lj_vm.S
BUILDVM lj_bcdef.h
BUILDVM lj_ffdef.h
BUILDVM lj_folddef.h
BUILDVM lj_libdef.h
BUILDVM jit/vmdef.lua
BUILDVM lj_recdef.h
CC lj_bc.o
CC lj_err.o
CC lj_dispatch.o
CC lj_record.o
ASM lj_vm.o
CC lj_crecord.o
CC lib_base.o
CC lib_math.o
CC lib_bit.o
CC lib_string.o
CC lib_table.o
CC lib_io.o
CC lib_os.o
CC lib_debug.o
CC lib_jit.o
CC lib_ffi.o
CC lj_ffrecord.o
CC lj_opt_fold.o
AR libluajit.a
LINK luajit
OK Successfully built LuaJIT
make[1]: Leaving directory '/home/MoonGen/libmoon/deps/luajit/src'
==== Successfully built LuaJIT 2.1.0-beta3 ====
==== Installing LuaJIT 2.1.0-beta3 to /usr/local ====
mkdir -p /home/MoonGen/libmoon/deps/luajit/usr/local/bin /home/MoonGen/libmoon/deps/luajit/usr/local/lib /home/MoonGen/libmoon/deps/luajit/usr/local/include/luajit-2.1 /home/MoonGen/libmoon/deps/luajit/usr/local/share/man/man1 /home/MoonGen/libmoon/deps/luajit/usr/local/lib/pkgconfig /home/MoonGen/libmoon/deps/luajit/usr/local/share/luajit-2.1.0-beta3/jit /home/MoonGen/libmoon/deps/luajit/usr/local/share/lua/5.1 /home/MoonGen/libmoon/deps/luajit/usr/local/lib/lua/5.1
cd src && install -m 0755 luajit /home/MoonGen/libmoon/deps/luajit/usr/local/bin/luajit-2.1.0-beta3
cd src && test -f libluajit.a && install -m 0644 libluajit.a /home/MoonGen/libmoon/deps/luajit/usr/local/lib/libluajit-5.1.a || :
rm -f /home/MoonGen/libmoon/deps/luajit/usr/local/lib/libluajit-5.1.so.2.1.0 /home/MoonGen/libmoon/deps/luajit/usr/local/lib/libluajit-5.1.so /home/MoonGen/libmoon/deps/luajit/usr/local/lib/libluajit-5.1.so.2
cd src && test -f libluajit.so &&
install -m 0755 libluajit.so /home/MoonGen/libmoon/deps/luajit/usr/local/lib/libluajit-5.1.so.2.1.0 &&
ldconfig -n /home/MoonGen/libmoon/deps/luajit/usr/local/lib &&
ln -sf libluajit-5.1.so.2.1.0 /home/MoonGen/libmoon/deps/luajit/usr/local/lib/libluajit-5.1.so &&
ln -sf libluajit-5.1.so.2.1.0 /home/MoonGen/libmoon/deps/luajit/usr/local/lib/libluajit-5.1.so.2 || :
cd etc && install -m 0644 luajit.1 /home/MoonGen/libmoon/deps/luajit/usr/local/share/man/man1
cd etc && sed -e "s|^prefix=.|prefix=/usr/local|" -e "s|^multilib=.|multilib=lib|" luajit.pc > luajit.pc.tmp &&
install -m 0644 luajit.pc.tmp /home/MoonGen/libmoon/deps/luajit/usr/local/lib/pkgconfig/luajit.pc &&
rm -f luajit.pc.tmp
cd src && install -m 0644 lua.h lualib.h lauxlib.h luaconf.h lua.hpp luajit.h /home/MoonGen/libmoon/deps/luajit/usr/local/include/luajit-2.1
cd src/jit && install -m 0644 bc.lua bcsave.lua dump.lua p.lua v.lua zone.lua dis_x86.lua dis_x64.lua dis_arm.lua dis_arm64.lua dis_arm64be.lua dis_ppc.lua dis_mips.lua dis_mipsel.lua dis_mips64.lua dis_mips64el.lua vmdef.lua /home/MoonGen/libmoon/deps/luajit/usr/local/share/luajit-2.1.0-beta3/jit
==== Successfully installed LuaJIT 2.1.0-beta3 to /usr/local ====

Note: the development releases deliberately do NOT install a symlink for luajit
You can do this now by running this command (with sudo):

ln -sf luajit-2.1.0-beta3 /home/MoonGen/libmoon/deps/luajit/usr/local/bin/luajit

Configuration done using x86_64-native-linuxapp-gcc
== Build lib
== Build lib/librte_compat
== Build lib/librte_eal
SYMLINK-FILE include/rte_compat.h
== Build lib/librte_eal/common
SYMLINK-FILE include/generic/rte_atomic.h
SYMLINK-FILE include/generic/rte_byteorder.h
SYMLINK-FILE include/generic/rte_cycles.h
SYMLINK-FILE include/generic/rte_prefetch.h
SYMLINK-FILE include/generic/rte_memcpy.h
SYMLINK-FILE include/generic/rte_spinlock.h
SYMLINK-FILE include/generic/rte_cpuflags.h
SYMLINK-FILE include/generic/rte_rwlock.h
SYMLINK-FILE include/generic/rte_pause.h
SYMLINK-FILE include/generic/rte_io.h
SYMLINK-FILE include/generic/rte_vect.h
SYMLINK-FILE include/rte_branch_prediction.h
SYMLINK-FILE include/rte_common.h
SYMLINK-FILE include/rte_debug.h
SYMLINK-FILE include/rte_eal.h
SYMLINK-FILE include/rte_errno.h
SYMLINK-FILE include/rte_launch.h
SYMLINK-FILE include/rte_log.h
SYMLINK-FILE include/rte_memory.h
SYMLINK-FILE include/rte_lcore.h
SYMLINK-FILE include/rte_memzone.h
SYMLINK-FILE include/rte_per_lcore.h
SYMLINK-FILE include/rte_pci.h
SYMLINK-FILE include/rte_random.h
SYMLINK-FILE include/rte_tailq.h
SYMLINK-FILE include/rte_interrupts.h
SYMLINK-FILE include/rte_alarm.h
SYMLINK-FILE include/rte_string_fns.h
SYMLINK-FILE include/rte_version.h
SYMLINK-FILE include/rte_eal_memconfig.h
SYMLINK-FILE include/rte_hexdump.h
SYMLINK-FILE include/rte_malloc_heap.h
SYMLINK-FILE include/rte_devargs.h
SYMLINK-FILE include/rte_bus.h
SYMLINK-FILE include/rte_dev.h
SYMLINK-FILE include/rte_vdev.h
SYMLINK-FILE include/rte_pci_dev_feature_defs.h
SYMLINK-FILE include/rte_pci_dev_features.h
SYMLINK-FILE include/rte_keepalive.h
SYMLINK-FILE include/rte_malloc.h
SYMLINK-FILE include/rte_time.h
SYMLINK-FILE include/rte_service.h
SYMLINK-FILE include/rte_rwlock.h
SYMLINK-FILE include/rte_service_component.h
SYMLINK-FILE include/rte_memcpy.h
SYMLINK-FILE include/rte_cycles.h
SYMLINK-FILE include/rte_spinlock.h
SYMLINK-FILE include/rte_pause.h
SYMLINK-FILE include/rte_atomic_32.h
SYMLINK-FILE include/rte_vect.h
SYMLINK-FILE include/rte_prefetch.h
SYMLINK-FILE include/rte_byteorder_32.h
SYMLINK-FILE include/rte_atomic_64.h
SYMLINK-FILE include/rte_byteorder_64.h
SYMLINK-FILE include/rte_rtm.h
SYMLINK-FILE include/rte_cpuflags.h
SYMLINK-FILE include/rte_atomic.h
SYMLINK-FILE include/rte_io.h
SYMLINK-FILE include/rte_byteorder.h
== Build lib/librte_eal/linuxapp
== Build lib/librte_eal/linuxapp/eal
== Build lib/librte_eal/linuxapp/igb_uio
CC eal.o
CC eal_hugepage_info.o
CC eal_memory.o
CC eal_thread.o
CC eal_vfio.o
CC eal_log.o
CC eal_vfio_mp_sync.o
CC eal_pci.o
CC eal_pci_uio.o
CC eal_pci_vfio.o
CC eal_debug.o
CC eal_lcore.o
CC eal_timer.o
CC eal_interrupts.o
CC eal_alarm.o
CC eal_common_lcore.o
CC eal_common_timer.o
CC eal_common_memzone.o
CC eal_common_log.o
CC eal_common_launch.o
CC eal_common_vdev.o
CC eal_common_pci.o
CC eal_common_pci_uio.o
CC eal_common_memory.o
CC eal_common_tailqs.o
CC eal_common_errno.o
CC eal_common_cpuflags.o
CC eal_common_string_fns.o
CC eal_common_hexdump.o
CC eal_common_devargs.o
CC eal_common_bus.o
CC eal_common_dev.o
CC eal_common_options.o
CC eal_common_thread.o
CC eal_common_proc.o
CC rte_malloc.o
CC malloc_elem.o
CC malloc_heap.o
CC rte_keepalive.o
CC rte_service.o
CC rte_cpuflags.o
CC rte_spinlock.o
SYMLINK-FILE include/exec-env/rte_interrupts.h
SYMLINK-FILE include/exec-env/rte_kni_common.h
SYMLINK-FILE include/exec-env/rte_dom0_common.h
AR librte_eal.a
INSTALL-LIB librte_eal.a
CC [M] /home/MoonGen/libmoon/deps/dpdk/x86_64-native-linuxapp-gcc/build/lib/librte_eal/linuxapp/igb_uio/igb_uio.o
/home/MoonGen/libmoon/deps/dpdk/x86_64-native-linuxapp-gcc/build/lib/librte_eal/linuxapp/igb_uio/igb_uio.c: In function 'igbuio_pci_probe':
/home/MoonGen/libmoon/deps/dpdk/x86_64-native-linuxapp-gcc/build/lib/librte_eal/linuxapp/igb_uio/igb_uio.c:429:6: error: this statement may fall through [-Werror=implicit-fallthrough=]
if (pci_alloc_irq_vectors(dev, 1, 1, PCI_IRQ_MSIX) == 1) {
^
/home/MoonGen/libmoon/deps/dpdk/x86_64-native-linuxapp-gcc/build/lib/librte_eal/linuxapp/igb_uio/igb_uio.c:437:2: note: here
case RTE_INTR_MODE_LEGACY:
^~~~
In file included from /home/MoonGen/libmoon/deps/dpdk/x86_64-native-linuxapp-gcc/build/lib/librte_eal/linuxapp/igb_uio/igb_uio.c:27:0:
./include/linux/device.h:1561:2: error: this statement may fall through [-Werror=implicit-fallthrough=]
_dev_notice(dev, dev_fmt(fmt), ##VA_ARGS)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/MoonGen/libmoon/deps/dpdk/x86_64-native-linuxapp-gcc/build/lib/librte_eal/linuxapp/igb_uio/igb_uio.c:445:3: note: in expansion of macro 'dev_notice'
dev_notice(&dev->dev, "PCI INTX mask not supported\n");
^~~~~~~~~~
/home/MoonGen/libmoon/deps/dpdk/x86_64-native-linuxapp-gcc/build/lib/librte_eal/linuxapp/igb_uio/igb_uio.c:447:2: note: here
case RTE_INTR_MODE_NONE:
^~~~
cc1: all warnings being treated as errors
scripts/Makefile.build:288: recipe for target '/home/MoonGen/libmoon/deps/dpdk/x86_64-native-linuxapp-gcc/build/lib/librte_eal/linuxapp/igb_uio/igb_uio.o' failed
make[7]: *** [/home/MoonGen/libmoon/deps/dpdk/x86_64-native-linuxapp-gcc/build/lib/librte_eal/linuxapp/igb_uio/igb_uio.o] Error 1
Makefile:1655: recipe for target 'module/home/MoonGen/libmoon/deps/dpdk/x86_64-native-linuxapp-gcc/build/lib/librte_eal/linuxapp/igb_uio' failed
make[6]: *** [module/home/MoonGen/libmoon/deps/dpdk/x86_64-native-linuxapp-gcc/build/lib/librte_eal/linuxapp/igb_uio] Error 2
/home/MoonGen/libmoon/deps/dpdk/mk/rte.module.mk:78: recipe for target 'igb_uio.ko' failed
make[5]: *** [igb_uio.ko] Error 2
/home/MoonGen/libmoon/deps/dpdk/mk/rte.subdir.mk:63: recipe for target 'igb_uio' failed
make[4]: *** [igb_uio] Error 2
/home/MoonGen/libmoon/deps/dpdk/mk/rte.subdir.mk:63: recipe for target 'linuxapp' failed
make[3]: *** [linuxapp] Error 2
/home/MoonGen/libmoon/deps/dpdk/mk/rte.subdir.mk:63: recipe for target 'librte_eal' failed
make[2]: *** [librte_eal] Error 2
/home/MoonGen/libmoon/deps/dpdk/mk/rte.sdkbuild.mk:76: recipe for target 'lib' failed
make[1]: *** [lib] Error 2
/home/MoonGen/libmoon/deps/dpdk/mk/rte.sdkroot.mk:128: recipe for target 'all' failed
make: *** [all] Error 2
make -C deps/http-parser library
make[1]: Entering directory '/home/MoonGen/libmoon/lua/lib/turbo/deps/http-parser'
gcc -I. -fPIC -DHTTP_PARSER_STRICT=0 -O3 -Wall -Wextra -c http_parser.c -o libhttp_parser.o
gcc -shared -Wl,-soname=libhttp_parser.so.2.1 -o libhttp_parser.so.2.1 libhttp_parser.o
make[1]: Leaving directory '/home/MoonGen/libmoon/lua/lib/turbo/deps/http-parser'
gcc -Ideps/http-parser/ -shared -O3 -Wall -g -fPIC deps/http-parser/libhttp_parser.o deps/turbo_ffi_wrap.c -o libtffi_wrap.so -lcrypto -lssl
Makefile:87: recipe for target 'all' failed
Could not compile Turbo with TLS support, disabling TLS
Install libssl-dev and OpenSSL to enable TLS support
make -C deps/http-parser library
make[1]: Entering directory '/home/MoonGen/libmoon/lua/lib/turbo/deps/http-parser'
gcc -shared -Wl,-soname=libhttp_parser.so.2.1 -o libhttp_parser.so.2.1 libhttp_parser.o
make[1]: Leaving directory '/home/MoonGen/libmoon/lua/lib/turbo/deps/http-parser'
gcc -Ideps/http-parser/ -shared -O3 -Wall -g -fPIC -DTURBO_NO_SSL=1 deps/http-parser/libhttp_parser.o deps/turbo_ffi_wrap.c -o libtffi_wrap.so
set -eu; for file in highwayhash/.cc; do
target=obj/${file##
/}; target=${target%.}.o;
[ "$target" = "obj/highwayhash_target.o" ] ||
[ "$target" = "obj/data_parallel_benchmark.o" ] ||
[ "$target" = "obj/data_parallel_test.o" ] ||
g++ -c -I. -std=c++11 -Wall -O3 -fPIC -pthread -DHH_DISABLE_TARGET_SPECIFIC -MM -MT
"$target" "$file";
done | sed -e ':b' -e 's-../[^./]
/--' -e 'tb' >deps.mk
g++ -c -I. -std=c++11 -Wall -O3 -fPIC -pthread highwayhash/profiler_example.cc -o obj/profiler_example.o
g++ -c -I. -std=c++11 -Wall -O3 -fPIC -pthread highwayhash/arch_specific.cc -o obj/arch_specific.o
g++ -c -I. -std=c++11 -Wall -O3 -fPIC -pthread highwayhash/instruction_sets.cc -o obj/instruction_sets.o
g++ -c -I. -std=c++11 -Wall -O3 -fPIC -pthread highwayhash/nanobenchmark.cc -o obj/nanobenchmark.o
g++ -c -I. -std=c++11 -Wall -O3 -fPIC -pthread highwayhash/os_specific.cc -o obj/os_specific.o
g++ -pthread obj/profiler_example.o obj/arch_specific.o obj/instruction_sets.o obj/nanobenchmark.o obj/os_specific.o -o bin/profiler_example
g++ -c -I. -std=c++11 -Wall -O3 -fPIC -pthread highwayhash/nanobenchmark_example.cc -o obj/nanobenchmark_example.o
g++ -pthread obj/nanobenchmark_example.o obj/arch_specific.o obj/instruction_sets.o obj/nanobenchmark.o obj/os_specific.o -o bin/nanobenchmark_example
g++ -c -I. -std=c++11 -Wall -O3 -fPIC -pthread highwayhash/vector_test.cc -o obj/vector_test.o
g++ -c -I. -std=c++11 -Wall -O3 -fPIC -pthread highwayhash/vector_test_portable.cc -o obj/vector_test_portable.o
g++ -c -I. -std=c++11 -Wall -O3 -fPIC -pthread -mavx2 highwayhash/vector_test_avx2.cc -o obj/vector_test_avx2.o
g++ -c -I. -std=c++11 -Wall -O3 -fPIC -pthread -msse4.1 highwayhash/vector_test_sse41.cc -o obj/vector_test_sse41.o
g++ -pthread obj/vector_test.o obj/arch_specific.o obj/instruction_sets.o obj/nanobenchmark.o obj/os_specific.o obj/vector_test_portable.o obj/vector_test_avx2.o obj/vector_test_sse41.o -o bin/vector_test
g++ -c -I. -std=c++11 -Wall -O3 -fPIC -pthread highwayhash/sip_hash_test.cc -o obj/sip_hash_test.o
g++ -pthread obj/sip_hash_test.o -o bin/sip_hash_test
g++ -c -I. -std=c++11 -Wall -O3 -fPIC -pthread highwayhash/highwayhash_test.cc -o obj/highwayhash_test.o
g++ -c -I. -std=c++11 -Wall -O3 -fPIC -pthread highwayhash/highwayhash_test_portable.cc -o obj/highwayhash_test_portable.o
g++ -c -I. -std=c++11 -Wall -O3 -fPIC -pthread -mavx2 highwayhash/highwayhash_test_avx2.cc -o obj/highwayhash_test_avx2.o
g++ -c -I. -std=c++11 -Wall -O3 -fPIC -pthread -msse4.1 highwayhash/highwayhash_test_sse41.cc -o obj/highwayhash_test_sse41.o
g++ -pthread obj/highwayhash_test.o obj/arch_specific.o obj/instruction_sets.o obj/nanobenchmark.o obj/os_specific.o obj/highwayhash_test_portable.o obj/highwayhash_test_avx2.o obj/highwayhash_test_sse41.o -o bin/highwayhash_test
g++ -c -I. -std=c++11 -Wall -O3 -fPIC -pthread -mavx2 highwayhash/benchmark.cc -o obj/benchmark.o
g++ -c -I. -std=c++11 -Wall -O3 -fPIC -pthread highwayhash/sip_hash.cc -o obj/sip_hash.o
g++ -c -I. -std=c++11 -Wall -O3 -fPIC -pthread -mavx2 highwayhash/sip_tree_hash.cc -o obj/sip_tree_hash.o
g++ -c -I. -std=c++11 -Wall -O3 -fPIC -pthread highwayhash/scalar_sip_tree_hash.cc -o obj/scalar_sip_tree_hash.o
g++ -c -I. -std=c++11 -Wall -O3 -fPIC -pthread highwayhash/hh_portable.cc -o obj/hh_portable.o
g++ -c -I. -std=c++11 -Wall -O3 -fPIC -pthread -mavx2 highwayhash/hh_avx2.cc -o obj/hh_avx2.o
g++ -c -I. -std=c++11 -Wall -O3 -fPIC -pthread -msse4.1 highwayhash/hh_sse41.cc -o obj/hh_sse41.o
g++ -pthread obj/benchmark.o obj/arch_specific.o obj/instruction_sets.o obj/nanobenchmark.o obj/os_specific.o obj/highwayhash_test_portable.o obj/highwayhash_test_avx2.o obj/highwayhash_test_sse41.o obj/sip_hash.o obj/sip_tree_hash.o obj/scalar_sip_tree_hash.o obj/hh_portable.o obj/hh_avx2.o obj/hh_sse41.o -o bin/benchmark
g++ -c -I. -std=c++11 -Wall -O3 -fPIC -pthread highwayhash/c_bindings.cc -o obj/c_bindings.o
ar rcs lib/libhighwayhash.a obj/sip_hash.o obj/sip_tree_hash.o obj/scalar_sip_tree_hash.o obj/arch_specific.o obj/instruction_sets.o obj/nanobenchmark.o obj/os_specific.o obj/hh_portable.o obj/hh_avx2.o obj/hh_sse41.o obj/c_bindings.o

Disabled due to false positives; ideally the test instead ensures

target-specific modules only export symbols starting with a prefix.

./test_exports.sh obj/sip_hash.o obj/sip_tree_hash.o obj/scalar_sip_tree_hash.o obj/arch_specific.o obj/instruction_sets.o obj/nanobenchmark.o obj/os_specific.o obj/hh_portable.o obj/hh_avx2.o obj/hh_sse41.o obj/c_bindings.o

-- The C compiler identification is GNU 7.5.0
-- The CXX compiler identification is GNU 7.5.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Building Intel TBB: /usr/bin/make -j8 tbb_build_prefix=tbb_cmake_build_subdir tbb_build_dir=/home/MoonGen/build/libmoon/tbb_cmake_build compiler=gcc
-- Configuring done
-- Generating done
-- Build files have been written to: /home/MoonGen/build
Scanning dependencies of target moon
[ 3%] Building CXX object libmoon/CMakeFiles/moon.dir/src/barrier.cpp.o
[ 10%] Building C object libmoon/CMakeFiles/moon.dir/src/memory.c.o
[ 10%] Building CXX object libmoon/CMakeFiles/moon.dir/src/main.cpp.o
[ 13%] Building C object libmoon/CMakeFiles/moon.dir/src/device.c.o
[ 17%] Building CXX object libmoon/CMakeFiles/moon.dir/src/task.cpp.o
[ 20%] Building C object libmoon/CMakeFiles/moon.dir/src/i40e.c.o
[ 27%] Building CXX object libmoon/CMakeFiles/moon.dir/src/lifecycle.cpp.o
[ 27%] Building C object libmoon/CMakeFiles/moon.dir/src/util.c.o
/home/MoonGen/libmoon/src/memory.c:2:10: fatal error: rte_mbuf.h: No such file or directory
#include <rte_mbuf.h>
^~~~~~~~~~~~
compilation terminated.
/home/MoonGen/libmoon/src/device.c:2:10: fatal error: rte_ethdev.h: No such file or directory
#include <rte_ethdev.h>
^~~~~~~~~~~~~~
compilation terminated.
libmoon/CMakeFiles/moon.dir/build.make:86: recipe for target 'libmoon/CMakeFiles/moon.dir/src/memory.c.o' failed
make[2]: *** [libmoon/CMakeFiles/moon.dir/src/memory.c.o] Error 1
/home/MoonGen/libmoon/src/i40e.c:2:10: fatal error: rte_ethdev.h: No such file or directory
#include <rte_ethdev.h>
^~~~~~~~~~~~~~
make[2]: *** Waiting for unfinished jobs....
compilation terminated.
libmoon/CMakeFiles/moon.dir/build.make:134: recipe for target 'libmoon/CMakeFiles/moon.dir/src/device.c.o' failed
make[2]: *** [libmoon/CMakeFiles/moon.dir/src/device.c.o] Error 1
libmoon/CMakeFiles/moon.dir/build.make:158: recipe for target 'libmoon/CMakeFiles/moon.dir/src/i40e.c.o' failed
make[2]: *** [libmoon/CMakeFiles/moon.dir/src/i40e.c.o] Error 1
/home/MoonGen/libmoon/src/util.c:3:10: fatal error: rte_ip.h: No such file or directory
#include <rte_ip.h>
^~~~~~~~~~
compilation terminated.
libmoon/CMakeFiles/moon.dir/build.make:182: recipe for target 'libmoon/CMakeFiles/moon.dir/src/util.c.o' failed
make[2]: *** [libmoon/CMakeFiles/moon.dir/src/util.c.o] Error 1
CMakeFiles/Makefile2:122: recipe for target 'libmoon/CMakeFiles/moon.dir/all' failed
make[1]: *** [libmoon/CMakeFiles/moon.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2
Trying to bind interfaces, this will fail if you are not root
Try sudo ./bind-interfaces.sh if this step fails
modprobe: ERROR: ../libkmod/libkmod.c:586 kmod_search_moddep() could not open moddep file '/lib/modules/5.3.0-40-generic/modules.dep.bin'
modprobe: FATAL: Module uio not found in directory /lib/modules/5.3.0-40-generic
lspci: Unable to load libkmod resources: error -12
Traceback (most recent call last):
File "usertools/dpdk-devbind.py", line 717, in
main()
File "usertools/dpdk-devbind.py", line 710, in main
get_device_details(network_devices)
File "usertools/dpdk-devbind.py", line 300, in get_device_details
route = check_output(["ip", "-o", "route"])
File "usertools/dpdk-devbind.py", line 149, in check_output
stderr=stderr).communicate()[0]
File "/usr/lib/python2.7/subprocess.py", line 394, in init
errread, errwrite)
File "/usr/lib/python2.7/subprocess.py", line 1047, in _execute_child
raise child_exception
OSError: [Errno 2] No such file or directory
Could not find any inactive interfaces to bind to DPDK. Note that this script does not bind interfaces that are in use by the OS.
Delete IP addresses from interfaces you would like to use with libmoon and run this script again.
You can also use the script dpdk-devbind.py in deps/dpdk/usertools manually to manage interfaces used by libmoon and the OS.
root@10ce5f37273b:/home/MoonGen#
`
I don't know what's the issue here. It worked fine in my laptop but not in the PC.
I'm wondering if its some version compatibility issue. But it's the same versions used and same things happening in both the systems, so technically it should work.

Please help me with this.

How to use the thread of libmoon

In the experiment, code of redis storage was added to dump-pkts.lua. But after monitoring, it is found that the key of data storage is far less than the number of packets. I have counted the number of receiving packets, and found that in the process of receiving and parsing, the packet loss rate is far greater than the number of packets. See libmoon support multithreading, but do not know how to use?
local bufs = memory.bufArray()
local num =1
while lm.running() do
local rx = queue:tryRecv(bufs, 10)
local batchTime = lm.getTime()
for i = 1, rx do
local buf = bufs[i]
-- if(next(buf) ~= nil)then
if filter(buf:getBytes(), buf:getSize()) then
print(buf:getBytes())
print(buf:getSize())

			if writer then
				print(buf:getBytes())
				print(buf:getSize())
				writer:writeBuf(batchTime, buf, snapLen)
				captureCtr:countPacket(buf) 
                                   
			else
                          local mem =  buf:getUdpPacket()
                           num=num+1
                         print(num)

                       client:hmset('UDP'..num,'src_port',mem.udp:getSrcPort(),'dst_port',mem.udp:getDstPort(),'length',mem.udp:getLength(),'Checksum',mem.udp:getChecksum(),'src_ip',mem.ip4:getSrcString(),'dst_ip',mem.ip4:getDstString(),'src_mac',mem.eth:getSrcString(),'dst_mac',mem.eth:getDstString())                         
                       
                        -- buf:dump()
                            
                                 
		--end
			end

the loss rate of packet

I would like to add simple code in the dump.pkts.lua to complete the storage after the packet is acquired. I store the key information of the packet in a hashed manner. However, by detecting the number of databases , it is found that a large number of data packets are lost in this process. In the loop, some simple statements cause a large packet loss rate.The code I added is as follow.My guess is that the storage rate can not match the receiving rate, causing the packet in buf to be overwritten by the new packet before it is processed.Whether there is a good solution of libmoon?
local bufs = memory.bufArray()
local num =0
while lm.running() do
local rx = queue:tryRecv(bufs,100)
local batchTime = lm.getTime()
for i = 1, rx do
local buf = bufs[i]
if(next(buf) ~= nil)then
if filter(buf:getBytes(), buf:getSize()) then
if writer then
writer:writeBuf(batchTime, buf, snapLen )
captureCtr:countPacket(buf)
else
local mem = buf:getUdpPacket()
num=num+1
print(num)

               client:hmset('UDP'..num,'src_port',mem.udp:getSrcPort(),'dst_port',mem.udp:getDstPort(),'length',mem.udp:getLength(),'Checksum',mem.udp:getChecksum(),'src_ip',mem.ip4:getSrcString(),'dst_ip',mem.ip4:getDstString(),'src_mac',mem.eth:getSrcString(),'dst_mac',mem.eth:getDstString())                         
                      --buf:dump()
                     --end

Lura error in task master

Hello,

Thanks for the library. When I run the libmoon hello world example, the following error appears. Do you have any suggestion on how to solve it?

vagrant@vagrant:/home/libmoon$ sudo ./build/libmoon examples/hello-world.lua
[WARN] malloc() allocates objects >= 1 MiB from LuaJIT memory space.
[WARN] Install libjemalloc if you encounter out of memory errors.
[INFO] Initializing DPDK. This will take a few seconds...
EAL: Detected 1 lcore(s)
EAL: Probing VFIO support...
EAL: WARNING: cpu flags constant_tsc=yes nonstop_tsc=no -> using unreliable clock cycles !
PMD: bnxt_rte_pmd_init() called for (null)
EAL: PCI device 0000:00:03.0 on NUMA socket -1
EAL: probe driver: 8086:100e rte_em_pmd
EAL: PCI device 0000:00:08.0 on NUMA socket -1
EAL: probe driver: 8086:100e rte_em_pmd
[INFO] Found 1 usable devices:
Device 0: 08:00:27:60:81:E4 (Intel Corporation 82540EM Gigabit Ethernet Controller)
Hello, world!
Command line arguments:
[FATAL] Lua error in task master
/home/libmoon/lua/libmoon.lua:174: Not enough cores to start this task
Stack Traceback

(2) Lua method 'fatal' at file '/home/libmoon/lua/log.lua:129'
Local variables:
self = table: 0x40e2c280 {DEBUG:0, fatal:function: 0x40e2c4a0, writeToLog:function: 0x40e2c480, INFO:1 (more...)}
str = string: "Not enough cores to start this task"
(3) Lua field 'startTask' at file '/home/libmoon/lua/libmoon.lua:174'
Local variables:
devices = table: 0x410a7a00 {}
socket = number: -1
core = nil
(4) Lua function 'master' at file 'examples/hello-world.lua:6' (best guess)
(5) global C function 'xpcall'
(6) Lua upvalue 'master' at file '/home/libmoon/lua/main.lua:96'
Local variables:
_ = string: "./build/libmoon"
file = string: "examples/hello-world.lua"
args = table: 0x415c7c58 {}
cfgFile = nil
ok = boolean: true
parsedArgs = table: 0x415c9d98 {}
(7) Lua function 'main' at file '/home/libmoon/lua/main.lua:143' (best guess)
Local variables:
task = string: "master"
/home/libmoon/lua/libmoon.lua:174: Not enough cores to start this task

Fault for hello world

[WARN]  malloc() allocates objects >= 1 MiB from LuaJIT memory space.
[WARN]  Install libjemalloc if you encounter out of memory errors.
[INFO]  Initializing DPDK. This will take a few seconds...
EAL: Detected 128 lcore(s)
EAL: invalid parameter for --lcores

Usage: libmoon [options]

EAL common options:
  -c COREMASK         Hexadecimal bitmask of cores to run on
  -l CORELIST         List of cores to run on
                      The argument format is <c1>[-c2][,c3[-c4],...]
                      where c1, c2, etc are core indexes between 0 and 128
  --lcores COREMAP    Map lcore set to physical cpu set
                      The argument format is
                            '<lcores[@cpus]>[<,lcores[@cpus]>...]'
                      lcores and cpus list are grouped by '(' and ')'
                      Within the group, '-' is used for range separator,
                      ',' is used for single number separator.
                      '( )' can be omitted for single element group,
                      '@' can be omitted if cpus and lcores have the same value
  -s SERVICE COREMASK Hexadecimal bitmask of cores to be used as service cores
  --master-lcore ID   Core ID that is used as master
  -n CHANNELS         Number of memory channels
  -m MB               Memory to allocate (see also --socket-mem)
  -r RANKS            Force number of memory ranks (don't detect)
  -b, --pci-blacklist Add a PCI device in black list.
                      Prevent EAL from using this PCI device. The argument
                      format is <domain:bus:devid.func>.
  -w, --pci-whitelist Add a PCI device in white list.
                      Only use the specified PCI devices. The argument format
                      is <[domain:]bus:devid.func>. This option can be present
                      several times (once per device).
                      [NOTE: PCI whitelist cannot be used with -b option]
  --vdev              Add a virtual device.
                      The argument format is <driver><id>[,key=val,...]
                      (ex: --vdev=net_pcap0,iface=eth2).
  -d LIB.so|DIR       Add a driver or driver directory
                      (can be used multiple times)
  --vmware-tsc-map    Use VMware TSC map instead of native RDTSC
  --proc-type         Type of this process (primary|secondary|auto)
  --syslog            Set syslog facility
  --log-level=<int>   Set global log level
  --log-level=<type-regexp>,<int>
                      Set specific log level
  -v                  Display version information on startup
  -h, --help          This help

EAL options for DEBUG use only:
  --huge-unlink       Unlink hugepage files after init
  --no-huge           Use malloc instead of hugetlbfs
  --no-pci            Disable PCI
  --no-hpet           Disable HPET
  --no-shconf         No shared config (mmap'd files)

EAL Linux options:
  --socket-mem        Memory to allocate on sockets (comma separated values)
  --huge-dir          Directory where hugetlbfs is mounted
  --file-prefix       Prefix for hugepage filenames
  --base-virtaddr     Base virtual address
  --create-uio-dev    Create /dev/uioX (usually done by hotplug)
  --vfio-intr         Interrupt mode for VFIO (legacy|msi|msix)
  --xen-dom0          Support running on Xen dom0 without hugetlbfs

EAL: FATAL: Invalid 'command line' arguments.
EAL: Invalid 'command line' arguments.
[INFO]  Found 0 usable devices:
Hello, world!
Command line arguments:


Segmentation fault

I followed the instruction of FlowScope and after I built libmoon, I ran the hello world example which ended up like above.
Am I doing something wrong?

cannot call histogram:avg()

Variable and function name are identical, so lua raises:
attempt to call method 'avg' (a number value)

Code:

function histogram:avg()
	if self.dirty then self:calc() end

	return self.avg
end

Cisco enic support

Hello,

I noticed that the necessary driver setup code for the Cisco enic dpdk driver was missing from libmoon. Is this a deliberate decision? If not, I'd like to potentially submit a pull request to include it. My very limited testing of this driver has shown that I am unable to exceed roughly 1.5Mpps regardless of packet size when providing PCI pass through of a Cisco VIC 1280 from a Cisco UCS/B-series blade server via VMware ESXi 6.5 hypervisor. Any insight into the above is greatly appreciated.

latency packets can be "lost" at high packet rates

We have been using the timestamper:measureLatency() to measure latency while having a concurrent bulk network traffic in the background. Some of these latency packets can get "lost", and I am not sure why this is happening yet. Somewhere around 10Mpps is where we start seeing loss. At 14.7Mpps, we get up to 25% loss. During this test, the bulk network (14.7Mpps) has exactly 0 loss. The latency packets are sent at about 100/second.

I have added debug code to measureLatency() to report the different ways loss can happen, and it is always because the time to wait for the packet has expired.

So far these tests use 64 byte frames for bulk network traffic and 76(80) byte frames for the latency packets. If we increase the frame size to 124 for latency, we get all of the packets.

The network adapter is Intel Niantic, and the ports are connected to each other (no other system involved).

I am wondering if this has anything to do with filtering on the adapter. Have you seen anything like this? I will probably look at the software timestamping next to see if the same problem is there.

Error on running dump-pkts.lua example

I am facing an error when I try to run the dump-pkts.lua example using the command:
sudo ./build/libmoon examples/dump-pkts.lua 0
where 0 is the device id. I do get the following log when running the example before it terminates with error:
[INFO] Found 1 usable devices: Device 0: 00:25:90:69:CA:C8 (Intel Corporation 82574L Gigabit Network Connection)

The error is:
/home/tina/libmoon/lua/device.lua:196: Could not configure device 0: error Invalid argument

Are there any other arguments that need to be passed to run the example? Or does the error have anything to do with the device?

Decapsulation requires header offset

In Moongen vxlan decapsulation example,
encapsulationLen(= 14 + 20 + 8 + 8) is constant but what if some header has variable size options?
I tried (pkt.payload.uint8 - buf:getBytes) but it doesn't include variable len either.
It would be useful if libmoon provide header offset considering variable len.

Not enough cores when using dpdk-conf.lua

Hello, I am using MoonGen with a custom dpdk-conf.lua, but an error occurs saying "not enough cores"

leos@server:~/MoonGen$ sudo  ./build/MoonGen examples/l3-load-latency.lua 0 1 -r 3000 -f 1000
[INFO]  Initializing DPDK. This will take a few seconds...
EAL: Detected 24 lcore(s)
EAL: 112 hugepages of size 1073741824 reserved, but no mounted hugetlbfs found for that size
EAL: Probing VFIO support...
EAL: PCI device 0000:84:00.0 on NUMA socket 1
EAL:   probe driver: 8086:10fb net_ixgbe
EAL: PCI device 0000:84:00.1 on NUMA socket 1
EAL:   probe driver: 8086:10fb net_ixgbe
[INFO]  Found 2 usable devices:
   Device 0: 90:E2:BA:61:E5:10 (Intel Corporation 82599ES 10-Gigabit SFI/SFP+ Network Connection)
   Device 1: 90:E2:BA:61:E5:11 (Intel Corporation 82599ES 10-Gigabit SFI/SFP+ Network Connection)
PMD: ixgbe_dev_link_status_print():  Port 0: Link Down
PMD: ixgbe_dev_link_status_print():  Port 1: Link Down
[INFO]  Waiting for devices to come up...
[INFO]  Device 0 (90:E2:BA:61:E5:10) is up: 10000 MBit/s
[INFO]  Device 1 (90:E2:BA:61:E5:11) is up: 10000 MBit/s
[INFO]  2 devices are up.
[FATAL] Lua error in task master
/home/leos/MoonGen/build/../libmoon/lua/libmoon.lua:175: Not enough cores to start this task
Stack Traceback
===============
(2) Lua method 'fatal' at file '/home/leos/MoonGen/build/../libmoon/lua/log.lua:129'
        Local variables:
         self = table: 0x40a9ff98  {DEBUG:0, fatal:function: 0x414b1898, writeToLog:function: 0x414b1878, INFO:1 (more...)}
         str = string: "Not enough cores to start this task"
(3) Lua field 'startTask' at file '/home/leos/MoonGen/build/../libmoon/lua/libmoon.lua:175'
        Local variables:
         devices = table: 0x409aca70  {1:[Device: id=0], 2:[Device: id=1]}
         socket = number: 1
         core = nil
(4) Lua function 'master' at file 'examples/l3-load-latency.lua:45' (best guess)
        Local variables:
         args = table: 0x4020e7b8  {rxDev:1, txDev:0, flows:1000, rate:3000, size:60}
(5) global C function 'xpcall'
(6) Lua upvalue 'master' at file '/home/leos/MoonGen/build/../libmoon/lua/main.lua:96'
        Local variables:
         _ = string: "./build/MoonGen"
         file = string: "examples/l3-load-latency.lua"
         args = table: 0x414d8b58  {1:0, 2:1, 3:-r, 4:3000, 5:-f, 6:1000}
         cfgFile = nil
         ok = boolean: true
         parsedArgs = table: 0x4020e4c8  {1:table: 0x4020e7b8}
(7) Lua function 'main' at file '/home/leos/MoonGen/build/../libmoon/lua/main.lua:146' (best guess)
        Local variables:
         task = string: "master"
        /home/leos/MoonGen/build/../libmoon/lua/libmoon.lua:175: Not enough cores to start this task

MoonGen works when no dpdk-conf.lua is provided. The command does not have --dpdk-config=/home/leos/MoonGen/dpdk-conf.lua because the script is in the main folder, but anyway the effect is the same.

In addition to this, MoonGen is working with the same exact command but in another machine with a slightly different configuration (same architecture, but more cores and more linecards). My dpdk-conf.lua looks like this:

DPDKConfig {
        cores = {1, 2, 3, 4, 5,13,14,15,16},
        pciWhitelist = {"0000:84:00.0", "0000:84:00.1"},
        cli = {
                "--file-prefix", "tg1",
                "--socket-mem", "1024,1024"
        }
}

What am I doing wrong ? Thank you for your help.

Software IP checksum calculation is slow

I measured a 50% performance hit in my arbitrary VXLAN example when the inner checksum needs to be recalculated without offloading support.

The software checksum code is currently a naive Lua implementation (except for the pseudo header for L4 protocols).
Snabb has great software checksum code, maybe that can be helpful here.

a problem of sending and receiving UDP by pkts

Why the experiment sends UDP from a server using pktgen, and when the MAC address is deliberately miswritten, the traffic is displayed through the dump-pkts in another server?it can also be received by dump-pkts when the ip is wrong?I don't know why it happened. Is it a broadcast?

Modification of received data leads to lower forwarding rate.

In filter.lua , the received data can be forwarded directly. I modified the IP address in the received packet and sent it, but caused the sending rate to drop rapidly. The rate of sending only 1.3 ~1.4Mpps. The previous idea was to store the data in redis and then regenerate the packet to implement tampering and forwarding. But it leads to a lot of data loss, you said that the string operation will greatly affect the performance, so I want to modify some data and then forward directly, but the performance is still not high.

  1. If you do not use a string, how to tamper with the IP address. In a hot loop, the effect of strings is very large.
  2. libmoon reduces the certain packet rate to find a balance point with storage, so that the packet loss rate is appropriately reduced.
    What is the reason and what is the solution or good idea?
    local rxBufs = memory.bufArray()
    local txBufs = memory.bufArray()
    while lm.running() do
    local rx = rxQueue:recv(rxBufs)
    local j = 0
    for i = 1, rx do
    local buf = --
    if filter(rxBufs[i]) then
    rxBufs[i]:free()
    else
    local mem = buf:getUdpPacket()
    mem.ip4:setDstString("202.119.236.5")
    j = j + 1
    txBufs[j] = rxBufs[i]
    end
    end
    txQueue:sendN(txBufs, j)
    end
    end

timestamping.lua missing 'else'

Hello everybody,
I have detected some missing else-statement for the if in timestamping.lua:130 at the current master branch.

if lat > 0 and lat < 2 * maxWait * 10^9 then

I made latency higher than 2*maxTime*10^8 by force and run the example script hardware-timestamping.lua. There will be much fewer packets generated because the script just needs the time for waiting for the timer to end.
A simple else statement with return nil, numPkts would fix this.
I know its just a small problem, also because of its rare occurrence, but its a small mark.

Best regards,
testunde

resetting device stats on X552

Hi,

running the following script:

local device	= require "device"
local lm	= require "libmoon"
local log	= require "log"
local memory	= require "memory"
local stats	= require "stats"
local timer	= require "timer"

local DST_MAC	= "01:23:45:67:89:AB"
local SRC_IP	= "10.0.0.10"
local DST_IP	= "10.1.0.10"
local SRC_PORT	= 1234
local DST_PORT	= 319

function configure(parser)
	parser:description("Generates UDP traffic.")
	parser:argument("txDev", "Device to transmit from."):convert(tonumber)
	parser:argument("rxDev", "Device to receive from."):convert(tonumber)
end

function master(args)
	txDev = device.config{port = args.txDev, rxQueues = 3, txQueues = 3}
	rxDev = device.config{port = args.rxDev, rxQueues = 3, txQueues = 3}
	device.waitForLinks()
	local rate, size = 100, 100
	txDev:getTxQueue(0):setRate(rate - (size + 4) * 8 / 1000)
	lm.startTask("loadSlave", txDev:getTxQueue(0), rxDev, size)
	lm.waitForTasks()
end

local function fillUdpPacket(buf, len)
	buf:getUdpPacket():fill{
		ethSrc = queue,
		ethDst = DST_MAC,
		ip4Src = SRC_IP,
		ip4Dst = DST_IP,
		udpSrc = SRC_PORT,
		udpDst = DST_PORT,
		pktLength = len
	}
end

function loadSlave(queue, rxDev, size)
	local mempool = memory.createMemPool(function(buf)
		fillUdpPacket(buf, size)
	end)
	local bufs = mempool:bufArray()
	local txCtr = stats:newDevTxCounter(queue, "plain")
	log:info('finalize immediately')
	txCtr:finalize()
	log:info('new txDev counter (1)')
	txCtr = stats:newDevTxCounter(queue, "plain")
	local time = timer:new(1)
	while lm.running() and not time:expired() do
		bufs:alloc(size)
		bufs:offloadUdpChecksums()
		queue:send(bufs)
		txCtr:update()
	end
	log:info('finalize after while')
	txCtr:finalize()
	lm.sleepMillis(5000)
	log:info('new txDev counter (2)')
	txCtr = stats:newDevTxCounter(queue, "plain")
	log:info('update & finalize')
	txCtr:update()
	txCtr:finalize()
end

produces as output:

$ ./build/MoonGen test.lua 0 1
# <snip>
[INFO]  Found 2 usable devices:
   Device 0: E0:DF:84:9B:C2:50 (Intel Corporation Ethernet Connection X552 10 GbE SFP+)
   Device 1: 9B:90:24:EC:46:42 (Intel Corporation Ethernet Connection X552 10 GbE SFP+)
# <snip>
[INFO]  finalize immediately
[Device: id=0] TX: nan (StdDev 0.00) Mpps, nan (StdDev 0) Mbit/s (nan Mbit/s with framing), total 0 packets with 0 bytes (incl. CRC)
[INFO]  new txDev counter (1)
[Device: id=0] TX: 0.12 Mpps, 99 Mbit/s (118 Mbit/s with framing)
[INFO]  finalize after while
[Device: id=0] TX: nan (StdDev 0.00) Mpps, nan (StdDev 0) Mbit/s (nan Mbit/s with framing), total 120078 packets with 12488112 bytes (incl. CRC)
[INFO]  new txDev counter (2)
[INFO]  update & finalize
[Device: id=0] TX: nan (StdDev 0.00) Mpps, nan (StdDev 0) Mbit/s (nan Mbit/s with framing), total 120078 packets with 12488112 bytes (incl. CRC)

which is, in my opinion, unexpected.
I'd expect the last line to report 0 packets/bytes, since stats:newDevTxCounter

obj:getThroughput() -- reset stats on the NIC

promises to reset stats.

Am I missing something?

Thanks!

Regards,
Sharlene

Newer DPDK

Please update to a more recent DPDK.
DPDK will not compile with newer Mellanox driver.

Interception

Hello, I 'd like to ask you how to intercept a message.

pktgen example not working with Intel X540-AT2

Hey @emmericp - firstly, thanks for building this great tool! I initially ran libmoon in a VirtualBox VM to get familiar with it.

Next I picked up some Intel X540-AT2 10 GbE NICs to use with it. After building libmoon I attempt to run the pktgen example, which results in no TX rate being reported.

I ran Wireshark on the machine packets were being sent to, and it appears none are being sent. Interesting, if I enable ARP in the pktgen example, I can see that the example is sending out an ARP request and is receiving a response from the remote machine.

I apologize if I have missed something obvious! Any advice is greatly appreciated. Picture attached for reference:

libmoon

Add a way to set the logging level for libmoon internal code

There is currently no way to disable logging messages originating from internal libmoon code.
Running the following script still prints warnings to stdout:

local log = require "log"
log:setLevel("ERROR")
local lm = require "libmoon"

function master()
end

Output:

[WARN]  malloc() allocates objects >= 1 MiB from LuaJIT memory space.
[WARN]  Install libjemalloc if you encounter out of memory errors.

Expected output:

This is problematic in automated work flows, where adherence to certain output format, such as csv, is expected.

mbuf/mempool reclaiming does not work

device.reclaimTxBuffers() is incompatible with the namespace-based approach for device management as the queues are not available here. we need a task-local cache to fix this (which is a good idea anyways)

Build error in Debian System

I can't install Libmoon on my test machine which is a Debian system. When I tried this on an Ubuntu server, it worked fine.

uname -a gives this: Linux <host-name> 3.16.0-5-amd64 #1 SMP Debian 3.16.51-3+deb8u1 (2018-01-08) x86_64 GNU/Linux

Running ./bind.sh gives the following error:
/home/pulkit/libmoon/deps/dpdk/lib/librte_eal/linuxapp/eal/eal_pci.c:82:3: error: ‘strncpy’ specified bound depends on the length of the source argument [-Werror=stringop-overflow=] strncpy(dri_name, name + 1, strlen(name + 1) + 1); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /home/pulkit/libmoon/deps/dpdk/lib/librte_eal/linuxapp/eal/eal_pci.c: In function ‘pci_scan_one.isra.1’: /home/pulkit/libmoon/deps/dpdk/lib/librte_eal/linuxapp/eal/eal_pci.c:82:31: note: length computed here strncpy(dri_name, name + 1, strlen(name + 1) + 1); ^~~~~~~~~~~~~~~~ CC rte_cpuflags.o cc1: all warnings being treated as errors make[5]: *** [/home/pulkit/libmoon/deps/dpdk/mk/internal/rte.compile-pre.mk:140: eal_pci.o] Error 1 make[5]: *** Waiting for unfinished jobs.... make[4]: *** [/home/pulkit/libmoon/deps/dpdk/mk/rte.subdir.mk:65: eal] Error 2 make[4]: *** Waiting for unfinished jobs.... CC [M] /home/pulkit/libmoon/deps/dpdk/x86_64-native-linuxapp-gcc/build/lib/librte_eal/linuxapp/igb_uio/igb_uio.o In file included from /usr/src/linux-headers-3.16.0-5-common/include/linux/kernel.h:11, from /usr/src/linux-headers-3.16.0-5-common/include/linux/kernfs.h:10, from /usr/src/linux-headers-3.16.0-5-common/include/linux/sysfs.h:15, from /usr/src/linux-headers-3.16.0-5-common/include/linux/kobject.h:21, from /usr/src/linux-headers-3.16.0-5-common/include/linux/device.h:17, from /home/pulkit/libmoon/deps/dpdk/x86_64-native-linuxapp-gcc/build/lib/librte_eal/linuxapp/igb_uio/igb_uio.c:27: /usr/src/linux-headers-3.16.0-5-common/include/linux/log2.h:22:1: error: ignoring attribute ‘noreturn’ because it conflicts with attribute ‘const’ [-Werror=attributes] int ____ilog2_NaN(void); ^~~ cc1: all warnings being treated as errors make[9]: *** [/usr/src/linux-headers-3.16.0-5-common/scripts/Makefile.build:269: /home/pulkit/libmoon/deps/dpdk/x86_64-native-linuxapp-gcc/build/lib/librte_eal/linuxapp/igb_uio/igb_uio.o] Error 1 make[8]: *** [/usr/src/linux-headers-3.16.0-5-common/Makefile:1355: _module_/home/pulkit/libmoon/deps/dpdk/x86_64-native-linuxapp-gcc/build/lib/librte_eal/linuxapp/igb_uio] Error 2 make[7]: *** [Makefile:182: sub-make] Error 2 make[6]: *** [Makefile:8: all] Error 2 make[5]: *** [/home/pulkit/libmoon/deps/dpdk/mk/rte.module.mk:79: igb_uio.ko] Error 2 make[4]: *** [/home/pulkit/libmoon/deps/dpdk/mk/rte.subdir.mk:65: igb_uio] Error 2 make[3]: *** [/home/pulkit/libmoon/deps/dpdk/mk/rte.subdir.mk:65: linuxapp] Error 2 make[2]: *** [/home/pulkit/libmoon/deps/dpdk/mk/rte.subdir.mk:63: librte_eal] Error 2 make[1]: *** [/home/pulkit/libmoon/deps/dpdk/mk/rte.sdkbuild.mk:78: lib] Error 2 make: *** [/home/pulkit/libmoon/deps/dpdk/mk/rte.sdkroot.mk:129: all] Error 2 make -C deps/http-parser library make[1]: Entering directory '/home/pulkit/libmoon/lua/lib/turbo/deps/http-parser' gcc -shared -Wl,-soname=libhttp_parser.so.2.1 -o libhttp_parser.so.2.1 libhttp_parser.o make[1]: Leaving directory '/home/pulkit/libmoon/lua/lib/turbo/deps/http-parser' gcc -Ideps/http-parser/ -shared -O3 -Wall -g -fPIC deps/http-parser/libhttp_parser.o deps/turbo_ffi_wrap.c -o libtffi_wrap.so -lcrypto -lssl make: Nothing to be done for 'all'. -- Building Intel TBB: /usr/bin/make -j4 tbb_build_prefix=tbb_cmake_build_subdir tbb_build_dir=/home/pulkit/libmoon/build/tbb_cmake_build compiler=gcc -- Configuring done -- Generating done -- Build files have been written to: /home/pulkit/libmoon/build [ 13%] Building C object CMakeFiles/libmoon.dir/src/memory.c.o [ 13%] Building C object CMakeFiles/libmoon.dir/src/device.c.o [ 13%] Building C object CMakeFiles/libmoon.dir/src/i40e.c.o [ 17%] Building C object CMakeFiles/libmoon.dir/src/util.c.o /home/pulkit/libmoon/src/i40e.c:2:10: fatal error: rte_ethdev.h: No such file or directory #include <rte_ethdev.h> ^~~~~~~~~~~~~~ compilation terminated. /home/pulkit/libmoon/src/memory.c:2:10: fatal error: rte_mbuf.h: No such file or directory #include <rte_mbuf.h> ^~~~~~~~~~~~ compilation terminated. /home/pulkit/libmoon/src/device.c:2:10: fatal error: rte_ethdev.h: No such file or directory #include <rte_ethdev.h> ^~~~~~~~~~~~~~ compilation terminated. make[2]: *** [CMakeFiles/libmoon.dir/build.make:76: CMakeFiles/libmoon.dir/src/memory.c.o] Error 1 make[2]: *** Waiting for unfinished jobs.... make[2]: *** [CMakeFiles/libmoon.dir/build.make:115: CMakeFiles/libmoon.dir/src/i40e.c.o] Error 1 make[2]: *** [CMakeFiles/libmoon.dir/build.make:102: CMakeFiles/libmoon.dir/src/device.c.o] Error 1 /home/pulkit/libmoon/src/util.c:3:10: fatal error: rte_ip.h: No such file or directory #include <rte_ip.h> ^~~~~~~~~~ compilation terminated. make[2]: *** [CMakeFiles/libmoon.dir/build.make:128: CMakeFiles/libmoon.dir/src/util.c.o] Error 1 make[1]: *** [CMakeFiles/Makefile2:73: CMakeFiles/libmoon.dir/all] Error 2 make: *** [Makefile:84: all] Error 2

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.