473,398 Members | 2,404 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,398 software developers and data experts.

Bandwith Shaping

Just curious - is there an easy way to shape bandwith in python. If I
wanted to have a max download speed for instance

-thanks

Jul 19 '05 #1
2 1342
flamesrock wrote:
Just curious - is there an easy way to shape bandwith in python. If I
wanted to have a max download speed for instance

-thanks

Interesting normally bandwidth shaping is an IP stack function

in the Kernel.

You are receiving a download within a python program?
And want to slow it down?
You could put a sleep(.01) in your receive loop.
That's about as fine as sleep gets, i've read.

But those packets ( I assume TCP ) are going to stack up somewhere,
the sender is gonna keep trying and retrying. In other words
you are increasing overall load to someone's router and the
network.
Someone correct me if I'm drunk on this.

Jul 19 '05 #2
Am Mittwoch, 4. Mai 2005 20:11 schrieb phil:
But those packets ( I assume TCP ) are going to stack up somewhere,
the sender is gonna keep trying and retrying. In other words
you are increasing overall load to someone's router and the
network.
This is not true, as TCP tries to adjust its sending speed at the sender end
to the receiving speed at the receiver end (it raises speed until packets
start getting dropped, and when they are, it starts decreasing send speed
again).

Of course, this requires a proper TCP implementation, but any operating system
should have one.

What you said, with a sleep(.01) is actually not quite the way to go. What you
could do is something like the following:

MAX_RATE = 1*1024 # (1k)
MAX_SEND = 1024
data = "blabber"
sent = 0
starttime = time.time() - 0.01
while data:
curtime = time.time()
if sent / ( curtime - starttime ) > MAX_RATE:
time.sleep(0.5)
continue
newsent = sock.send(data[:MAX_SEND])
data = data[newsent:]
sent += newsent
Someone correct me if I'm drunk on this.


See above. ;)

--
--- Heiko.
listening to: Pearl Jam - Man Of The Hour
see you at: http://www.stud.mh-hannover.de/~hwundram/wordpress/

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)

iD8DBQBCeT1Df0bpgh6uVAMRAsYuAJsGuQh+cKGhMPizKZQsBh Ehmv15egCcC2A/
/vn+cQhJptSLBGIHcj4iPE4=
=cYxi
-----END PGP SIGNATURE-----

Jul 19 '05 #3

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

Similar topics

1
by: smjmitchell | last post by:
Hi All, I am developing a application in VB 6.0. I need to plot a 3D mesh of quadrilateral and triangular polygons. I have this working OK in wireframe. The question I have is what is the...
0
by: Gordon Knote | last post by:
H is it possible to detect the bandwith of all network adapters (NICs only), that are installed on a winxp system programmatically (any language, .net or C/C++)?
0
by: Stephan Steiner | last post by:
Hi I'm trying to get some control over the speed I'm sending out packets in a networking application. Using UDP sockets, if I send at full speed, I eventually have packets that never make it on...
0
by: Mike Kingscott | last post by:
Hi all, I wonder if anyone can help? I have a need to display some data on my web page (the results of a search) for links. Here's the thing: Each link can belong to one or more category (yes, I...
2
by: doar123 | last post by:
Hello, I'm using a shape query, but instead of using a simple clause "RELATE field1 to field2" (relates the parent to the child), i wan't to use 2 relates. somthing like "RELATE field1 to field2...
5
by: DCaballero | last post by:
Hi, I've seen on some applications like emule, options on limiting the amount of outgoing and incoming bandwith the application uses. How can I incorporate this into my application? Is this done...
3
by: Jeff Jarrell | last post by:
I'd like to create a service-locator\proxy type service that I can use to simulate low bandwith situations and latency issues on the service under test. The request comes from the client, is...
2
by: Nazman | last post by:
Hi; I am trying to find out what is the recommended bandwith requirements for a user accessing a SQL database through a WAN link . I do not have the capability to do any WAN monitoring. Naz
3
by: TimVtoo | last post by:
Hello everyone. This pretty much the first time posting in a forum, so please dont shout at me for doing something wrong :). SQL SERVER 2005 CLASSIC ASP VBSCRIPT SQL Server And IIS are running...
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...
0
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,...
0
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...
0
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.