• 0

Socket header


Question

I'm working on a server that needs to send rather small packets and about 15 of them every second i've just been going over the usage and it seems i need around 40 bytes per packet (20 ip + 20 tcp) just for the header

so 1200 bytes on the header and 165 bytes of data per second

not sure if i've worked that out right but if its true then thats a lot of overhead for such a small amount of data

i was considering using udp which would reduce that to 720 bytes however i was hoping if i could go any further

would raw sockets allow me to save even more? and even with the restrictions imposed by microsoft since xp sp2 is it still possible to make any real use of raw sockets or it simply not worth the effort?

i'm planning to receive 15 packets from approximately 40 connections so with tcp thats around 200MB an hour just to deliver 24MB worth of content (combining the packets together is not an option)

thank you in advanced :)

Link to comment
Share on other sites

5 answers to this question

Recommended Posts

  • 0
i doubt you could get much lower than UDP's 720 bytes..

what kind of data is this? and why can't you send bigger packets of 1 per second instead of 15 small ones per second..?

Yeah I don't think you'll get the overhead much smaller than that. Why can't the packets be combined?

The data is unpredictable its actually for a game that uses the old ping/pong type of communication every second it will attempt to send and receive packet 15 packets (22 bytes each way)

I reduced that to about 4 bytes up and 7 bytes down which helps a bit and yeah kind of forgot about the tcp/ip header, each packet is basically player input

ah well thanks anyway but out of curiosity how big would the raw sockets be? it would be interesting to know how small a packet can be that will transmit

cheers

Link to comment
Share on other sites

  • 0

Raw sockets simply let you build packets manually. They still require IP headers, you just have to fill them out yourself. You can't just decide to leave half of them out to save space.

So what are you left with? The payload. What are you going to put in it?

Your operating system only understands TCP and UDP, and if you're going to put a TCP or UDP packet in the payload, you will need to include the headers for those as well (you just have to fill them in manually, rather than the OS doing it). In other words, all you've done is written your own TCP/UDP implementation (which is likely inferior to the OS's) and wasted a lot of time.

Now, depending on the OS, you could create a driver for a new protocol, but how much are you going to save compared to the amount of work involved in doing so and the compatibility issues you'll end up with? A UDP header is already only something like eight bytes, and includes only the source and destination port, the length of the packet, and a checksum. If you implemented your own protocol, could you do without these? Not likely.

If you can't handle the bandwidth use, can't delay and combine packets, and can't do anything to improve prediction in the game so you need fewer packets, that's pretty much the end of the road.

Link to comment
Share on other sites

  • 0

yeah figured as much wasn't really an issue just figured the ip header was to large for what it does was hoping to find something smaller that contained the bare minimum

I can handle the bandwidth use but was hoping to reduce more if not no big deal but figured it would still be good to atleast look into rather then pass it away (as it is a hobby project)

thanks all for the feedback ^_^

Link to comment
Share on other sites

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.