473,804 Members | 2,148 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Returning UDP traffic in real-time and control latency

I am capturing syslogd traffic from a firewall/router, if I display the
results to Console it runs fine and dandy, but the minute I need it to go to
a ListBox, DataGrid or even a text box problems begin to arise.

It comes down to what looks like latency, but the control are not fast
enough to refresh in time to display all of the packet contents.

I have tried threading the function, but that only increases the latency.
At one point I seriously thought it was my code:
While True
Dim data(1024) As Byte
Dim recv As Integer
recv = s.ReceiveFrom(d ata, ep)
'iep = ep '*** Only needed to get the source of the traffic ***
Dim strData As String = System.Text.Enc oding.ASCII.Get String(data, 0,
recv)
Console.WriteLi ne(strData)
End While

That is the business end of the code, and there is not much tweaking there
that can be done to speed up returns.

I have tried this code on a P4, a P3 and an old P2 with the same results,
the controls just did not refresh fast enough such that the next line of
traffic could be added.

I have compiled the code in both Debug (very bad latency about 2 messages in
3 were lost) and Release (1 in 2 to as low as 1 in 5 messages lost).
Nov 20 '05 #1
2 2329
Hi Wayne,

I dont know how many stuff are you getting and if it possible to handle it
by a vb.net windows application... but we can try. You posted the console
version :-( and what we need is the windows version, where the bug or
problem is. Any way, I suggest 3 hacks:

First trick is not up update for every packet! Update only for every half second.
Cache the results until a Timer fires, and then flush the cache into a control.

Second trick is to use a StringBuilder for caching, not a string.

Third trick is to .BeginUpdate .EndUpdate your control (eg. ListBox).

Here is a sample (with a RichTextBox... add it to the form):
' Declare at module level
Private sb As New System.Text.Str ingBuilder

' start the timer
With Timer1
.Interval = 500
.Enabled = getData
End With
While getData = True
Dim data(1024) As Byte
Dim recv As Integer
recv = s.ReceiveFrom(d ata, ep)
Dim strData As String
strData = System.Text.Enc oding.ASCII.Get String(data, 0, recv)
' Add data to cache
sb.Append(strDa ta & vbCrLf)
End While
' stop the timer
Timer1.Enabled = False
Private Sub Timer1_Tick(ByV al sender As System.Object, _
ByVal e As System.EventArg s) Handles Timer1.Tick
' flush cache
RichTextBox1.Ap pendText(sb.ToS tring)
' clear cache
sb.Remove(0, sb.Length)
End Sub
Hope this helps.
Best regards,
Mario
"Wayne M J" <no*@home.nor.b igpuddle.com> wrote in message news:uw******** ******@TK2MSFTN GP11.phx.gbl...
I am capturing syslogd traffic from a firewall/router, if I display the
results to Console it runs fine and dandy, but the minute I need it to go to
a ListBox, DataGrid or even a text box problems begin to arise.

It comes down to what looks like latency, but the control are not fast
enough to refresh in time to display all of the packet contents.

I have tried threading the function, but that only increases the latency.
At one point I seriously thought it was my code:
While True
Dim data(1024) As Byte
Dim recv As Integer
recv = s.ReceiveFrom(d ata, ep)
'iep = ep '*** Only needed to get the source of the traffic ***
Dim strData As String = System.Text.Enc oding.ASCII.Get String(data, 0,
recv)
Console.WriteLi ne(strData)
End While

That is the business end of the code, and there is not much tweaking there
that can be done to speed up returns.

I have tried this code on a P4, a P3 and an old P2 with the same results,
the controls just did not refresh fast enough such that the next line of
traffic could be added.

I have compiled the code in both Debug (very bad latency about 2 messages in
3 were lost) and Release (1 in 2 to as low as 1 in 5 messages lost).

Nov 20 '05 #2
Thanks for the reply (and sorry for the delay in response).

I ended up solving the problem, by doing nothing more than upgrading from
VS.Net2002 to VS.Net2003.

This is something that I have noticed quite a lot lately, that any code that
I wrote under 2002 suffers from latency whilst the 2003 code runs perfectly.
Nov 20 '05 #3

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

Similar topics

9
11918
by: mjm | last post by:
Folks, Stroustrup indicates that returning by value can be faster than returning by reference but gives no details as to the size of the returned object up to which this holds. My question is up to which size m would you expect vector<double> returns_by_value() {
6
4306
by: Mirek | last post by:
Hi, The application setup is: Access frontend + ODBC (TCP/IP) + MSSQL7 Few days ago i was informed that the app generates high network traffic. Thus i started to look for some savings. I found out (sniffer) that even if the client is idle every 30sek. a TCP packet comes from client to server, then answer goes back. The
8
2091
by: Derek | last post by:
Some authors advocate returning const objects: const Point operator+(const Point&, const Point&); ^^^^^ Returning a const object prevents some bad code from compiling: Point a, b, c; (a + b) = c; // error
6
2432
by: Generic Usenet Account | last post by:
Is it okay to return a local datastructure (something of type struct) from a function, as long as it does not have any pointer fields? I think it is a bad idea, but one of my colleagues does not seem to think so. According to my colleague, if the data structure does not "deep copy" issues, it is perfectly okay to return a local variable. This is because at the point of invocation, a copy of the data structure is made. In all fairness...
9
5215
by: Thomas Mlynarczyk | last post by:
Hi, It seems to be a generally adopted convention to have a function return FALSE in case of an error. But if a function is supposed to return a boolean anyway, one cannot distinguish anymore between the "normal" FALSE and the "error" FALSE. So why not using NULL instead to indicate an error? Are there drawbacks I am not aware of? Greetings, Thomas
2
2105
by: matt | last post by:
Does anyone know of a service, that provides driving traffic information in the form of xml? I see several large cities have information on the web, including traffic cameras. traffic.com has an RSS feed which has some information but when i looked at it, you can't really tell where the traffic problem is. The goal is to write a program that can take your location, such as zip code, or road/direction/city, or lat/long coordinates and...
5
3401
by: guilherme.oliveira | last post by:
Hi. What is the simple way to do a traffic counter in C ? I'm searching but there aren't any records of total transffers in /proc to get the value. Thanks in advance.
17
3265
by: I.M. !Knuth | last post by:
Hi. I'm more-or-less a C newbie. I thought I had pointers under control until I started goofing around with this: ================================================================================ /* A function that returns a pointer-of-arrays to the calling function. */ #include <stdio.h> int *pfunc(void);
34
4389
by: Victor Kryukov | last post by:
Hello list, our team is going to rewrite our existing web-site, which has a lot of dynamic content and was quickly prototyped some time ago. Today, as we get better idea of what we need, we're going to re-write everything from scratch. Python is an obvious candidate for our team: everybody knows it, everybody likes it, it has *real* objects, nice clean syntax etc.
23
2946
by: pauldepstein | last post by:
Below is posted from a link for Stanford students in computer science. QUOTE BEGINS HERE Because of the risk of misuse, some experts recommend never returning a reference from a function or method. QUOTE ENDS HERE I have never heard anyone else say that it is a problem for a function
0
9712
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9594
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10595
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10341
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
6862
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5530
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4308
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3831
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3001
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.