1. Basic Concepts a) Protocols are used for communication within a layer, between the entities of the layer. Each layer communicates with its upper and lower layers through interfaces. A protocol of a layer offers a service to the upper layer and the service is used through the interface. b) Socket interface is used for communication between the application and transportation layers (or TCP/IP stack) in the TCP/IP architecture. That is, the application layer uses transportation service through it. 2. HTTP in the Point of View of the OSI Model HTTP is not really implemented in OSI Model so it is natural that it is hard to divide all its functions on separate layers unambiguously. However, there are some functions that can be quite unambiguously divided on the layers of the OSI Model. Application Layer The functions that offer the application (WWW client or server) an interface through which the application can perform its specific data transfer form the application layer. In WWW the data transfer consists mainly client's requests for files and server's reponses. Especially HTTP methods (GET, HEAD, POST, ...) belong to the application layer. Presentation Layer On the presentation layer HTTP manages data formats. With Accpet headers the client informs what kind of data it will be able to handle. Content haders tell what kind of data has been sent. However, HTTP does not implement the presentation layer of OSI model in the sense that it does not adapt uncompatible machine-dependent data formats. Session Layer On the session layer HTTP manages connections. By default HTTP 1.1 uses persistent connections but their use can be prevented by the Connection header. Also cookies belong to the session layer. 3. Netcat and FTP a) A file can be transerred for example as follows: First, set Netcat A to listen a chosen port (1024 < port < TCP max, by command netstat -a | grep port you can check that the port is free) and redirect the output to a file: kekkonen /u/6/liia > nc -l -p 3333 > bar.txt Then, use Netcat B to send the data to the listening port: kekkonen /u/6/liia > cat foo.txt | nc localhost 3333 You could copy files between computers with corresponding procedure by sending the data with Netcat B to a separate host that has Netcat A listening to a port. b) FTP protocol has separate control and data connections. Server and client communicate through the control connection but the data transfer is done through the data connection. However, notice that both connections are bidirectional. FTP data transfer can be done in either active or passive mode. The control connection is established by the client. In active FTP the server establishes the data connection, that is the server is "active". In passive FTP the client establishes the data connection, that is the server is "passive". The firewall of HUT Computing Center complicated the use of active FTP, because it did not pass unknown incoming connections forward. The use of passive FTP goes as follows: Establishing the control connection to the FTP server: kekkonen /u/6/liia > telnet ftp.funet.fi 21 Trying 193.166.3.2... Connected to ftp.funet.fi. Escape character is '^]'. 220---------- Welcome to Pure-FTPd ---------- 220-You are user number 259 of 1000 allowed. 220-Local time is now 14:24. Server port: 21. 220-Only anonymous FTP is allowed here 220 You will be disconnected after 30 minutes of inactivity. ##user name user anonymous 331-Welcome to the FUNET anonymous ftp archive 331- 331-This archive is also available over the IPv6 network via ftp.ipv6.funet.fi 331-WWW-browser users can also try http://www.nic.funet.fi/pub/ 331- 331-See the README file for more information about this archive. 331- 331-All anonymous FTP transactions will be logged for possible later analysis 331-and statistics. If you don't like this policy, please disconnect now! 331- 331-THIS is a four processor SUN 450/4GB/1TB system 331-Please mail to problems@nic.funet.fi in case of problems 331- 331 Any password will work ##password pass any 230 Any password will work ##switching to the passive mode pasv 227 Entering Passive Mode (193,166,3,2,187,126) ##commanding the server to send the specified file through the data connection ##simultaneously, see establishing the data connection retr /rfc/rfc959.txt 150-Accepted data connection 150 143.9 kbytes to download 226-File successfully transferred 226 0.080 seconds (measured here), 1.76 Mbytes per second ##closing the FTP connection quit 221-Goodbye. You uploaded 0 and downloaded 288 kbytes. 221 Logout. Connection closed by foreign host. Establishing the data connection: Establish a data connection to the server and redirect its output to a file. The server informs you of the correct TCP port on line "227 Entering Passive Mode (193,166,3,2,187,126)", where the four first numbers tell the IP address and the two last the TCP port (256*187 + 126). nc 193.166.3.2 47998 > rfc959.txt