[Twisted-Python] twisted and gprs

Andreas Kostyrka andreas at kostyrka.org
Mon Jan 8 17:37:17 MST 2007

* John Aherne <johna at johnaherne.co.uk> [070108 23:44]:
> Andreas Kostyrka wrote:
> >* John Aherne <johna at johnaherne.co.uk> [070108 22:28]:
> >  
> >>I'm obviously missing some obvious point I think.
> >>
> >>I need to be sure that the connection keeps on using the same source/destination ports for the duration, so the firewall lets the conversation carry on.
> >>
> >>Provided I don't close the socket at either end will the PDA and server carry on using the same set of source/destination ports.
> >>
> >>The test I did I purposely took note of the port used by the PDA as the network people told me to make sure I kept them the same. I then forced the server to send using that port as 
> >>the destination. Over the time frame of about 40  minutes I did not need to issue any keepalives. I would rather not issue keepalives since this will cost money on a gprs network 
> >>based on data usage.
> >>    
> >
> >The huge problem here is, that there are no (repeat no) assertations
> >how long firewalls keep their association. Worse, you cannot be even
> >be sure that the IP addresses of your client are unique. Technically,
> >they have to unique up to the NAT gateway.
> >
> >So basically, going the TCP way, with heart beats (that might need
> >automatic/manual tuning, depending upon the network) is a safe
> >conservative solution.
> >
> >Furthermore, GPRS is usually billed at 10/100KB increments. So doing a
> >one byte keepalive message every minute, in both directions, would
> >mean 5000 minutes or 50000 minutes before the keep alives cause real
> >costs. While making the GPRS timeout implies a new connection, and
> >lost money, because the payment increments start from zero.
> >
> >So sending a small keepalive packet is a sensible thing to do.
> >
> >Andreas
> >
> >_______________________________________________
> >Twisted-Python mailing list
> >Twisted-Python at twistedmatrix.com
> >http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python
> >
> >  
> Andreas
> Thanks for the info.
> You are right. The IP addresses are not unique. It is the combination of IP/PortNo that is unique if I understand the network people correctly. They share about 10 IPs with everyone.
Not even that. At best ports are random. Ports are 16 bit integers
(and some ranges are reserved). So if you include somehow the client
IP, you've got a problem.

OTOH, client IPs as they arrive on the server (gateway IP so to say)
plus ports should be unique.

> I'll run some more tests on how long the firewall is designed to keep its associations. And as well I'll check with the network operators.
The problem here is, that you need to consider:
*) your app will get deployed on some other network.
*) the network people change their config (e.g. because the gateway
has problems to remember all it's associations).
*) if you have not an insider connection to the real responsible, most
network operators won't be able to give you that information.
> I'll also check re the costings for keepalives.

Just take a look at the rates for GPRS. In Europe, they are billed
usually at increments of 100KB. So making a connection timeout and
reestablishing the GPRS session costs you on average 50KB that you
could use for application level keep alives.


More information about the Twisted-Python mailing list