Networking Forums

Networking Forums > Computer Networking > Linux Networking > (socket) send transmits data on same packet

Reply
Thread Tools Display Modes

(socket) send transmits data on same packet

 
 
alexia.bee@gmail.com
Guest
Posts: n/a

 
      05-28-2008, 06:25 PM
Hi all,

I noticed that when I use send() function to send data to remote PC,
I
see all the data on same packet (Wireshark) even though I used send
more than once.
For example,

send("er");
send("an");
send("ya");

I will see the data on same packet rether than 3 packets.


thanks.
 
Reply With Quote
 
 
 
 
Tauno Voipio
Guest
Posts: n/a

 
      05-28-2008, 07:35 PM
(E-Mail Removed) wrote:
> Hi all,
>
> I noticed that when I use send() function to send data to remote PC,
> I
> see all the data on same packet (Wireshark) even though I used send
> more than once.
> For example,
>
> send("er");
> send("an");
> send("ya");
>
> I will see the data on same packet rether than 3 packets.



If you're using a stream socket (TCP), it is
perfectly normal.

TCP guarantees only that all octets (bytes) sent
eventually arrive at the destination in the same
order as they are sent.

There's no guarantee whatsoever of correspondence
of the socket write lengths and the lengths of the
packets on wire.

If you want to preserve record boundaries, you have
two options:

- Embed the record boundary markers or record
lengths into the TCP data stream, or

- use UDP (and be prepared for missing and/or mis-
ordered packets).

--

Tauno Voipio
 
Reply With Quote
 
David Schwartz
Guest
Posts: n/a

 
      05-29-2008, 07:02 PM
On May 28, 11:25*am, alexia....@gmail.com wrote:
> Hi all,
>
> I noticed that when I use send() function to send data to remote PC,
> I
> see all the data on same packet (Wireshark) even though I used send
> more than once.
> For example,
>
> send("er");
> send("an");
> send("ya");
>
> I will see the data on same packet rether than 3 packets.
>
> thanks.


So what? TCP applications don't care about packets.

If you ask FedEx to send three packages to Asia, does it matter to you
whether they go on three trucks or one truck? (And wouldn't it be
really dumb to expect them to take three separate trucks if they all
fit in one truck?)

TCP implements a division of responsibility. Just as using FedEx means
you don't have to care how many trucks or planes the package takes,
using TCP means you don't have to care about how many packets the
bytes take.

Just as FedEx might route a package in a way that naively seems like
the long way (maybe the truck that went directly was full, maybe there
was a storm and the plane took a strange route), TCP sometimes gets
the data to the other side in ways that naively seem odd or wrong. In
this case, it's obvious why TCP did what it did. The total number of
bytes sent is lower this way because each packet has overhead.

If you care if your three packages all go in the same truck, you can't
use FedEx (because they don't guarantee this). But there is no reason
you should care. Similarly, if you care if your bytes go in the same
packet, you can't use TCP (because it doesn't guarantee this). But
there's no reason you should care.

DS
 
Reply With Quote
 
 
 
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to send out a packet urgently? Bill Unruh Linux Networking 8 11-28-2007 06:13 PM
How to get data in kernel SEND buffer for a TCP socket from a netfilter based kernel module Rohit Linux Networking 0 05-10-2007 11:27 AM
udp send data Ludwig Moser Linux Networking 0 04-20-2006 11:00 AM
How to send a packet to wake on lan steve Windows Networking 0 02-12-2004 02:30 PM
tcp send bigger data faster then small data Stephan Absmeier Linux Networking 20 10-29-2003 02:40 PM



1 2 3 4 5 6 7 8 9 10 11