Fun read. Does anyone here know how to deal with the Python being slow at sending ACK packets problem? Or is it a built-in limitation that comes with dealing with high level languages?
Implement it in C. Also its likely more a python problem than a "high level" language problem.
What happens if you write a TCP stack in Python?
21–30 of 125 posts
Re: What happens if you write a TCP stack in Python?
#22Shouldn't the TCP handshake look like this: ---- SYN ----> ---- ACK ----> rather than having the client send two SYNs to the server?
Re: What happens if you write a TCP stack in Python?
#23About 13 years ago, I wrote my own programming language expressly for the purpose of implementing network stacks, and had a complete TCP in it; I didn't have this problem. But I do have this problem all the time when I write direct network code and forget about buffering.
Similarly: "Python is so slow that Google reset the network connection" seems a bit unlikely too. Google, and TCP in general, deals with slower, less reliable senders than you. :)
What's the time between your SYN and their SYN+ACK?
Re: What happens if you write a TCP stack in Python?
#24Re: What happens if you write a TCP stack in Python?
#25I wonder if it would have a better success rate on a site other than Google's, since I've heard that Google's done extensive tuning of their TCP stack to send page data faster. Somebody's oversubscribed $3/month shared PHP hosting might not ramp up the speed as quickly.
Re: What happens if you write a TCP stack in Python?
#26In Uni we had a networking course where we got to build a network web server software stack from the bottom up, starting with Ethernet/MAC, TCP/IP, and then on the top HTTP, all being flashed onto a small network device (IIRC it was originally a CD-ROM server). It was an extremely enlightening exercise. I recommend you go deeper instead of just using a premade Python library for TCP!
Re: What happens if you write a TCP stack in Python?
#27I wonder if it would have a better success rate on a site other than Google's, since I've heard that Google's done extensive tuning of their TCP stack to send page data faster. Somebody's oversubscribed $3/month shared PHP hosting might not ramp up the speed as quickly.
Re: What happens if you write a TCP stack in Python?
#28Fun read. Does anyone here know how to deal with the Python being slow at sending ACK packets problem? Or is it a built-in limitation that comes with dealing with high level languages?
The answer to questions about performance is always "profile it". I mean, sure, you could probably get a crude speedup by just running it under pypy or some such, but the real answer is to profile it, see where the bottleneck is, and fix it. As the other post suggests, this is not a problem in all high-level languages; it's possible to write very high-performance code in Haskell or Ocaml, for example. But python's se…
Re: What happens if you write a TCP stack in Python?
#29The idea that Python is so slow that it's confusing TCP sounds wrong to me. I think it's more likely that your packet capture scheme is slow. It looks like you're using scapy, which I assume is in turn using libpcap... which may be buffering (in high-performance network monitoring, the packet capture interface goes out of its way to buffer). Which is something you can turn off. About 13 years ago, I wrote my own prog…
Re: What happens if you write a TCP stack in Python?
#30Earlier quoted context omitted.
Indeed
It confuses me that people make such a big deal of their little 20 lines of code toy projects.
It's pointless to people who understand how TCP works in depth, but the majority of programmers don't.