<<

Ports

 Some well-known ports: Lecture 10  80: http  21: ftp  23: telnet Servers  22: ssh February 4, 2005  79: finger  42: nameserver  13: daytime  7: echo  /etc/services

Telnet Protocol Telnet Protocol

 TELNET is a protocol that provides “a general, bi-  TCP connection directional, eight-bit byte oriented communications  Data and control over the same connection. facility”.  Network Virtual Terminal

 telnet is a program that supports the TELNET  Negotiated options protocol over TCP.

 Many application protocols are built upon the TELNET protocol.

Network Virtual Terminal Network Virtual Terminal

 Intermediate representation of a generic terminal.  Provides a standard language for Process communication of terminal control functions.  Uses 7 bit codes for characters, transmitted as 8 bits (MSB=0). EOF is CR (carriage NVT NVT return) followed by LF (line feed). CR is CR TCP TCP followed by NUL (all bits zero) character.

1 Negotiable Options Negotiated Options

 All NVTs support a minimal set of  The protocol for requesting optional features capabilities. is well defined and includes rules for  Some terminals have more capabilities than eliminating possible negotiation “loops”. the minimal set.  The set of options is not part of the TELNET  The 2 endpoints negotiate a set of mutually protocol, so that new terminal features can acceptable options (character set, echo be incorporated without changing the mode, etc). TELNET protocol.

Examples for Options EBDIC and ASCII

 ASCII: 7-bit character set, 8th bit can be  Line mode vs. character mode used for error checking or extended characters.  echo modes  EBCDIC: IBM, 8-bit, no parity checking possible, more control characters.  character set (EBCDIC vs. ASCII)

Some Control Characters Command Structure

 Erase Character (EC):  All TELNET commands and data flow  delete last character sent through the same TCP connection.  typically used to edit keyboard input  Commands start with a special character called the Interpret as Command character (IAC).  Erase Line (EL):  The IAC code is 255.  delete all input in current line  If a 255 is sent as data - it must be followed by another 255.

2 Looking for Commands Command Codes

 Each receiver must look at each byte that  IP 243 suspend, interrupt, abort process arrives and look for IAC.  AO 244 abort output  AYT 245 are you there  If IAC is found and the next byte is IAC - a  EC 246 erase character single byte is presented to the  EL 247 erase line application/terminal (a 255).  WILL 251 performing indicated option  If IAC is followed by any other code - the  WONT 252 refuse to perform option TELNET layer interprets this as a command.  DO 253 request indicated option  DONT 254 stop indicated option  IAC 255 interpret as command

Options Options

 Options are agreed on by a process of negotiation,  Sender wants the other end to echo: option will affect interchange and operation of and/or server. 255(IAC), 251(WILL), 1  Either end: IAC, ,

Options Playing with Telnet

 Example: client wishes to identify terminal  You can use the telnet program to play type to the server: with the TELNET protocol. client 255(IAC), 251(WILL), 24  telnet is a generic TCP client. server 255(IAC), 253(DO), 24  Sends whatever you type to the TCP socket. server 255(IAC), 250(SB), 24, 1, 255(IAC), 240(SE)  Prints whatever comes back through the TCP client 255(IAC), 250(SB), 24, 0, ‘V’, ‘T’, ‘2’, ‘2’, ‘0’, socket. 255(IAC), 240(SE)  Useful for testing TCP servers (ASCII based protocols).  1: value required, 0: value supplied

3 Some TCP Servers you can play with telnet hostname port

 Some systems have these servers > telnet cs.someschool.edu 7 running (by default): Trying 128.113.111.31... Connected to machine.cs.someschool.edu  echo port 7 (128.113.112.31).  discard port 9 Escape character is '^]'.  daytime port 13 Hi dave Hi dave  chargen port 19 stop it stop it ^] telnet> quit Connection closed.

Playing with Telnet Telnet vs TCP

 Try this:  Not all TCP servers talk TELNET (most don't) telnet telnet> toggle options Will show option processing. telnet> open machine.school.edu Trying 130.207.3.8...  You can use the telnet program to play with these Connected to machine.school.edu (129.128.127.31). servers, but the fancy commands won't do anything. Escape character is ‘^]’.  type ^], then "help" for a list of fancy TELNET stuff you can SENT DO ENCRYPT do in telnet. SENT WILL ENCRYPT SENT DO SUPPRESS GO AHEAD SENT WILL TERMINAL TYPE SENT WILL NAWS SENT WILL TSPEED ...

Client/Server Web Server Basics

 telnet protocol and program.  HTTP: HyperText Transfer Protocol  now: web server example (Apache). (communication between web server and ).

Request

Response Web Browser Web Server () (Apache)

4 Apache Overview Apache 2.0

Parent Parent

Child Child Child Child Child Child

threads (“ThreadPerChild”) for requests and one listener thread

Apache 2.0 Apache 2.0

 Apache tries to maintain pool of spare server  Typical configuration file: threads.  “StartServers”: initally started processes. ServerLimit 16  Dynamically forks/kills processes to keep number of idle threads between “MinSpareThreads” and StartServers 2 “MaxSpareThreads”. MaxClients 150  “MaxClients”: max. number of child processes is MinSpareThreads 25 MaxClients/ThreadsPerChild. MaxSpareThreads 75  “ServerLimit”: hard limit for child processes. ThreadsPerChild 25  “ThreadLimit”: hard limit for threads.

Apache 2.0 Apache 2.0

 Modules:  dynamic or static linkage Parent 100s of threads  in-process modules: run from inside the httpd process (mod_cgi, mod_perl, mod_php, Tomcat mod_python, mod_tcl)

 out-of-process modules (mod_proxy, mod_jrun) Child Child Child … (10s) … (10s) DB mod_jk mod_rewrite mod_php mod_perl

5 Apache 2.0 Apache 2.0

 Multi-Processing Module (MPM)  Client:  An MPM defines how the server will receive  single HTTP connection (eg. web browser). and manage incoming requests.  note that many web browsers open up multiple connections. Apache considers each connection  Allows OS-specific optimizations. uniquely.  Allows vastly different server models (eg. threaded vs. multiprocess).

Apache 2.0 Performance: sendfile()

 Keepalive requests:  fd-to-fd copying of data (stay in kernel).  No more double-copy.  Persistent connections  Zero-copy*.  multiple requests over one TCP socket  Dramatic improvement for static files.  Available on  directives:  2.4.x  KeepAlive  Solaris 8+  MaxKeepAliveRequests  FreeBSD/NetBSD/OpenBSD  KeepAliveTimeout  ...

* Zero-copy requires both OS support and NIC driver support.

Web Server Performance Server ‘Quality’

 ab  Response time:  flood  server side: time to handle a request  httperf  client side: request transmission + time to handle a request + reply transmission  JMeter  Throughput:  ...and many others  number of requests handled in a second

6 Response Times Throughput

ab flood

 Simple Load on a Single URL.  Profile-driven load tester.  Comes with Apache.  Useful for generating real-world scenarios.  Good for sanity check.  Built to be highly-scalable.  Scales poorly.  Designed to be extremely flexible.

JMeter

 Has a graphical interface.  Built on Java.  Part of Apache Jakarta (Java and Apache) project.  Depends heavily on JVM performance.

7