Thread: Incorrect IPv4 Header Total Length

  1. #1
    Registered User carrotcake1029's Avatar
    Join Date
    Apr 2008
    Posts
    404

    Incorrect IPv4 Header Total Length

    I'm working on a project where we need to listen to an embedded device via ethernet. It sends UDP via IPv4.

    The problem is there is a bug in the embedded device's software and it sets the "Total Length" field in the IPv4 header to be too large. It appears that the operating system (Windows, Linux) drops this message, and my application doesn't get to see any packets.

    I have used libpcap to capture raw packets, which can grab the packet before it gets discarded. This appears to me to be the only workaround. I was wondering if anyone had any other ideas for capturing this data with a more native solution (Windows or Linux) since packaging libpcap with my application is not ideal.

    Thanks!

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,661
    So fixing the embedded device isn't an option (why isn't it an option)?

    How many customers are you shipping the complete project to?
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  3. #3
    Registered User carrotcake1029's Avatar
    Join Date
    Apr 2008
    Posts
    404
    Unfortunately, it is something we have to deal with. The vendor is unwilling to fix it. I almost feel like it is a "feature" so that is makes it harder for applications to listen in as it requires extra effort, thus protecting the sensitive data it transmits.

    The tool we're developing will potentially be used by hundreds of customers

  4. #4
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,661
    So how do the vendor's other customers deal with the problem?

    I take it from your previous post that your customers will use Windows or Linux, so any solution needs to work with both.

    Computer-on-module - Wikipedia, the free encyclopedia
    If you can find a suitable CoM with two NICs, and the cost is small compared to the embedded device, then it might be possible to create a filter which just repairs the header.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  5. #5
    Registered User carrotcake1029's Avatar
    Join Date
    Apr 2008
    Posts
    404
    Not sure how others deal with it actually.

    The solution doesn't necessarily have to work on both. We just pick the platform, so whichever would suit us better. That is a solution I hadn't though of. The spec it uses is 10BASE-T, so probably any low cost hardware could do the trick, though I'm fairly certain we'll probably want to go with a pure software solution. It might just be libpcap is simply the easiest software solution to the issue.

    Thanks!

  6. #6
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,661
    You could try this approach, if you want to just stick with Linux.

    c - Reading from a promiscuous network device - Stack Overflow
    It would avoid having to drag a whole extra library into the project just to solve the problem.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. array add total rows and total colms
    By gameover6005 in forum C Programming
    Replies: 1
    Last Post: 04-16-2013, 11:46 PM
  2. IPv4 is no more
    By Salem in forum General Discussions
    Replies: 12
    Last Post: 02-04-2011, 07:32 AM
  3. IP header "total length" vs. packet size
    By MK27 in forum Networking/Device Communication
    Replies: 2
    Last Post: 01-04-2009, 07:45 AM
  4. Sockets: IPv4 vs IPv6
    By ninboy in forum Networking/Device Communication
    Replies: 1
    Last Post: 10-15-2008, 01:02 AM
  5. Adding v6 feature to existing IPv4 stack
    By arron in forum Networking/Device Communication
    Replies: 0
    Last Post: 11-22-2005, 11:39 PM