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

initial import of packetblaster lwaftr #847

Merged
merged 24 commits into from
May 12, 2016

Conversation

mwiget
Copy link
Contributor

@mwiget mwiget commented Mar 27, 2016

This is a first working prototype of a lwaftr specific IPv4 and IPv6 traffic generator with the following features, for which I'm seeking feedback from the community in general and @kbara, @dpino and @wingo in particular.

  • Refactored packetblaster synth and replay into their own directories.
    Send IPv4 and IPv6 traffic concurrently to fully test and report on a LWAFTR "on a stick design"
  • Traffic sent either on a PCI port or Linux tap interface
  • Simulates any number of B4 clients
  • Rate limit generated traffic in MPPS (fractions are fine)
  • Report separately and combined on incoming IPv4 and IPv6 traffic in MPPS, Gbps and packet loss
  • Report on incoming packet loss by calculating the delta of the embedded packet counter, separately for IPv4 and IPv6 (allowing for separate sender and receiver applications).

See https://github.com/mwiget/snabbswitch/tree/packetblaster-lw4o6/src/program/packetblaster/lwaftr for a detailed description.

Some topics I'm not sure about yet:

  • Would it make sense to integrate this tighter with lwaftr, e.g. by importing lwutil.lua or leverage the protocol libraries for udp and datagram?
  • Performance seems suboptimal. It max's out at roughly 5 MPPS on receiving. Maybe its just a matter of triggering jit.flush() or there are some low hanging fruits to optimise.

local ipv4_pkt = packet.allocate()
local eth_hdr = cast(ether_header_ptr_type, ipv4_pkt.data)
eth_hdr.ether_dhost, eth_hdr.ether_shost = dst_mac, src_mac
eth_hdr.ether_type = PROTO_IPV4
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems there's no support of VLAN tags. I would like to have it as it's something we use often.

Since you're defining ethernet_header, one way of implementing support of VLAN tags is to change the definition of the ethernet header if VLAN tags are used. In that case, ether_header_ptr_type will point to the definition of a 802.1Q header. See https://github.com/Igalia/snabbswitch/blob/lwaftr_starfruit/src/apps/lwaftr/generator.lua#L103

Same goes for the hardcoded offsets. In case of supporting VLAN tags, offsets should change (14 turns into 16, 34 (20 + 14) turns into 36, etc). As for me I prefer to use constants instead of hardcoded values since it makes easier to understand the meaning of a value (ipv4_header_size + ethernet_header_size instead of 34).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Many thanks for your detailed feedback. I'll go thru all of them and make the required changes. On VLAN support I'm wondering if I could simply leverage VMDq instead of handling VLANs in software. One drawback is of course the lack of VLAN support on tap interface. On the other hand, my intention with the tap interface was simply a method to make the packets visible via tcpdump if needed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm. VMDq is probably not a good idea, because it requires to register with a mac address unless a VLAN is given. Just thinking out loud here: maybe VMDq can still be used with VLAN tag, but must be disabled for untagged traffic. Setting MAC address is an issue for the single stick design, which can have two different destination MAC's for v4 and v6 traffic returned from LWAFTR.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Went with VMDq set to true when VLAN is given. Its an efficient way to add VLAN support without changing the source code: VLAN handling is done by the Intel NIC. That obviously doesn't work for tap interfaces and I don't have a warning about it just yet.

@dpino
Copy link
Contributor

dpino commented Mar 29, 2016

Looking good. Supporting VLAN tags is the main concern to me.

@dpino
Copy link
Contributor

dpino commented Mar 31, 2016

@mwiget thanks for tackling the issues. If VLAN tagging can be managed by VMDq it works for me too.


local vlan = nil
function opt.v (arg)
vlan = assert(tonumber(arg), "duration is not a number!")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wrong error message (copy-paste error I believe).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

argh and thanks ;-)

@mwiget mwiget changed the title [wip] initial import of packetblaster lwaftr initial import of packetblaster lwaftr Apr 1, 2016
@mwiget
Copy link
Contributor Author

mwiget commented Apr 1, 2016

I think I fixed all open issues so far, removing the [wip]. Happy to make more changes of course.

@dpino
Copy link
Contributor

dpino commented Apr 3, 2016

As for me, no more changes required. LGTM.

config.app(c, "source", Synth, { sizes = sizes,
src = source, dst = destination })

local patterns = args
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mwiget I am not a big fan of the code duplication here. Could the shared code below be put into a shared function?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@eugeneia: Hmm, that was a result of moving synth and replay into their own directories, so they are in line with the added lwaftr. Would it make more sense to leave the original packetblaster.lua as is and simply enhance its logic to also allow commands taken from subdirectories? Kind of having synth and replay be handled within packetblaster.lua (as before this pull) and only add lwaftr/lwaftr.lua?
Or do you have something different in mind?

src = source, dst = destination })

local patterns = args
local nics = packetblaster.config_loadgen(c, patterns)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mwiget With the risk of being super annoying: the code before and after uses of config_loadgen is identical in both cases as far as I can tell. How do you feel about moving that code into config_loadgen and rename it to run_loadgen?

E.g. instead of

   local patterns = args
   local nics = packetblaster.config_loadgen(c, patterns)
   assert(nics > 0, "<PCI> matches no suitable devices.")
   engine.busywait = true
   intel10g.num_descriptors = 32*1024
   engine.configure(c)
   local t = timer.new("report", packetblaster.report, 1e9, 'repeating')
   timer.activate(t)
   if duration then engine.main({duration=duration})
   else             engine.main() end

we would have

packetblaster.run_loadgen(c, args, duration)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@eugeneia Ah, now I get it. Did as suggested and it does indeed look cleaner. Made a few more commits to address VLAN support without VMDq and creation of a pcap file plus selftest the pcap file.

@mwiget mwiget changed the title initial import of packetblaster lwaftr [wip] initial import of packetblaster lwaftr Apr 9, 2016
@mwiget mwiget changed the title [wip] initial import of packetblaster lwaftr initial import of packetblaster lwaftr Apr 9, 2016
@mwiget mwiget changed the title initial import of packetblaster lwaftr [wip] initial import of packetblaster lwaftr Apr 10, 2016
@plajjan
Copy link
Contributor

plajjan commented Apr 18, 2016

@mwiget What is WIP about this one? I'm looking at making additions/modifications to packetblaster and your code seems like a better foundation than what we currently have on master.

@mwiget
Copy link
Contributor Author

mwiget commented Apr 19, 2016

@plajjan I wanted to add some more test cases and I have a change on reporting packet loss in % instead of absolute numbers. So nothing major. I should take the WIP away again.

@mwiget mwiget changed the title [wip] initial import of packetblaster lwaftr initial import of packetblaster lwaftr Apr 19, 2016
@plajjan
Copy link
Contributor

plajjan commented Apr 19, 2016

Would it make sense to integrate this tighter with lwaftr, e.g. by importing lwutil.lua or leverage the protocol libraries for udp and datagram?

@mwiget I think not. It's kind of nice with a second implementation from a testing perspective. One could argue this is just for performance testing and that such validation could be performed by another test app but.. why? Better that that the test apps share code but we have to make sure we validate the program itself and if we share code with the lwAFTR how can we do that?

I noticed you have 2 space indent. I think Snabb typically uses 3 space indent, no? (Do we have a style guide?)

@kbara
Copy link
Contributor

kbara commented Apr 19, 2016

It does indeed usually use a 3 space indent.

@dpino
Copy link
Contributor

dpino commented Apr 19, 2016

@plajjan That's correct, the convention is to use 3-spaces indention. With regard to a style guideline I remember reading the codebase follows the Lua Style Guideline http://lua-users.org/wiki/LuaStyleGuide. I remember reading also the rule of thumb is to write code in the same style as the code that it has been written so far. I think those notes were on the "size budget" page in the Wiki, but I cannot find it anymore cc @lukego

@mwiget
Copy link
Contributor Author

mwiget commented Apr 20, 2016

@plajjan, @kbara and @dpino: didn't even notice and my .vimrc did technically make the mistake ;-), but I fixed it now.

eugeneia added a commit to eugeneia/snabb that referenced this pull request Apr 20, 2016
@eugeneia eugeneia merged commit 1c023ec into snabbco:master May 12, 2016
dpino added a commit to dpino/snabb that referenced this pull request Jun 28, 2017
Add binary serialization support for identity-ref
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants