![]() ServerState Dispatcher Dictionary of Connections poll() method Checks 'serving' attribute value and turns on and off dispatcher So this can be changed by the GUI If serving: Calls asyncore.poll() Calls each connection poll() for each connection in the dictionaryġ4 Connection class On initialising, parses requested filename, sets options such as blksize, keeps blksize counter Has a poll method to check timeouts and re-tries Has a senddata method, called from the dispatcher handle_write method, to send any data in the tx_data attribute Acts as a parent to two child classes: SendData – for sending a file ReceiveData – for receiving a fileġ5 sends any data in tx_data poll() method checks timersĬonnection class Parse filename Parse blksize option Keep blkcount send_data method sends any data in tx_data poll() method checks timers SendData class incoming_data method checks acknowledgements if ok reads file and puts data in tx_data ReceiveData class incoming_data method writes to file, creates acknowledgement and puts it in tx_dataġ6 SendData class Inherits from the Connection class Has a poll() method to call asyncore.poll() and also to check each connection for timeouts Maintains a text attribute, which can be read by a GUI and produces logsġ3 Checks 'serving' attribute value and turns on and off dispatcher Maintains a dictionary of connections Each dictionary key is the remote client (address, port) tuple, and value is a 'Connection' object. While True: asyncore.poll() myserver.close()ġ1 Read command line options and configuration fileĬreate server GUI? NO YES GUI Loop New Thread Server Loop EXITġ2 ServerState class Has an asyncore dispatcher class as an attribute Use _init_ to bind a socket Whenever asyncore.poll() is called: Dispatcher handle_read method called when data is available Dispatcher handle_write method called to send dataĬlass MyServer(asyncore.dispatcher): def _init_(self, local_addr, local_port): asyncore.dispatcher._init_(self) self.create_socket(socket.AF_INET, socket.SOCK_DGRAM) self.bind((local_addr, local_port)) def handle_read(self): rx_data, (addr,port) = self.recvfrom(1024) def handle_write(self): sent = ndto(tx_data, (addr,port)) def handle_connect(self): pass def handle_error(self): But not Firwall friendly If server replies with port 69, must implement multiplexing for simultaneous connections.Ĩ Asyncore UDP listenning socket Create a dispatcher class Server address/port + Client address/port TFTP server listens on 69, but can reply on any port, creating a connection suitable for a threaded application. ![]() UDP not TCP - connectionless Up to the application to create a 'connection' with acknowledgements, timeouts and error packets.Ħ Uniquely identify the connection: 192.168.1.50/2002 - 192.168.1.1/69Ĭlient Client 15037 2002 26004 69 69 69 Server Uniquely identify the connection: / /69 / /69 / /69ħ The problem A 'connection' is defined by: Server acknowledges Files transferred with acknowledgements, the acks contain an incrementing block count. TFTP Protocol (revision 2) RFC 1350 TFTP Option Extension RFC 2347 TFTP Blocksize Option RFC 2348 TFTP Timeout Interval and Transfer Size Options RFC 2349ĥ Summary Client calls with a request to get or put a file Network engineer needs a simple GUI driven server for his laptop, only enabled when needed Easy to install (standard library, pure python, no dependencies, put it anywhere and run) Easy to uninstall – delete directory and files Python 2 and Python 3 versions, Linux and WindowsĤ TFTP - what? Trivial File Transfer Protocol TFTP - uses UDP port 69 No passwords, just an ip address of a server and: Get filename Put filenameģ GUI – why? No password access, so insecure Used to store and get Router and switch config files. Needed a GUI driven TFTP server Wrote it several years ago when learning Python Was a god awful mess, but recently updatedĢ TFTP -why? Trivial File Transfer ProtocolĪ way of passing files to and from a server in an easy fashion. Presentation on theme: "A Python TFTP server Bernie Network engineer"- Presentation transcript:ġ A Python TFTP server Bernie Network engineer
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |