⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 tyt06fi.htm

📁 一个学习tcp/ip协议的教程
💻 HTM
📖 第 1 页 / 共 5 页
字号:
<HTML><HEAD><TITLE>tyt06fi.htm</TITLE><LINK REL=ToC HREF=index-1.htm><LINK REL=Index HREF=tppmsgs/msgs0.htm#37><LINK REL=Next HREF=tyt07fi.htm><LINK REL=Previous HREF=tyt05fi.htm></HEAD><BODY BGCOLOR=#FFFFFF TEXT=#000000 LINK=#0000FF VLINK=#800080><A ID=I0 NAME=I0></A><P><P ALIGN=CENTER><A HREF=tyt05fi.htm TARGET=_self><IMG SRC=blanprev.gif WIDTH = 37 HEIGHT = 37 BORDER = 0 ALT="Previous Page"></A><A HREF=index-1.htm TARGET=_self><IMG SRC=blantoc.gif WIDTH = 37 HEIGHT = 37 BORDER = 0 ALT=TOC></A><A HREF=tyt07fi.htm TARGET=_self><IMG SRC=blannext.gif WIDTH = 37 HEIGHT = 37 BORDER = 0 ALT="Next Page"></A><HR ALIGN=CENTER><P><UL><UL><UL><LI><A HREF=#E68E59>Telnet</A></LI><UL><LI><A HREF=#E69E82>Telnet Connections</A></LI><LI><A HREF=#E69E83>Telnet Commands</A></LI><LI><A HREF=#E69E84>TN3270</A></LI></UL><LI><A HREF=#E68E60>File Transfer Protocol (FTP)</A></LI><UL><LI><A HREF=#E69E85>FTP Commands</A></LI><LI><A HREF=#E69E86>FTP Connections</A></LI><LI><A HREF=#E69E87>FTP Third-Party Transfers</A></LI><LI><A HREF=#E69E88>Anonymous FTP Access</A></LI><LI><A HREF=#E69E89>FTP Servers</A></LI></UL><LI><A HREF=#E68E61>Trivial File Transfer Protocol (TFTP)</A></LI><UL><LI><A HREF=#E69E90>TFTP Commands</A></LI><LI><A HREF=#E69E91>TFTP Packets</A></LI></UL><LI><A HREF=#E68E62>Simple Mail Transfer Protocol (SMTP)</A></LI><UL><LI><A HREF=#E69E92>SMTP Commands</A></LI></UL><LI><A HREF=#E68E63>The Berkeley Utilities</A></LI><UL><LI><A HREF=#E69E93>The hosts.equiv and .rhosts Files</A></LI><LI><A HREF=#E69E94>rlogin</A></LI><LI><A HREF=#E69E95>rsh</A></LI><LI><A HREF=#E69E96>rcp</A></LI><LI><A HREF=#E69E97>rwho</A></LI><LI><A HREF=#E69E98>ruptime</A></LI><LI><A HREF=#E69E99>rexec</A></LI></UL><LI><A HREF=#E68E64>Summary</A></LI><LI><A HREF=#E68E65>Q&amp;A</A></LI><LI><A HREF=#E68E66>Quiz</A></LI><LI><A HREF=#E68E67>Workshop</A></LI></UL></UL></UL><HR ALIGN=CENTER><A ID=E66E6 NAME=E66E6></A><H1 ALIGN=CENTER><CENTER><FONT SIZE=6 COLOR=#FF0000><B>&#151; 6 &#151;</B><BR><B>Telnet and FTP</B></FONT></CENTER></H1><BR><P>In the last five days you have seen the architecture of TCP/IP, as well as both the Internet Protocol and the Transmission Control Protocol in considerable detail. Building on these two protocols is a layer of application-layer protocols that are commonly associated with TCP/IP. Today I look at the most common application layer protocols: Telnet, File Transfer Protocol (FTP), Trivial File Transfer Protocol (TFTP), and Simple Mail Transfer Protocol (SMTP), as well as a suite of tools called the Berkeley r-utilities.<BR><P>To cover all four protocols in complete detail would require several hundred pages, so today I examine the protocols' most important aspects, including their purposes, their relations to TCP and IP, their control codes and behavior, and their typical usage. Each of the four application layer protocols has advantages that make it ideally suited for a particular purpose. I hope that by the end of the day you will understand why they are used and how they fit into the TCP/IP world.<BR><BR><A ID=E68E59 NAME=E68E59></A><H3 ALIGN=CENTER><CENTER><FONT SIZE=5 COLOR=#FF0000><B>Telnet</B></FONT></CENTER></H3><BR><P>The Telnet (telecommunications network) program is intended to provide a remote login or virtual terminal capability across a network. In other words, a user on machine A should be able to log into machine B anywhere on the network, and as far as the user is concerned, it appears that the user is seated in front of machine B. The Telnet service is provided through TCP's port number 23 (see Table 4.1 or Appendix D, &quot;Well Known Port Numbers,&quot; for the TCP port numbers). The term Telnet is used to refer to both the program and the protocol that provide these services.<BR><P>Telnet was developed because at one time the only method of enabling one machine to access another machine's resources (including hard drives and programs stored there) was to establish a link using communications devices such as modems or networks into dedicated serial ports or network adapters. This is a little more complicated than might appear at first glance because of the wide diversity of terminals and computers, each with their own control codes and terminal characteristics. When directly connected to another machine, the machine's CPU must manage the translation of terminal codes between the two, which puts a hefty load on the CPU. With several remote logins active, a machine's CPU can spend an inordinate amount of time managing the translations. This is especially a problem with servers that can handle many connections at once: if each had to be handled with full terminal translation, the server CPU could be bogged down just performing this function.<BR><P>Telnet alleviates this problem by embedding the terminal characteristic sequences within the Telnet protocol. When two machines communicate using Telnet, Telnet itself can determine and set the communications and terminal parameters for the session during the connection phase. The Telnet protocol includes the capability not to support a service that one end of the connection cannot handle. When a connection has been established by Telnet, both ends have agreed upon a method for the two machines to exchange information, taking the load off the server CPU for a sizable amount of this work.<BR><P>Usually, Telnet involves a process on the server that accepts incoming requests for a Telnet session. On UNIX systems, this process is called telnetd. On Windows NT and other PC-based operating systems, a Telnet Server program is usually involved. The client (the end doing the calling) runs a program, usually called telnet, that attempts the connection to the server. A relative of the telnet program is the program rlogin, which is common on UNIX machines and which I look at later today; see the section titled &quot;The Berkeley Utilities.&quot;<BR><BLOCKQUOTE><BLOCKQUOTE><HR ALIGN=CENTER><BR><NOTE><IMG SRC=note.gif WIDTH = 75 HEIGHT = 46>The rlogin program provides almost identical functionality to Telnet and adds support for the UNIX environment. Many machines, especially UNIX workstations, act as both client and server simultaneously, enabling a user to log into other machines on the network and other users to log into the user's machine.</NOTE><BR><HR ALIGN=CENTER></BLOCKQUOTE></BLOCKQUOTE><BR><A ID=E69E82 NAME=E69E82></A><H4 ALIGN=CENTER><CENTER><FONT SIZE=4 COLOR=#FF0000><B>Telnet Connections</B></FONT></CENTER></H4><BR><P>The Telnet protocol uses the concept of a <I>network virtual terminal, </I>or NVT, to define both ends of a Telnet connection. Each end of the connection (each NVT) has a logical keyboard and printer. The logical printer can display characters, and the logical keyboard can generate characters. The logical printer is usually a terminal screen, whereas the logical keyboard is usually the user's keyboard, although it could be a file or other input stream. These terms are also used in the File Transfer Protocol (FTP) and Simple Mail Transfer Protocol (SMTP). Figure 6.1 illustrates the NVT and logical keyboard and printer.<BR><P><B><A HREF=06tyt01.gif>Figure 6.1. A network virtual terminal for </B><B>Telnet.</A></B><BR><P>The Telnet protocol treats the two ends of the connection as NVTs. The two programs at either end (telnet and telnetd for a UNIX server) manage the translation from virtual terminals to actual physical devices. The concept of virtual terminals enables Telnet to interconnect to any type of device, as long as a mapping is available from the virtual codes to the physical device. One advantage of this approach is that some physical devices cannot support all operations, so the virtual terminal does not have those codes. When the two ends are establishing the connection, the lack of these codes is noted, and sequences that would use them are ignored. This process is straightforward: one end asks whether the function is supported, and the other replies either positively or negatively. If it is supported, the necessary codes are sent. The list of supported functions is covered quickly in this manner.<BR><P>When a connection is established through Telnet, telnetd (or whatever program is acting as the Telnet server) starts a process on the server for running applications. Every keystroke in a Telnet session must go through several different processes, as shown in Figure 6.2. Each keystroke goes through telnet, telnetd, and the applications that are used during the Telnet session. Some applications want to communicate through a terminal device, so the remote system runs a pseudo-TTY driver that acts like a terminal to the application. If a windowed interface such as X or Motif is used on the host and remote machines, the systems must be instructed to enable windowing information to be passed back and forth; otherwise, the remote machine tries to open the windows on the server.<BR><P><B><A HREF=06tyt02.gif>Figure 6.2. A Telnet connection.</A></B><BR><P>To start Telnet, you must provide either the name or the IP address of the machine to be connected with. The name can be used only if the system has a means of resolving the name into its IP address, such as with the Domain Name System. A port name can usually be used to connect to a specific service, but this is used infrequently. For example, to connect to a machine with the IP address 205.150.89.1, you would enter this command:<BR><BR><PRE><FONT COLOR=#000080>telnet 205.150.89.1</FONT></PRE><P>If the system had the name darkstar, which was resolvable into its IP address, you could issue this command:<BR><BR><PRE><FONT COLOR=#000080>telnet darkstar</FONT></PRE><P>If no name, address, or port is specified, Telnet enters its command mode and waits for specific instructions. When the connection is established, a user ID and password are requested. You can log in with any user ID that is valid on the remote system (it does not have to be the same user ID you have on the local system). A typical connection to a UNIX server looks like this:<BR><PRE><FONT COLOR=#000080>telnet 205.150.89.1Trying...Connected to tpciEscape character is '^]'.HP-UX tpci A.09.01 A 9000/720 (ttys2)login: tparkerpassword: xxxxxxxx$</FONT></PRE><P>As you can see in the preceding code, Telnet tried to connect to the remote system, told you it was connected, then set up the communications parameters between the two systems. When that was done, the login prompt was displayed (as on any UNIX terminal), followed by a password request. If the login and password are enabled, the UNIX shell prompt (a dollar sign) is shown to indicate that the remote machine is now active.<BR><P>You can use a machine name as part of the Telnet command only if the system has a means of resolving the name to its IP address. If not, no connection is established, although Telnet might remain in command mode. To exit, use Ctrl+D or the break sequence displayed as part of the start-up message.<P>You can enter Telnet's command mode at any time, usually by using the Ctrl+] key combination (hold down Ctrl and press the right bracket key). If you are currently connected to an active session when you enter command mode, Telnet waits for you to issue a command, execute it, and then return to the session automatically. Command mode lets you enter commands relative to the client (the machine you are physically in front of) instead of the server. You might need to do this to change directories or run a local application, for example.<BR><P>Once the connection is successfully established, your session behaves as though you were on the remote machine, with all valid commands of that operating system. All instructions are relative to the server, so a directory command shows the current directory on the server, not the client. To see the client's directory, you would have to enter command mode. A sample Telnet login and logout session, calling from one UNIX workstation (merlin) to a server (tpci_hpws4, a name that can be resolved by the name server) follows:<BR><PRE><FONT COLOR=#000080>merlin&gt; telnet tpci_hpws4Trying...Connected to tpci_hpws4.Escape character is '^]'.HP-UX tpci_hpws4 A.09.01 A 9000/720 (ttys2)login: tparkerpassword: xxxxxxxxtpci_hpws4-1&gt; pwd/u1/tparkertpci_hpws4-2&gt; cd docstpci_hpws4-3&gt; pwd/u1/tparker/docstpci_hpws4-2&gt; &lt;Ctrl+d&gt;Connection closed by foreign host.merlin&gt;</FONT></PRE><P>Once you are connected to the remote machine, the session behaves exactly as if you were on that machine. To log out of the remote session, simply issue the logout command (in the previous example, the UNIX Ctrl+D combination), and you are returned to your local machine. The telnet program is useful when you are on an under-powered machine or terminal and you want to use another machine's processing capabilities, or if another machine has a particular tool that you don't want to load on your local machine.<BR><P>Telnet utilities are available for many different operating systems. Figure 6.3 shows a Windows for Workgroups Telnet application (part of a larger TCP/IP application suite from NetManage called ChameleonNFS, which I look at in much more detail on Day 10, &quot;Setting Up a Sample TCP/IP Network: DOS and Windows Clients&quot;) logging into an SCO UNIX server. Even when the local machine has a graphical interface such as Windows, you can most likely connect to remote machines using a character-based interface.<BR><P><B><A HREF=06tyt03.gif>Figure 6.3. Using Telnet from a Windows for </B><B>Workgroups machine.</A></B><BR><P>If the calling and receiving workstations use a graphical user interface (GUI) such as Motif or X, and you want to use them instead of a character-based interface, you must instruct both ends to use the local terminal for windowing (because you can't see a window on the remote terminal). Locally, a program is run that instructs the operating system to enable other machines to display directly onto the screen, and the remote must have an instruction to redirect windowing commands to the local screen. Many UNIX systems perform this function like this:<BR><PRE><FONT COLOR=#000080>tpci_server-1&gt; xhost +tpci_server-2&gt; telnet tpci_hpws4Trying...Connected to tpci_hpws4.Escape character is '^]'.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -