Twisted server and protocol question

Discussion in 'Python' started by Benry, Aug 28, 2006.

  1. Benry

    Benry Guest

    Hi guys. I hope I can discuss Twisted here. If not, direct me to the
    correct place please.

    My question(s):
    I'm working on a custom network protocol (application layer in TCP/IP
    model) for a custom network. Please don't try to talk me out of this.
    I'm limiting many of the other protocols, because this is in a highly
    secure network, and latency/bandwidth is key. The packet sizes are
    minimized by the protocol design, which is ideal. Anyway. I'm having
    some problems with figuring out what to include in the Protocol class,
    and what to handle in the server class. Basically, I'm using Telnet,
    SMTP, and FTP protocol python files as a reference, and each have
    different strutures and methods of doing similar things. Basically,
    the protocol I'm developing is very similar to Telnet, so I used this
    code as a base. It is necessary to have a state machine, but there is
    dynamic information to send as a response to some received messages.
    For example, the server may need to get information from a DB, and send
    it in a packet as a reponse to a request. I'll give you a sample
    implementation, and the remainder of the specific questions below:

    server = a
    client = b

    1a = NEED, 1 - NEED is a request to send data from client to server,
    1 is the option, or type of data
    2b = HAVE, 1 - HAVE is a positive response
    3a = NEED, 1 - re-iterated for the purpose of being a server. The
    line "1a" is initiated only by a UI command. The line "3a" is
    initiated by as a response to the request "2b".
    4b = PASV, 1 - same as FTP. It's basically, "Well, I have data...what
    port can I send it on?"
    4a = PORT, 1, 51000 - not the same as FTP. It's the command, option,
    and port number
    5b = ACK - acknowledge
    ok...now they both disconnect, or stop communication on this port, and
    server dynamically opens port 51000
    on port 51000:
    6b - <<data stream>>
    7a - <<md5 or something other to verify correct and complete>>

    Questions I have:
    This is a state machine. The server has a class derived from the
    Protocol class whose methods are called prior to the Protocol's. For
    example, since the Server is using the derived Protocol class (let's
    say it's PProto), whenever a "dataReceived" is fired, PProto picks it
    up, and has to call Protocol's dataReceived handler explicitly. Where
    should all of this message handling take place? Should I split up the
    duties, like anything that's a singular response to one line should be
    in the Protocol class, and anything dynamic can be in the PProto class?


    What about dynamic ports? Where should this be implemented? The
    alternative is to have many connections on the one server port. Would
    this cause any issues, so that I could eliminate the PASV command
    altogether?

    I need to read the data being sent by the client. How can I correctly
    intercept this data without effecting the operation of the Protocol,
    and also so I can port the Protocol class to other applications without
    rewriting the server?

    I'm a newbie :).

    Thanks for your help.
    Benry, Aug 28, 2006
    #1
    1. Advertising

  2. Benry

    Simon Forman Guest

    Simon Forman, Aug 28, 2006
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Ben Kial
    Replies:
    1
    Views:
    782
  2. Jean-Paul Calderone
    Replies:
    0
    Views:
    430
    Jean-Paul Calderone
    Jun 17, 2008
  3. Glyph
    Replies:
    0
    Views:
    164
    Glyph
    Dec 27, 2012
  4. Glyph
    Replies:
    0
    Views:
    139
    Glyph
    Apr 3, 2013
  5. Glyph
    Replies:
    0
    Views:
    40
    Glyph
    May 12, 2014
Loading...

Share This Page