Unix Programming - UDP concept help please

This is Interesting: Free IT Magazines  
Home > Archive > Unix Programming > October 2005 > UDP concept help please





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author UDP concept help please
person

2005-10-26, 6:01 pm

Hi,

I'm trying to write a program to capture as much traffic as possible
from a UDP port. I tried writing a program that ran a thread that
watched the port and stuffed each UDP message into a message queue.
The program had another thread that harvested messages from the queue
for processing. It worked like crap. I lost over 50% of the messages.

Will anyone please help by sharing a concept on how to implement this?
Or share any information that might help improve my understanding of
what I'm doing and how to best accomplish it.

Any help will be greatly appreciated. I'm running gnu c in cygwin on a
w2k intel platform.

Thanks,
Frank

entropy

2005-10-26, 6:01 pm

frank.l.lane@boeing.com wrote...
> Hi,
>
> I'm trying to write a program to capture as much traffic as possible
> from a UDP port. I tried writing a program that ran a thread that
> watched the port and stuffed each UDP message into a message queue.
> The program had another thread that harvested messages from the queue
> for processing. It worked like crap. I lost over 50% of the messages.
>
> Will anyone please help by sharing a concept on how to implement this?
> Or share any information that might help improve my understanding of
> what I'm doing and how to best accomplish it.
>
> Any help will be greatly appreciated. I'm running gnu c in cygwin on a
> w2k intel platform.


I've noticed it's incredibly easy to get a MS OS receiver to drop a
bunch of packets on connectionless protocols. Kludges I've seen in
net code include have the sender actually call sleep(1) when sending
to Windows boxes.

You could try something like that just to see if it's a receiver
capacity problem. If it isn't, then I'd suggest using a packet
capture tool to count the number of packets / bytes that are actually
being delivered to the receiver NIC, and compare that to the count of
bytes that your application is getting.

I regret I can't give you a stronger answer.
Pascal Bourguignon

2005-10-26, 6:01 pm

"person" <frank.l.lane@boeing.com> writes:

> Hi,
>
> I'm trying to write a program to capture as much traffic as possible
> from a UDP port. I tried writing a program that ran a thread that
> watched the port and stuffed each UDP message into a message queue.
> The program had another thread that harvested messages from the queue
> for processing. It worked like crap. I lost over 50% of the messages.
>
> Will anyone please help by sharing a concept on how to implement this?
> Or share any information that might help improve my understanding of
> what I'm doing and how to best accomplish it.
>
> Any help will be greatly appreciated. I'm running gnu c in cygwin on a
> w2k intel platform.


You want to avoid blocking the reader. Sending messages to a queue
will block when the queue is full!

I'd use shared memory to communicate the packets between the udp
datagram collector process and the consumer process, with a buffer big
enough for at least one second of packets, and perhaps using a
semaphore to communicate the availability of packets.


If you use threads, why do you want to store the packets into kernel
memory (message queue) when all the thread already share the process
memory??? Just keep the packets in the memory.

message queues, shared memory, semaphores are IPC = INTER PROCESS
communications. Threads inside a process have direct telepathic mind
reading capability.


--
__Pascal Bourguignon__ http://www.informatimago.com/
-----BEGIN GEEK CODE BLOCK-----
Version: 3.12
GCS d? s++:++ a+ C+++ UL++++ P--- L+++ E+++ W++ N+++ o-- K- w---
O- M++ V PS PE++ Y++ PGP t+ 5+ X++ R !tv b+++ DI++++ D++
G e+++ h+ r-- z?
------END GEEK CODE BLOCK------
person

2005-10-26, 6:01 pm

Thank you very much!:-)

person

2005-10-28, 4:53 pm

Thanks Pascal! I like the telepathic aspect of threads!:-) The final
deployment of what I'm doing right now is unknown but leaning towards
multiple processes. I'm going to try and get the threads working first
with mind reading. Thanks again!

Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com