[Twisted-Python] Mixmaster Architecture
Here's an architecture question for Twisted Matrix gurus. I need to implement a "mixmaster" scheme, as follows: |--> Remote client A UDP TCP | Server <---> Mixmaster <---|--> Remote client B | |--> Remote client C | ... (etc.) Here is the background data: Server <---> mixmaster is a custom binary protocol over UDP transport. Mixmaster <---> clients is custom protocol(s) over TCP transport. The most important client type uses Telnet (raw). Server and mixmaster script live on the same PC. Remote clients have individual IPs and MACs. Server is closed-source Java; I cannot change it. Server's UDP communications is stock Java from Sun. Clients are different closed-source systems (not PCs). Mixmaster script is my Python. How to architect it? The Mixmaster script needs to multiplex communications between clients and server. The server will think it's talking to N clients, all of which know its peculiar protocol. It's OK for the server to believe they have the same IP address 127.0.0.1. There is other identifying information in the server protocol to distinguish the clients (including MACs and device name strings). I have an idea how to proceed, but still would like to hear your advice, and thank you for it. Mark
On 20 Nov 2003, "Mark Evans" <2s7l3way02@sneakemail.com> wrote:
Here's an architecture question for Twisted Matrix gurus. I need to implement a "mixmaster" scheme, as follows:
|--> Remote client A UDP TCP | Server <---> Mixmaster <---|--> Remote client B | |--> Remote client C | ... (etc.)
No this is the wrong picture. Here's a right picture: |<--| |--> Remote client A UDP| | TCP | Server <---|<--|Mixmaster<----|--> Remote client B | | | |<--| |--> Remote client C | | | ... (etc.) so you'll want something like class MixmasterProtocol(protocol.Protocol) # the TCP side def connectionMade(self): self.udp = p = protocol.ConnectedDatagramProtocol() p.datagramReceived = self.datagramReceived self.server = reactor.connectUDP('127.0.0.1', PORT, p) def connectionLost(self): self.server.stopListening() def dataReceived(self, data): pass # handle data from TCP client, maybe use self.udp.transport.write def datagramReceived(self, data): pass # handle data from server, maybe use self.transport.write
The most important client type uses Telnet (raw).
Make up your mind, telnet or raw? a Line-based protocol?
participants (2)
-
Mark Evans
-
Moshe Zadka