Re: Bandwidth Allocation
- From: salman <alisalman@xxxxxxxxx>
- Date: Mon, 17 Sep 2007 04:22:40 -0000
Thanks Peter
I am working on a trading application, and there is 1 MB link on
trading server. Normally at a time 25 to 30 TCP clients are connecting
to server. If more than 30 clients (TCP connection) connect to the
server, then perform is going down.
Trading server sends stock market feeds to clients on request, on
client side there is a timer which sending 'a request for feed' to
server after specific time interval and then server sends the feed to
client.
Hops you all understand the problem.
Salman Ali
On Sep 15, 10:43 pm, Peter Duniho <NpOeStPe...@xxxxxxxxxxxxxxxx>
wrote:
salman wrote:
I am developing a server and I want to view and change the the clients
TCP connection bandwidth.
It's not really clear from your question what you want to do. However,
assuming you want to do the possible rather than the impossible, the
basic idea is simple:
* Displaying bandwidth requires that you count how many bytes have
been transferred over a certain amount of time. How exactly to
calculate this depends on what you want to display to the user. If you
want to display total cumulative bandwidth, you'll just note the
starting time for a transfer, count total bytes, and calculate the
current bandwidth based on the ratio of the two.
If you want some sort of trailing average, you'll have to decide how
often to update the average and for how many of those intervals back you
want to calculate the average. One technique would be to keep a list of
the byte count for each interval so that you can subtract the oldest
byte count at each interval (the time part will be constant, based on
the interval length and number).
Alternatively, you can do some sort of weighted average, in which all of
your bytes are counted, but the most recent ones are weighted more
heavily; this would allow you to calculate the trailing average without
keeping track of all of the byte counts for some fixed number of intervals.
* Changing the bandwidth is a little more complicated, but not
much. Obviously you can only restrict bandwidth; if the user wants more
bandwidth than their network will support, you can't provide that.
For restricting bandwidth, you'll simply calculate a maximum number of
bytes to transfer in some period of time, and when you reach that limit,
wait until the period of time has expired. The period of time should be
long enough that you can still send a reasonable amount of data in each
"burst", but short enough that the network transfer is reasonably smooth.
The basic idea here is that if you have some requirement to not send
data faster than, say, 100K per second then you include logic in your
code that counts bytes sent and only allows 100K to go through for any
one second interval (or 50K in a half second interval, or 200K in a two
second interval, etc.).
Pete
.
- Follow-Ups:
- Re: Bandwidth Allocation
- From: Scott Gifford
- Re: Bandwidth Allocation
- References:
- Bandwidth Allocation
- From: salman
- Re: Bandwidth Allocation
- From: Peter Duniho
- Bandwidth Allocation
- Prev by Date: Re: Question about location of a class in a WCF application
- Next by Date: Move menu items causing user to go bananas
- Previous by thread: Re: Bandwidth Allocation
- Next by thread: Re: Bandwidth Allocation
- Index(es):
Relevant Pages
|