From owner-freebsd-net@freebsd.org Thu Feb 18 22:41:32 2016 Return-Path: Delivered-To: freebsd-net@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id A0AE7AAC32D for ; Thu, 18 Feb 2016 22:41:32 +0000 (UTC) (envelope-from rizzo.unipi@gmail.com) Received: from mail-lb0-x22f.google.com (mail-lb0-x22f.google.com [IPv6:2a00:1450:4010:c04::22f]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 29B5713B0 for ; Thu, 18 Feb 2016 22:41:32 +0000 (UTC) (envelope-from rizzo.unipi@gmail.com) Received: by mail-lb0-x22f.google.com with SMTP id of3so37257686lbc.1 for ; Thu, 18 Feb 2016 14:41:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:date:message-id:subject :from:to:cc:content-type; bh=w//SiT9inyaQu+M8JIrbfQt7Twmyn2URL2DoOmehoR4=; b=bhyehQOKoTg8WVdyGFS1XMQShukYV967XjZgJp60pAijYgEWqCZds15T0FnrODWRv9 fYtIqlC/hVjjoh+JEX41JRmiBUCM0SNps/eCGYAuzJxAIHvAGO46I/Pl8wWvNsa3AfAd HWl8Ah1Dcvuql12VykdFs97ZWM9OtuWxiotchlueibzS6sBDgo2WsWkNoZXqsAxUbFAi vUkKPKA5yUUaefc3JIyCKjYz4jsWlJVo5cVqj91uoviUHs9PHRbdL878yOggiDjASufq UXKfE42+ob0xqeanqBe06u0ljjCy2EWyU5qEhMebGvVPEzG8vpVEc2UqU/83r7Ht4VAp YV/g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:sender:in-reply-to:references:date :message-id:subject:from:to:cc:content-type; bh=w//SiT9inyaQu+M8JIrbfQt7Twmyn2URL2DoOmehoR4=; b=DaQAYb+rrpMqMroaz11qefWNs1ARIARpYRjI48ZKYqHCdv+im9lNd8JwTS5HNTshNh f+TCFH2tV0A2qydZXLoD1Et7MfS6V0kUNQ2vbHmvSZeEiYUc3/BEutnXBJhzNzn8LWcp C+LDwb5emEeGATvuwBapjuQ03M+T8WEMBtZ5pfipgxRce5vPurMlZTHuZZz0K/rOB3N+ 8ZtX2MIk8CW8TZKS6FL6toloFcJD6GfXDmn0xvH3R4+SpqLWyQXIGzJ/5RRIT8eLCOA/ GiSnSKksfTxohJ3v8K/MiEj48vchg9PGMThj7gFVtB3RUJTKfqzcFZ7mKjZFsnJ/ycTO eyIA== X-Gm-Message-State: AG10YOQV21IKZDBKTbJJeu/CslgCl7AmtgM8BPvDx28bHEQsDZ3jDOGmIwAkkjF4FyWEgOTpnSl1fjQAIUwQww== MIME-Version: 1.0 X-Received: by 10.112.170.73 with SMTP id ak9mr4151697lbc.92.1455835290318; Thu, 18 Feb 2016 14:41:30 -0800 (PST) Sender: rizzo.unipi@gmail.com Received: by 10.114.184.146 with HTTP; Thu, 18 Feb 2016 14:41:30 -0800 (PST) In-Reply-To: References: Date: Thu, 18 Feb 2016 14:41:30 -0800 X-Google-Sender-Auth: 2_sLt97vgKBJ8eCEiSqlZ1k0HJg Message-ID: Subject: Re: netmap packet timestamping From: Luigi Rizzo To: Chris Inacio Cc: "freebsd-net@freebsd.org" Content-Type: text/plain; charset=UTF-8 X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Networking and TCP/IP with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 18 Feb 2016 22:41:32 -0000 Hi, when you call poll() or one of the ioctl, the timestamp is saved in the netmap_ring and you can access it from there. This is roughly as good (or as bad) as the timestamp supplied by the OS kernel in the regular network stack. Differences: - the kernel network stack typically produces a timestamp when the interrupt/NAPI thread runs, which is not when packet was received. Packets processed in the same run of the interrupt handler may have slightly different timestamps but the interval between packets has no relation to the actual interarrival times. - the timestamp provided by netmap in the netmap ring only indicates the last time the *_rxsync() has been called. This happens during the execution of a system call, so when the calling process is about to be woken up. Again it does not correspond to the actual packet arrival time, though the process may run slightly later than the interrupt thread in the previous case, depending on priorities. We could in principle have the interrupt thread update the timestamp in the ring but that would be racy. There is only a single timestamp for the entire ring, which helps reminding you that you cannot compute interarrival times for packets that arrive in the same interrupt. cheers luigi On Mon, Feb 15, 2016 at 6:20 PM, Chris Inacio wrote: > Hello all, > > I'm trying to write some code to work with netmap which previously worked > with PCAP API. In the PCAP API it's easy enough to get the timestamp the > packet arrived from the API, but I can't find that (easily) from the netmap > API. I'm not concerned with Tx, only Rx. > > Is there an easy place to get the packet timestamp? I saw the timestamp in > the flags, but it wasn't clear to me that it would be a received timestamp. > > Also, since I'm not a regular list reader, please keep my email address on > the thread too. > > Thanks > chris inacio > _______________________________________________ > freebsd-net@freebsd.org mailing list > https://lists.freebsd.org/mailman/listinfo/freebsd-net > To unsubscribe, send any mail to "freebsd-net-unsubscribe@freebsd.org" -- -----------------------------------------+------------------------------- Prof. Luigi RIZZO, rizzo@iet.unipi.it . Dip. di Ing. dell'Informazione http://www.iet.unipi.it/~luigi/ . Universita` di Pisa TEL +39-050-2217533 . via Diotisalvi 2 Mobile +39-338-6809875 . 56122 PISA (Italy) -----------------------------------------+-------------------------------