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

Delayed_start, stall snabb so that peer NIC drivers can fully initialize #869

Merged
merged 2 commits into from
Jun 9, 2016

Conversation

petebristow
Copy link
Contributor

An app that delays packet forwarding for a configurable period of time.
Useful when feeding pcaps into a physical nic. The delay lets the peer
NIC the link to come up before sending packets so none are dropped.

Waiting for a linkup in the NicDriver:new() delays the whole process
in every situation and is even worse when a port doesn't link as all the
timers need to expire.

@eugeneia
Copy link
Member

Calling usleep will block the whole snabb process as well (timers will not be run for instance). I suggest using engine.now instead:

function Delayed_start:new (delay)
   return setmetatable({ start = now()+delay },
                       { __index = Delayed_start})
end

function Delayed_start:push()
   if engine.now() < self.start then return end
   for _ = 1, link.nreadable(self.input.input) do
      link.transmit(self.output.output, link.receive(self.input.input))
   end
end

@petebristow
Copy link
Contributor Author

Blocking the whole snabb process with usleep was by design. There was an issue floating around a while ago about back pressure was it good / was it bad. I don't remember it reaching a conclusion so it's on my list of things to play with. I wanted to avoid putting back pressure in place with this app or buffering packets in memory, which could go rather wrong if it's being fed by Repeater.

I'd like to leave it as is if possible, perhaps expanding the comment to make it explicit that it will stall the whole snabb process.

@eugeneia
Copy link
Member

I don't think blocking is an option as it breaks engine.main({duration=...}), but you are right: we need to resolve the back pressure debate! See #656.

As of now anyways, the solution I suggested would work with Repeater, as it will only transmit packets when there is room in its output link, e.g. some packets would be buffered in Delayed_start.

Cc @lukego

C.usleep(self.delay)
self.delay = nil
end
if engine.now() < self.start then return end
Copy link
Member

Choose a reason for hiding this comment

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

This looks like a neat solution to me!

@petebristow
Copy link
Contributor Author

@eugeneia Is there anything else you want to see before this can be merged?

@eugeneia eugeneia self-assigned this Apr 27, 2016
@eugeneia eugeneia changed the title [wip] delayed_start, stall snabb so that peer NIC drivers can fully initialize Delayed_start, stall snabb so that peer NIC drivers can fully initialize Apr 27, 2016
@eugeneia
Copy link
Member

@petebristow I merged it and replaced some tabs with spaces along the way, could you make sure your editor does not emit tabs?

@eugeneia eugeneia merged commit 6baa1f3 into snabbco:master Jun 9, 2016
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.

3 participants