An Introduction to the IBM 5250 Terminal and tn5250 =================================================== Author: Dave Edwards Origin date: July 3, 2006 Last updated: Oct 2, 2006 (c) Copyright by Dave Edwards 2006. All rights reserved. This is an introduction to the IBM 5250 terminal and its emulation by Telnet client software (tn5250). There are many tn5250 clients available on the Internet, and some of them are free or very low cost. The 5250 is a screen terminal, size 24 rows by 80 columns or 27 rows by 132 columns, that is used to connect to an IBM mid-range mainframe computer (iSeries, AS/400, System/36, or System/38). It is similar in many ways to the IBM 3270 terminal, which is used to connect to ESA/390 mainframe computers, but there are many significant differences between 5250 and 3270. There is a good article on AS/400 in Wikipedia (www.wikipedia.com); see also the articles "IBM 5250", "IBM 3270", and Telnet. Note that 5250, 3270, and IBM mainframes use IBM's EBCDIC character set, as opposed to the Ascii character set used by most of the rest of the computer world. Part of tn5250's job is to convert between Ascii at the client end and EBCDIC at the mainframe (server) end. The Sim390 mainframe emulator, version 1.6 and higher, can act as a tn5250 server, allowing tn5250 clients to log in to the MUSIC/SP Demo system. See below. Basic documentation: Part of the problem with 5250 is that its documentation is hard to find, not well written, and often confusing (at least in my experience). For the Telnet and tn5250 protocols, see RFCs 854, 855, 856, 885, 1091, 1205, and 2877. RFC 1205 has very useful information, including a description of the 10-byte SNA header used on tn5250 messages. Both tn5250 and tn3270 use the basic Telnet protocol (RFC 854), but with extra options negociated at TCP/IP connect time. These options are Binary Transmission, Terminal Type name, and End of Record. The options negociation is the same for 5250 and 3270, except the terminal type names are different. tn5250 usually uses terminal type names IBM-3179-2 or IBM-5292-2 (both are 24 x 80) and IBM-3477-FC (27 x 132). But the Telnet protocol is only the "wrapper" for the 5250 data. Once the options are negociated, 5250 data streams are sent between the tn5250 client program (running on a PC or workstation) and the server (e.g. an AS/400 mainframe computer). There are two types of data streams: (1) Outgoing data stream: sent from server to client, contains 5250 commands and orders to write data to the 5250 display screen and read data from the screen. (2) Incoming data stream: sent from client to server, contains data read from the screen (for example, data entered by the user into various defined fields of the screen). The contents of the data streams, including the various 5250 commands and orders, is described in the IBM manual "5494 Remote Control Unit, Functions Reference" SC30-3533-04, June/95. It can be viewed online - search for it by title or manual number on www.ibm.com. If you install IBM's Library Reader for Windows (it's free), you can download a copy of the manual (as a .boo file) and view it offline, which is handy. Some of the RFCs and other older documentation on 5250 refer to IBM manual "5250 Information Display System, Functions Reference" SA21-9247-6, but that is an out-of-date manual that does not seem to be available online. As far as I can tell, the "5494 Remote Control Unit" manual given above is now the definitive IBM documentation on 5250: how the screen is programmed, data streams, commands, orders, action keys, etc. In the manual, you can ignore most of the "gobbledegook" about SNA and network support. The sections to read are 13.4 (Negative Responses), 15 (Data Streams), and 16 (Keyboard, especially 16.2 (Keys)). Be warned that many of the 5250 features described in the manual are not supported by many tn5250 clients, or are only partially supported, or are even incorrectly supported in some cases. For example, most clients do not support PAn keys (PA1, PA2, PA3), and some do not even support the Clear key. Some clients do not allow an SBA (Set Buffer Address) order to row 1 column 0, described in section 15.6.4 of the IBM manual. If you are writing or debugging a tn5250 client or server, or just want to understand how they work, I recommend that you try as many clients as you can find, and that you examine the actual TCP/IP data passing between the client and the server. To do this, you can use a packet analyser or a port forwarder (proxy) that allows data between the client and server to be intercepted and displayed in hex and EBCDIC and Ascii character form. For Windows, you can use the program proxy.exe available at http://www.geocities.com/proxyde1 Other references: www.texas400.com has intro articles on AS/400. www.midrange.com has lots of info and links for AS/400. http://www.geocities.com/sim390 is the home page for an ESA/390 mainframe emulator that includes a tn3270 server. A tn5250 server has also been developed, and is part of Sim390 version 1.6 (and later). The tn5250 server works by using the tn3270 server system (the MUSIC/SP Demo system), and converting data streams between 3270 and 5250 formats. This is useful for testing tn5250 clients. The Sim390 tn5250 server has been successfully tested with several tn5250 clients. The 5250 terminal type names allowed by Sim390 are IBM-3179-2, IBM-5292-2 (both 24 x 80 colour), and IBM-3477-FC (27 x 132 colour). Notes on some tn5250 clients: www.mochasoft.dk (shareware, low cost, free demo version) - Works well. - The author responds quickly to emails. - The version I tried had a problem with the Clear icon. This is reportedly fixed in version 8.2. - Does not support PAn keys. http://tn5250.sourceforge.net (open-source, free) - I tried the Windows version. Download and run the file tn5250-0.17.3-setup.exe to install it. - Written mainly for Unix/Linux, but the Windows version also works. - Documentation, help, and the user interface is a bit sparse. - Does not allow SBA (Set Buffer Address) order to row 1 column 0, even though this should work. Negative Response code 10050122 occurs. - The default font does not display well (it is large and fuzzy). You can change it by View --> Change font, for example to FixedSys/Regular/12 or CourierNew/Regular/14, which display better, but any change to the font seems to remove screen line 25, which is used for the message area and cursor row/column display. - There does not seem to be any support for the 5250 Clear and PAn action keys. In fact, the keyboard assignments for the Windows version are not even documented. By trial and error, I found: - 5250 Enter (AID x'F1') = Enter - 5250 PF1 to PF12 = F1 to F12 - 5250 PF13 to PF24 = Shift+F1 to Shift+F12 - 5250 Clear (AID x'BD') = ?? - 5250 PAn = ?? - 5250 Reset = Ctrl+R - 5250 Help = ScrollLock - 5250 RollDown = PageUp (next to Home key) = Ctrl+U = Ctrl+B - 5250 RollUp = PageDown (next to End key) = Ctrl+D = Ctrl+F - 5250 Attn = Ctrl+A or Esc - 5250 Test Req = Ctrl+T - 5250 Record Backspace (AID x'F8') = Ctrl+O - 5250 Print (AID x'F6') = Ctrl+P - Exit tn5250 = Ctrl+Q - C source is available: download and use WinZip on, for example, file tn5250-0.17.2.tar.gz. This is useful if you know C and want to see details of a particular part of tn5250 (not for the faint of heart!) www.hummingbird.com (HostExplorer connectivity products, not free) - Works well. Full-featured. - Good documentation and help. - I have tried only the older HostExplorer 4.0 product. I have heard that more recent products also work. - Allows all 5250 action keys to be defined, including PAn.