Re: General questions about Sockets
From: David Mair (mairdanot_at_not.hotmail.com)
Date: 07/23/04
- Next message: kelly: "UDP and Serial Comm"
- Previous message: Gisle Vanem: "Re: winsock and cable disconnection"
- In reply to: Sims: "General questions about Sockets"
- Messages sorted by: [ date ] [ thread ]
Date: Fri, 23 Jul 2004 10:59:19 -0600
Sims wrote:
> Hi all,
>
> I have written a small application that sends a 512k packet to computer A
> and then waits for computer A to send a reply, (also 512k).
> I have 3 computers, (98/ME and XPpro), to test with and so far I am happy
> with the results as it does exactly what I need.
>
> I just have a few questions that hopefully you will be able to answer.
>
> The whole turn around process, (from A to B and waiting for B again), is
> about 1 second. is that too slow or is it as expected? ( I have a default
> home user network, nothing fancy).
> Is a 512k package a reasonable size unlikely to return errors? How high
> could I push it before I see the network slowing down and/or errors ?
What you describe is about 360 packets each way, a little over 1MB in
the whole round trip. That's about 8Mbps if it takes 1s. It's not
great but it's not dreadful either. I can push about 160Mbps on switched
100Base-T and the network is at saturation by that time. You should be
able to go at least as high as 30Mbps on shared 100Mbit Ethernet before
you start getting visible exponential collision rate growth (that is
based on very old information I used to use for this kind of thing).
512kB seems a lot without any response. It's also been a long time
since I reminded myself of this but you may have a Nagle challenged
design if you are using TCP. I used to read the WinSock lame list for
amusement. Given your message size I suspect you don't have a
Nagle/Delayed ACK interaction but you could confirm it with a packet
sniffer like Ethereal (free and Google should find it for you). This
would let you capture the traffic off the wire and analyse it for delays
or other problems. FWIW, I would use application layer ACKing (small
messages saying you have got some data) from the side receiving the big
message. That way there is always a small amount of traffic in the
other direction to limit the effects of delayed ACKs and RFC whatever it
is that define's Nagle's algorithm (AFAIK he doesn't like it being
called by his name).
> To ensure that there is no data loss shall I surround my data by magic
> numbers? how shall I ensure/test that there was no data loss?
> I can setup any port in my registry, but what would be the 'default' one I
> should offer my users?
I would just use TCP. Frames have a basic checksum and it provides
guaranteed delivery or failure. It used to be that you should get a
port assigned to you but there are lots of cases where no-one bothers
(I'm guilty of that too). You could just choose a high port number.
IIRC Windows has a maximum port number used for dynamic assignment,
Google could confirm it. You could play fast and loose and simply
choose a port number you like that's well above that number. I
recommend not choosing numbers that are "fun" in decimal or hex (0xBABE
for example).
> What sort of test shall I run to be really confident that I have written a
> solid piece of code?
I guess that depends on what your application does but you could just do
extended use testing and maybe throw in a few spanners like routers
(translating and not translating), Connection failure, low bandwidth
segments (10Mbit and modem if you can swing it).
> And last but not least, I am using the class CAsyncSocket, is that the best
> I can use or is there an easier/faster/more reliable way of doing things?
I've seen anecdote either way but it all seems like a subjective thing
to me. The most vehement opinions I've seen suggest that an
asynchronous socket class is truly evil. I like async sockets but I
tend not to use classes for my async implementations. Using the Google
groups page to search for CAsyncSocket may get you some useful opinion.
- Next message: kelly: "UDP and Serial Comm"
- Previous message: Gisle Vanem: "Re: winsock and cable disconnection"
- In reply to: Sims: "General questions about Sockets"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|