473,385 Members | 1,546 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

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(data, ep)
'iep = ep '*** Only needed to get the source of the traffic ***
Dim strData As String = System.Text.Encoding.ASCII.GetString(data, 0,
recv)
Console.WriteLine(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 2308
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.StringBuilder

' 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(data, ep)
Dim strData As String
strData = System.Text.Encoding.ASCII.GetString(data, 0, recv)
' Add data to cache
sb.Append(strData & vbCrLf)
End While
' stop the timer
Timer1.Enabled = False
Private Sub Timer1_Tick(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Timer1.Tick
' flush cache
RichTextBox1.AppendText(sb.ToString)
' clear cache
sb.Remove(0, sb.Length)
End Sub
Hope this helps.
Best regards,
Mario
"Wayne M J" <no*@home.nor.bigpuddle.com> wrote in message news:uw**************@TK2MSFTNGP11.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(data, ep)
'iep = ep '*** Only needed to get the source of the traffic ***
Dim strData As String = System.Text.Encoding.ASCII.GetString(data, 0,
recv)
Console.WriteLine(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
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...
6
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...
8
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 +...
6
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...
9
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...
2
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...
5
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
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: ...
34
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...
23
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...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.