Register for your free account! | Forgot your password?

Go Back   elitepvpers > MMORPGs > Conquer Online 2 > CO2 Private Server
You last visited: Today at 10:41

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



Packet Size and Handling

Discussion on Packet Size and Handling within the CO2 Private Server forum part of the Conquer Online 2 category.

Reply
 
Old   #1
 
elite*gold: 67
Join Date: Aug 2014
Posts: 1,321
Received Thanks: 927
Packet Size and Handling

I was in the assumption, that you have to write sockets that take fragmented packets and combine them into one full packet, if you don't it will be your end.

Atleast thats what korvacs and many others told me back in the days. I never questioned them because I was looking up to them.. So today at my usual research routine i came across the following:

Quote:
Fragmentation, packet loss, and retransmission is all handled inside TCP/IP. Your application doesn't need to worry about it. Your application should treat a TCP socket as a stream of bytes. The bytes you put in come out in the same order. How long it takes and how many come out at once is not guaranteed.
and

Quote:
The Sockets API won't deliver you packet fragments, only complete packets. The TCP/IP stack will buffer received fragments until it has a complete packet, and if some fragments are lost the whole packet will be discarded and have to be retransmitted in its entirety.
So basically, nobody needs a fragmentation handler / Packet splitter.

I was curious and implemented a logger on Xio to tell if there were any packets of the wrong size. Result after 24h and a few 100.000 packets

0

Okay, incomming packets get merged by the stack, fine, how about outgoing packets? A packet larger than 800ish bytes closes the client, so lets send an attack packet with the size 900 and split it in two 400's.

Result: Client closes after the 2nd packet. Now, this is my problem right here which makes me question my entire research.

WinPCAP and Wireshark locked and loaded.

Turns out any packet larger than 569 bytes gets split. The maximum packetsize i can transmit is 569 bytes. my mtu is 1500 on both OS and Router. I'm really lost at this point.
Xio. is offline  
Old 09/07/2014, 17:31   #2


 
Korvacs's Avatar
 
elite*gold: 20
Join Date: Mar 2006
Posts: 6,125
Received Thanks: 2,518
That's what the documentation says, but that's not true in practice. You will find occasionally that packets are split, not because of the stack but because you read x bytes from the stack, not x packets.

If you know the exact length of a packet, and which packet is incoming then you can read a full packet without worrying about it, of course you don't know what the client will send next so that isn't possible.

There are other ways to do it of course, you can read the header and then the packet's body in sequence, this ensures that you receive complete packets every time.

Also for sending packets, your problem isn't necessarily with understand sockets, or packet splitting but the client itself. The client may simply have been written in a way that doesn't accept packets which are deliberately split.

Don't forget that if you physically send two byte[]s as two separate sends then in TCP/IP terms they are two different packets, not one. So they won't be recombined by the stack at the other end.

The client may also be written with a specific maximum incoming packet size in mind.

So a lot of things for you to consider.
Korvacs is offline  
Thanks
1 User
Old 09/11/2014, 13:11   #3
 
elite*gold: 0
Join Date: Jul 2014
Posts: 402
Received Thanks: 540
Quote:
Originally Posted by Korvacs View Post
Don't forget that if you physically send two byte[]s as two separate sends then in TCP/IP terms they are two different packets, not one. So they won't be recombined by the stack at the other end.
No, actually these "packets" can, and often will, depending on things like size and time between each send, be combined and thus the receiving end has to split the two packets apart.
Best Coder 2014 is offline  
Old 09/11/2014, 13:25   #4
 
Super Aids's Avatar
 
elite*gold: 0
Join Date: Dec 2012
Posts: 1,761
Received Thanks: 946
On Linux:

Super Aids is offline  
Old 09/12/2014, 02:36   #5


 
Korvacs's Avatar
 
elite*gold: 20
Join Date: Mar 2006
Posts: 6,125
Received Thanks: 2,518
Quote:
Originally Posted by Best Coder 2014 View Post
No, actually these "packets" can, and often will, depending on things like size and time between each send, be combined and thus the receiving end has to split the two packets apart.
They can be, but that's all determined at much lower levels, it's equally possible and probable that they will be sent separately. Really you should avoid deliberately splitting your packets as a proof as there's a lot of issues that could occur beyond your control. So for the purposes of this they should be considered separate.

But yeah if any TCP/IP experts want to go into detail feel free, it's not really my area.
Korvacs is offline  
Old 09/12/2014, 08:50   #6
 
elite*gold: 0
Join Date: Jul 2014
Posts: 402
Received Thanks: 540
Quote:
Originally Posted by Korvacs View Post
They can be, but that's all determined at much lower levels, it's equally possible and probable that they will be sent separately. Really you should avoid deliberately splitting your packets as a proof as there's a lot of issues that could occur beyond your control. So for the purposes of this they should be considered separate.

But yeah if any TCP/IP experts want to go into detail feel free, it's not really my area.




What do you mean you should deliberately avoid splitting your packets?
Best Coder 2014 is offline  
Old 09/12/2014, 09:16   #7


 
Korvacs's Avatar
 
elite*gold: 20
Join Date: Mar 2006
Posts: 6,125
Received Thanks: 2,518
Quote:
Originally Posted by Best Coder 2014 View Post




What do you mean you should deliberately avoid splitting your packets?
As in for the sake of trying to understand how the client behaves, you shouldn't deliberately take an 800 byte packet and split it in two and send two halves. Because that's not how the server would send it typically, there's no guarantee that the client will receive it as a whole packet, and there's no guarantee how the stack will behave.
Korvacs is offline  
Old 09/12/2014, 09:32   #8
 
elite*gold: 0
Join Date: Jul 2014
Posts: 402
Received Thanks: 540
Quote:
Originally Posted by Korvacs View Post
As in for the sake of trying to understand how the client behaves, you shouldn't deliberately take an 800 byte packet and split it in two and send two halves. Because that's not how the server would send it typically, there's no guarantee that the client will receive it as a whole packet, and there's no guarantee how the stack will behave.
But we were talking about packets being "merged", not split, though.
Best Coder 2014 is offline  
Reply


Similar Threads Similar Threads
Handling TCP Packet Fragmentation.
03/14/2014 - CO2 Programming - 15 Replies
Well after long time digging Network programming, one topic remains ambiguous to me. Packet Fragmentation, as far as i know TCP may not give you the message you sent as a whole but might fragment or rebuild it. So there is no guarantee that when i receive for example the Client's Login packet that it would be Full so how in all the source around here From Albetros to Pheonix i can't see any sort of Fragmentation Handling ? does it exists some how and i don't know/understand ?. Please i need a...
PACKET SIZE ERROR
03/02/2012 - 9Dragons - 4 Replies
Any1 know what is this error? O___O http://img196.imageshack.us/img196/38/beztytuuuwb b.png
Packet Handling Ways
01/17/2012 - CO2 Private Server - 5 Replies
well im interested in packet and i seen alot of examples of building packets so here is some examples Heres Example of Attack Packets : 1st Example public Attack(bool Create) { if (Create) { Buffer = new byte;
Getting packet size error
12/06/2011 - 9Dragons - 1 Replies
I need a solution for the packet size error after i update the client version and 9diciple. I can log in and once when it gets into the game map it starts showing packet size error. I m a noob with these kind of stuffs so kindly want any solution. Thanks
[Question]New way of packet handling?
01/26/2011 - CO2 Private Server - 16 Replies
I have been thinking, and to me it seems that a lot of the packet handlers (especially LOTF) are pretty large. Would it take up more resources to do something more dynamic such as the following? This is just an example obviously. But the main concept is there. The void would be your PacketID, the Arg1 would be your data. And it simply calls the method immediately rather then going through a case? class Program { static void Main(string args) { string...



All times are GMT +2. The time now is 10:41.


Powered by vBulletin®
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2024 elitepvpers All Rights Reserved.