473,395 Members | 1,869 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

How do i avoid packet segmentation?

Hi,
I'm writing a program that sends 1500 bytes of data at once, from the
client to the server. However, the packet is broken down into 3
different segments of 500 each before getting to the server. This is
detrimental to the program i'm writing as I need the server to receive
the entire 1500 bytes at once. How do I avoid this segmentation. Is it
a linux setting which I can change or is it a TCP setting? either way,
what can I do? I'm sending the packets using the C send() function.

Oct 12 '06 #1
7 2373
"owolablo" <ow********@yahoo.comwrote in message
news:11**********************@i3g2000cwc.googlegro ups.com...
Hi,
I'm writing a program that sends 1500 bytes of data at once, from the
client to the server. However, the packet is broken down into 3
different segments of 500 each before getting to the server. This is
detrimental to the program i'm writing as I need the server to receive
the entire 1500 bytes at once. How do I avoid this segmentation. Is it
a linux setting which I can change or is it a TCP setting? either way,
what can I do? I'm sending the packets using the C send() function.
This is acutally off topic, as this is a TCP/IP problem, not a C or C++
problem. However, the problem is not with your program, but in a MTU
(Maximum Transmission Unit) somewhere between the sending and receiving
computers. It could be the sending computer, any router inbetween or the
receiving computer. So basically, the best you can do is ensure the MTU on
the sending and receiving computer are set to a high enough value and hope
for the best.

That being said, even if right now you can get it to go in one packet there
is no guarantee that tomorrow it will be received in one packet because some
router in between may have a smaller MTU. A router/computer is allowed to
break a packet into smaller chunks. This is part of the TCP/IP protocol.
It is something you have to live with and code around. It is common to send
some type of information in a packet to say how big the data actually is, so
you can piece it back together on the receiving side.

You need to start reading up on packets, etc...

Please post any follow up questions to an appropriate newsgroup dealing with
internet protocols.
Oct 12 '06 #2
Dnia Thu, 12 Oct 2006 03:54:18 -0700, Jim Langston napisał(a):
That being said, even if right now you can get it to go in one packet there
is no guarantee that tomorrow it will be received in one packet because some
router in between may have a smaller MTU. A router/computer is allowed to
break a packet into smaller chunks. This is part of the TCP/IP protocol.
It is something you have to live with and code around. It is common to send
some type of information in a packet to say how big the data actually is, so
you can piece it back together on the receiving side.
When you send some data, the server will get them all (can be fragmented
ofcourse). IMHO sending information about packet length in TCP/IP is
useless.

--
SirMike - http://www.sirmike.org

C makes it easy to shoot yourself in the foot; C++ makes it harder, but
when you do, it blows away your whole leg. - Bjarne Stroustrup
Oct 12 '06 #3
>
This is acutally off topic, as this is a TCP/IP problem, not a C or C++
problem. However, the problem is not with your program, but in a MTU
(Maximum Transmission Unit) somewhere between the sending and receiving
computers.
Actually, it might not even be a MTU issue. TCP/IP doesn't deal
with packets on the application side. It's a byte stream. The
size you get from a read has nothing to do with what is written
on the other side (other than that you can't obviously read more
than what was sent).
Oct 12 '06 #4
SirMike wrote:
Dnia Thu, 12 Oct 2006 03:54:18 -0700, Jim Langston napisał(a):
That being said, even if right now you can get it to go in one packet there
is no guarantee that tomorrow it will be received in one packet becausesome
router in between may have a smaller MTU. A router/computer is allowedto
break a packet into smaller chunks. This is part of the TCP/IP protocol.
It is something you have to live with and code around. It is common tosend
some type of information in a packet to say how big the data actually is, so
you can piece it back together on the receiving side.

When you send some data, the server will get them all (can be fragmented
ofcourse). IMHO sending information about packet length in TCP/IP is
useless.
he was talking about *data length*, which is essentially Application
layer,
not packet length.

--
Nick Keighley

Oct 12 '06 #5
KBG
I think, it cannot break.

Regards,
Karthik Balaguru
Nick Keighley wrote:
SirMike wrote:
Dnia Thu, 12 Oct 2006 03:54:18 -0700, Jim Langston napisał(a):
That being said, even if right now you can get it to go in one packetthere
is no guarantee that tomorrow it will be received in one packet because some
router in between may have a smaller MTU. A router/computer is allowed to
break a packet into smaller chunks. This is part of the TCP/IP protocol.
It is something you have to live with and code around. It is common to send
some type of information in a packet to say how big the data actuallyis, so
you can piece it back together on the receiving side.
When you send some data, the server will get them all (can be fragmented
ofcourse). IMHO sending information about packet length in TCP/IP is
useless.

he was talking about *data length*, which is essentially Application
layer,
not packet length.

--
Nick Keighley
Oct 12 '06 #6
KBG wrote:
I think, it cannot break.
I have no idea what that is supposed to mean.

As Nick and I have pointed out, there's no such
thing as a packet on the application side of
a TCP connection. It's a byte stream. There's
no guarantee that the write size has any bearing
on the read size, any more than it does in
a stdio FILE or C++ stream.
Oct 12 '06 #7
"Ron Natalie" <ro*@spamcop.netwrote in message
news:45**********************@news.newshosting.com ...
>
>>
This is acutally off topic, as this is a TCP/IP problem, not a C or C++
problem. However, the problem is not with your program, but in a MTU
(Maximum Transmission Unit) somewhere between the sending and receiving
computers.

Actually, it might not even be a MTU issue. TCP/IP doesn't deal
with packets on the application side. It's a byte stream. The
size you get from a read has nothing to do with what is written
on the other side (other than that you can't obviously read more
than what was sent).
A new user to TCP/IP usually does something like the file:
open the connection to the server
recieve data
Process the bytes reeived.
go back to receiving data.

That's where the problem comes in. For small packets this will work, but
even if they are small sometimes they get broken anyway. So you can't
process the data received until you piece it back together. So you have to
do more like the following.

open the connection to the server
receive data
add the data to the buffer
Is the data complete? If so process it and clear the buffer
go back to receive data

For a simple file transmission it is fairly simple, just keep adding the
data to the buffer until the socket closes. Then you have all the data.
But in a client/server or peer to peer application data is usually sent back
and forth and are usually messages. There are different schemes for keying
the end of the data. For ASCII data a simple null terminator is sufficient.
For binary data, you normally send the length of the data. That way the
application knows when the data is complete.

Yes, it's a byte stream, and needs to be treated as such. But the new user
to TCP/IP usually doesn't, they treat a packet as complete data, which it
sometimes isn't.
Oct 13 '06 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: QQ | last post by:
Hello I am a newbie on network programming. I am trying to receive a packet if((numbytes = recvfrom(udp_fd1, buf, MAXLEN-1, 0,(struct sockaddr*)&register_addr, &addr_len))==-1){ fprintf(stderr,...
10
by: PH | last post by:
Hi guys! I need to get the remote EndPoint from when I receive packets when listening in a local port in my computer. I'm using UDP (connection-less) so I only bind the socket to my...
1
by: Maria | last post by:
Hi, I have read about paging, segmentation and paged segmentation and I believe I have (nearly) understood how these techniques are implemented in hardware. However, I am till confused about the...
1
by: pmm | last post by:
hi I am repeating my post here plz excuse i am trying out a UDP packet transfer between a windows machine and a linux I created a structure on both sides (ie on linux and on windows) and I sent...
3
by: madunix | last post by:
My Server is suffering bad lag (High Utlization) I am running on that server Oracle10g with apache_1.3.35/ php-4.4.2 Web visitors retrieve data from the web by php calls through oci cobnnection...
1
by: visal | last post by:
hi Please help me.i am developing a java pgm to capture network packets using jpcap.i downloded jpcap and wpcap dll files. My pgm is: import jpcap.JpcapHandler; import jpcap.Jpcap; import...
3
by: nexus024 | last post by:
I am trying to write a program that will continuously sniff eth0 for a specific UDP packet thats being sent to a specific destination IP, alter the data of the packet, and finally transmit it to the...
1
by: sangith | last post by:
Hi, I tried the packet capture module program. I did a file transfer using ftp from this host to another server. But when I ran the program, it was just hanging off and it did not print the...
1
by: AngreGanon | last post by:
Hi all~ I've written a network program in C. This program catputures ARP request packet and reply wrong ARP packet. Hi. I've written a small program to learn to write in C. But unfortunately...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.