Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1028687
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T12:25:44+00:00 2026-05-16T12:25:44+00:00

I’m making a program to calculate latency from a tcpdump/pcap file and I want

  • 0

I’m making a program to calculate latency from a tcpdump/pcap file and I want to be able to specify rules on the command line to correlate packets — i.e. find the time taken between sending a packet matching rule A to receiving a packet matching rule B (concrete example would be a FIX NewOrderSingle being sent and a corresponding FIX ExecutionReport being received).

This is an example of the fields in the packet (before they’ve been converted into dictionary form) — I’m testing the numerical version of the field (in parentheses) rather than the English version:

    BeginString (8): FIX.4.2
    BodyLength (9): 132
    MsgType (35): D (ORDER SINGLE)
    SenderCompID (49): XXXX
    TargetCompID (56): EXCHANGE
    MsgSeqNum (34): 1409104
    SendingTime (52): 20100723-12:49:52.296
    Side (54): 1 (BUY)
    Symbol (55): A002
    ClOrdID (11): BUY704552
    OrderQty (38): 1000
    OrdType (40): 2 (LIMIT)
    Price (44): 130002
    TimeInForce (59): 3 (IMMEDIATE OR CANCEL)
    QuoteID (117): A002
    RelatdSym (46): A002
    CheckSum (10): 219 [correct]

Currently I have the arguments coming off the command line into a nested list:

[[35, 'D'], [55, 'A002']]

(where the first element of each sublist is the field number and second is the value)

I’ve tried iterating over this list of rules to accumulate a lambda expression:

for field, value in args.send["fields_filter"]:
    if matchers["send"] == None:
        matchers["send"] = lambda fix : field in fix and fix[field] == value
    else:
        matchers["send"] = lambda fix : field in fix and fix[field] == value and matchers["send"](fix)

When I run the program though, I get the output:

RuntimeError: maximum recursion depth exceeded in cmp

Lambdas are late-binding? So does this apply to all identifiers in the expression or just those passed in as arguments? It seems the former is true

What’s the best way to achieve this functionality? I feel like I’m going about this the wrong way currently. Maybe this is a bad use of lambda expressions, but I don’t know a better alternative for this.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T12:25:44+00:00Added an answer on May 16, 2026 at 12:25 pm

    Don’t use lambdas. They are late binding. Perhaps you want a partial from functools, but even that seems too complex.

    Your data coming in has field names, numbers and values, right?

    Your command-line parameters use field numbers and values, right?

    You want a dictionary keyed by field number. In that case, you don’t need any complex lookups. You just want something like this.

    def match( packet_dict, criteria_list ):
        t = [ packet_dict[f] == v for f,v in criteria_list ]
        return any( t )
    

    Something like that should handle everything for you.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.