Howto not crash Cisco’s NAT
Maiz is the dormitory of my school, and it hosts around 170 people. As a school of network & telecom, it is only natural that us students manage our own network, and so do we.
However, we suffer from severe bandwidth limitations. Indeed, because of many factors, we can only have a few ADSL lines. Still, we try to give our comrades a decent Internet connection, but with only lousy Netgears modems (see the previous post), it’s quite difficult to get the network to scale up.
So the current challenge is to find modems that will not crash after a few hours/minutes. To give you an order of idea, there is approximately 20 connections opened each second. We have to reboot the Netgear every 20 minutes in order to keep it alive…
Then we tried a Cisco 1700 with a modem card. It goes fine, but however crashed after a few hours. Reason ? Too many NAT entries and no RAM left. And indeed, Cisco’s timeouts are really, really conservative: the default TCP timeout is 24 hours. After setting those to more reasonable values, it seems to work better!
ip nat translation timeout 3 ip nat translation tcp-timeout 600 ip nat translation udp-timeout 120 ip nat translation finrst-timeout 3 ip nat translation syn-timeout 10 ip nat translation dns-timeout 3 ip nat translation icmp-timeout 3 ip nat translation max-entries 30000
You’ll note the last line setting the max-entries. Its purpose is not to limit the users, but to have the router to refuse connections before it gets out of memory.
I can’t wait for IPv6 and for this f*cking NAT to be dead! #optimistic
Why is Microsoft going to fuck everyone’s back?
Before anything, I’m far, far, very far to be a Microsoft fanboy. However, I lately came to (re-)discover things made by Microsoft that make me think that they are not the club of incompetent idiots that everybody tends to take them for.
By example, it’s of common knowledge that Microsoft did never invent anything and did copy all its products on its competitors. Really ? We’ll have a quick tour :
- Peedy the Talking Parrot (1995). Have you ever heard of him ? Well, it’s a parrot able to understand natural language to execute various tasks. In the video demos, you can see how you could control your music player using natural language sentences, and get a human-like answer (including expressions). Doesn’t it quite remember Apple’s Siri ?
- The Briefcase. You can put documents in it, and then synchronize them between computers. It appeared at least in Windows 95, and seriously reminds of Dropbox.
- Microsoft’s vision of Internet in… Windows 98 installer. Remember those texts that the installer displays in order to make you wait by teasing you on how awesome Windows is. If you read them with today’s eye, they mostly describe a vision of Internet where you can do e-shopping, have a virtual identity, etc. This vision is being realized, but its accomplishment is not even finished!
- Microsoft Bob. All right, this one is even worse than an EPIC fail, because they actually tried to make the computer look like all other common objects with the technology they had back in the time. You can’t fit a house in a screen. But you’ll fit all sorts of electronic devices, corresponding to Bob’s applications, inside your house. That’s exactly what ubiquitous computing is about! We’ll note that ubiquitous computing opposes itself to virtual reality, but I explained the relation I see between the two.
So, why a few 20-years old epic fails would mean that Microsoft is not staying in his grave? After all, as we do all know, they splendidly missed the Web 2.0 thing, and that’s what puts them in a “bad” position. But is it really a fault? Why did they need so long to get Internet Explorer back on tracks? Firefox probably stole 20% of their market share before they woke up. Don’t tell me that one of the largest company in the world can’t get a web browser right. Ironically enough, we’ll note that the whole Ajax/Web 2.0 hype relies on one and single thing: the XHR object, that was introduced by Microsoft.
But maybe that they see on the longer term. If no Web 3.0 is coming out (shut up you troll in the back), it’s probably because the Web 2.0 is merely a transition to something else, that is, once again, ubiquitous computing. See the smartphone/tablets delirium that’s floating around? It’s only the beginning.
And for 20 years, Microsoft did not make a move on anything. They just polished their Office pack, killed GPU for Aero to work and other superficial stuffs like that. Fundamentally, Windows 7 does nothing more than Windows 3.11, if you make abstraction of the technical side of things. But for 20 years, Microsoft Research was not shut down, and you sometimes see them surfacing. Like Surface, or all the thing’s they’ve been doing on robotics. Those things are still in the labs, because they’ve learned of their mistakes and now they’ll wait for the market to be ready before to take a product out.
The first strike: the Kinect of course. What’s next? Who knows… My belief is that they’ll use a strategy similar to Apple’s. When a new product starts to take off (like smartphones by example), they commercialize a new product more advanced than all of the others (at least, marketingly speaking).
In other words, if you’re going to do new products, watch your back, because Microsoft probably has a better one in its labs!
There is however another possiblity: Microsoft guys are indeed plain idiots, and thus Microsoft Research did never manage to get anything working, which means that in 10 years I’ll re-read this post and roll on the floor laughing to be so wrong. Time will tell :)
“Modem” (= bridge) mode on Netgear DG632
Recently I configured a Netgear DG632 in a bridge mode. Initially I was expecting the modem to translate from PPPoE on the LAN port to PPPoA on the WAN port. Wrong :)
In short, the configuration :
---- Machine 1
((Internet))----[ DG632 ]----[ Gateway ]----|---- Machine 2
---- Machine N
Actually, it dials the ISP and identifies itself just as in the router mode, but the difference is that it expects to find a computer with the public IP on the LAN port. However the router that you gateway must use is not the one given by IPCP, and rather the management IP of the modem. Here’s the relevant part of my FreeBSD’s rc.conf:
ifconfig_re1="inet 193.251.78.150 netmask 255.255.255.0" static_routes="adsl" route_adsl="-host 192.168.1.1 -iface re1"
New Project: Karte
Nothing ground-breaking today, I’m just starting a new project. Once again it’s university-related, and this time it’s going to have a real-life application. Indeed, the goal is to create a payment card for all pupils. It’s going to allow electronic micro-payments in various places and occasions (parties, cafeteria, …).
There will be a client, used on the points of sale, and a server, probably backed-up by a PostgreSQL database. The client is going to use Qt, and the server will use the very good Twisted framework, that is a Python framework that allows you to easily create and deploy network applications.
For now the only thing more or less advanced is the data model, created using the Django ORM and Modelviz. We probably won’t use the ORM at all, but it helped to design the database without loosing too much time with poor database design tools. And it generates both the graph and the SQL!
Regarding the “card” technology in itself, it’s probably going to be RFID/NFC. Not because it’s hype, but because it’s cheap and the student card is a NFC anyway, so we’ll try to use it! And by the way, NFC is quite the same thing as RFID, it’s just that RFID designates a wider range of technologies than NFC. In case you are being confused, it’s just marketing, not technology.
Anyway, since I’m being evaluated on this project, I’m pretty sure I will finish it, or at least greatly advance it. So stay tuned to see how it turns out :)
Old Blog
To those nostalgic of the old blog, it can still be found at http://old.hyperthese.net/.
Smooth OpenGL Text Scrolling: Getting It Right
My first challenge with CanalK: getting the text scrolling smooth. I must warn that I lack of any theoretical training on computer graphics, so some things I say here might be quite basic for experts, but I couldn’t find them explicitly said elsewhere, thus it might be helpful anyway.
All right, back to our scrolling problem. Remember the screen structure?
You’d think that scrolling a text (or a picture) is easy, you just take the time delta since last frame, multiply it by the speed and add that to the text’s position, and you’re done. Unfortunately, this is completely wrong.
Let’s start with the current version. It is plain Qt, and uses the animation framework to move the text. So it’s supposedly well tested, fluid, and everything. And indeed, it is far from using the full CPU, and the FPS looks pretty decent. However, from time to time (around each second) the text jumps.
Later when doing the same thing with OpenGL, I got some similar troubles as well. So what’s happening? Let’s suppose that our rendering process generates 10 frames per second, but that the screen only displays 9 frames per second. When the screen displays a frame, it takes the last generated frame.

What you can see here is that obviously the frame 5 is skipped. That’s only logical because the screen can display less frames than generated. But the text was supposed to go through the position in generated frame 5, and instead jumps from 4 to 6. Culprit is found!
Another thing is: my intuition was to calculate the time delta between to frames with a timer, by watching elapsed time between two calls of the update() function. Very wrong. Indeed, the GPU displays a frame exactly 60 times per second. Which means that whatever I’m doing, the delta will be 1/60s, no more, no less, unless I take too long to render my frame, but in a simple 2D application this should not be the case. The timestamp of the frame generation does not matter in the slightest, what counts is only the time when the frame is displayed.
Now the main problems are identified, what is the solution?
- You must generate the exact same number of frames than your screen. Yup, that’s vsync. There is several ways to do it, and no real standard method. The NVidia driver offers an option, you can also set the environment variable __GL_SYNC_TO_VBLANK to 1. If like me you’re using Qt, just use QGLFormat::setSwapInterva().
- Under normal circumstances, you will set the swap interval to 1 (you swap the buffers every frame), but if you can’t be fast enough for 60FPS, you’ll have to do 30FPS by setting the swap interval to 2.
- If you’re scrolling a text at constant speed, don’t calculate anything and just add a constant to the position, preferably an integer to avoid sub-pixel problems.
By respecting those points I was able to get a perfectly fluid text, so this more or less proves me right. However, this is just a theory I have about a phenomenon I observed, and maybe that I’m wrong… Anyways, scrolling really looks like one of the worst things to do, because the eye won’t be so touchy with other effects, like fade to black.
Once again, this shows that in programming it is very important to be able to know your limits, because there is no secret formula that’s going to help you managing dropped frames (that you can’t predict). Hope my advises here will be useful !
Intro to CanalK
Hey, my first real post! This is a quick intro to the CanalK project. Not that I think that it will move the world forward, but it might help to understand the next posts. In my school, we previously had TV in the corridors to display pictures, like the posters for the next events. The old system eventually broke, so it was changed by something more modern. In short, a Qt/C++ application fetches slides from a server, and displays them.
The application presents itself as follow: there is a large area dedicated to display the content (pictures, videos, web pages), and a not-so-small strip on top of the screen, with our logo, the current time, and a sliding text.
Pretty simple, huh? Not so fast! I must mention that in order to display this application, we use a mini-PC with a wild hot config you can only see in your dreams: Intel Atomshit D510 + Intel icrap915. For starters, you basically take a 10-years old PC, remove some features, and there you go. By the way, at the time screens had a resolution like 800×600, but here we’re talking about 1920×1080. I talked about dreams, did I mention nightmares?
The currently used application is written in plain Qt/C++, and you can find the sources on gitorious. However, it suffers from various lags and other issues because of the poor hardware. After the videos went randomly blinking without a proper reason, I decided to re-write most of it using pure OpenGL.
Let’s hope it works better, see the following posts to find out!




