From: Eric Dumazet <eric.dumazet@gmail.com>
To: thomas yang <lampsu@gmail.com>
Cc: netdev@vger.kernel.org
Subject: Re: IP header identification field is zero, why?
Date: Wed, 07 Oct 2009 16:55:28 +0200	[thread overview]
Message-ID: <4ACCABE0.2070804@gmail.com> (raw)
In-Reply-To: <f4f837ab0910070704k7a193be9i285573b423b96ba2@mail.gmail.com>
thomas yang a écrit :
> This is captured on my PC (Fedora 11, Linux)
> 
> [root@localhost ~]# tcpdump -i eth1 icmp -n -x
> tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
> listening on eth1, link-type EN10MB (Ethernet), capture size 96 bytes
> 17:02:39.025882 IP 192.168.1.64 > 192.168.1.1: ICMP echo request, id
> 25096, seq 1, length 64
> 	0x0000:  4500 0054 0000 4000 4001 b717 c0a8 0140
> ......
> 17:02:39.027866 IP 192.168.1.64 > 192.168.1.1: ICMP echo request, id
> 25096, seq 2, length 64
> 	0x0000:  4500 0054 0000 4000
> 
> The  IP header 'identification' field is zero, why?
> 
> I wrote a simple UDP server and UDP client programs, and captured some
> packets, the IP identification is also zero.
> 
> Should the host increase this field for each packet it sends?
> 
> 
> I captured some TCP packets, all of the IP identification are
> different, not zero.
> 
Very good questions, this bothered me too.
ping sends "echo request" datagrams with DF set (Dont Fragment),
and ID=0, this is a user program building a packet from scratch.
When linux replies with a "echo reply", DF is not set and an ID is included
in the answer, increasing at each packet.
About your UDP tests, DF is automatically set, and
I believe ID on DF frames is generated only for connected sockets.
cf include/net/ip.h
static inline void ip_select_ident(struct iphdr *iph, struct dst_entry *dst, struct sock *sk)
{
        if (iph->frag_off & htons(IP_DF)) {
                /* This is only to work around buggy Windows95/2000
                 * VJ compression implementations.  If the ID field
                 * does not change, they drop every other packet in
                 * a TCP stream using header compression.
                 */
                iph->id = (sk && inet_sk(sk)->daddr) ?
                                        htons(inet_sk(sk)->id++) : 0;
        } else
                __ip_select_ident(iph, dst, 0);
}
next prev parent reply	other threads:[~2009-10-07 14:56 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-10-07 14:04 IP header identification field is zero, why? thomas yang
2009-10-07 14:55 ` Eric Dumazet [this message]
2009-10-08  9:08   ` thomas yang
2009-10-08  9:18     ` Eric Dumazet
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox
  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):
  git send-email \
    --in-reply-to=4ACCABE0.2070804@gmail.com \
    --to=eric.dumazet@gmail.com \
    --cc=lampsu@gmail.com \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY
  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
  Be sure your reply has a Subject: header at the top and a blank line
  before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).