From mboxrd@z Thu Jan 1 00:00:00 1970 From: Eric Dumazet Subject: Re: IP header identification field is zero, why? Date: Thu, 08 Oct 2009 11:18:28 +0200 Message-ID: <4ACDAE64.5020101@gmail.com> References: <4ACCABE0.2070804@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: QUOTED-PRINTABLE Cc: netdev@vger.kernel.org To: thomas yang Return-path: Received: from gw1.cosmosbay.com ([212.99.114.194]:45943 "EHLO gw1.cosmosbay.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751530AbZJHJTH (ORCPT ); Thu, 8 Oct 2009 05:19:07 -0400 In-Reply-To: Sender: netdev-owner@vger.kernel.org List-ID: thomas yang a =E9crit : > The IP ID for TCP is non-zero, but for UDP is zero, strange. >=20 > I want to make the IP ID (not always zero) for UDP packets, what shou= ld I do? > (I want to use 'IP header ID, flags, offset, protocol' to identify an > IP packets) As I said, you can connect() your udp socket, if you send/receive trafi= c to/from a given destination. if (connected_sock) res =3D connect(sock, (struct sockaddr *)&addr, sizeof(addr)); (Only once) Then, your sendto() can be faster (because no route lookup is performed= ) if (sendto(sock, buffer, psize, 0, connected_socks ? NULL : (struct sockaddr *)&addr, sizeof(struct sockaddr_in)) !=3D -1) Then linux *will* generate an ID for each datagram.