780 likes | 866 Views
Szept 29.-ei előadás pótlása. Szept 22.-én a 207-es teremben 16-18-ig. 1. Gyakorlat Felkészülés a web programozásra. Kecskeméti Gábor A/1 336-os szoba – fizika tanszék Konzultációs idő : Csütörtök 9-11 Előadás : XX. Előadó , Csütörtök 14-16
E N D
Szept 29.-ei előadáspótlása • Szept 22.-én a 207-es teremben 16-18-ig.
1. GyakorlatFelkészülés a web programozásra KecskemétiGábor A/1 336-os szoba – fizikatanszék Konzultációsidő: Csütörtök 9-11 Előadás: XX. Előadó, Csütörtök 14-16 Gyakorlat: 207-es terem, Csütörtök 12-14
The Universal Resource Locator (URL) Each page of information on the web has a unique address called the URL at which it can be found • http://faculty.uscupstate.edu/atzacheva/lecture1.html The document can be obtained using the Hypertext Transfer Protocol (HTTP) Host Name - The Name of Web Server Path to the Web Page File Name Denotes that the File is Written in HTML HyperText Markup Language 1 2 3 File Name Protocol Host Name
Önállófeladat • Készítsünkegyprogramotamifeldolgozza a parancssoriparaméterkéntkapottURLtésdarabjairabontja • Az URL alábbirészeit minimum tudjafelolvasni a program: • 1. protokoll (séma) • 2. Domain név (hostazonosító) • 3. Port (nemprotokollnakmegfelelőportszám) • 4. Elérésiútvonal • 5. Ha Queryt is tartalmazaz URL akkor a paramétereknevei • 6. Ha Queryt is tartalmazaz URL akkor a paraméterekértékei • Ha valakielkészült a feladattalellenőrzésétésteszteléséténvégzem, jelezzemindenki ha mehetek
Példák • urlparser.exehttp://www.hwsw.hu • Protokoll (séma): http • Domain név (hostazonosító): www.hwsw.hu • urlparser.exe x://y:1/a?b=c&d=e • Protokoll (séma): x • Domain név (hostazonosító): y • Port (nemprotokollbólkövetkező): 1 • Elérésiútvonal: a?b=c&d=e • Query paraméterek: b,d • Query értékek: c,e
FTP protokoll KecskemétiGábor A/1 336-os szoba – fizikatanszék Konzultációsidő: Csütörtök 9-11 Előadás: XX. Előadó, Csütörtök 14-16 Gyakorlat: 207-es terem, Csütörtök 12-14
application: supporting network applications FTP, SMTP, HTTP transport: process-process data transfer TCP, UDP network: routing of datagrams from source to destination IP, routing protocols link: data transfer between neighboring network elements PPP, Ethernet physical: bits “on the wire” Internet protocol stack application transport network link physical
Ports • Each IP address is subdivided into ports, each port assigned to a single program • You can browse the Internet using one port while receiving e-mail using another port, with a single IP address
Protocols • Sets of rules or standards that let computers communicate over the Internet • Type or size or brand of computer doesn’t interfere with communication if the protocol is used
Objectives of FTP • Promote the sharing of files • To encourage indirect or implicit use of remote computers • To shield users from variations in file storage systems • To transfer data reliably and efficiently
History • First proposed file transfer mechanisms in 1971 in RFC 114 and RFC 141 • RFC 354 (1972) defined FTP between hosts on ARPANET • Several RFCs came shortly thereafter • RFC 686 (1975) entitled “Leaving Well Enough Alone” • RFC 959 defines additional commands: • CDUP, SMNT, STOU, RMD, MKD, PWD, SYST
Problems of File Transfer • At first, file transfer may seem simple • Heterogeneous systems use different: • Operating Systems • Character Sets • Naming Conventions • Directory Structures • File Structures and Formats • FTP need to address and resolve these problems
WHAT IS FTP? Terminology • FTP works on the client/server principle. A client program enables the user to interact with a server in order to access information and services on the server computer. • Files that can be transferred are stored on computers called FTP servers. To access these files, an FTP client program is used. This is an interface that allows the user to locate the file(s) to be transferred and initiate the transfer process.
FTP • FTP begins at port 21 • Initially, client and server communicate in plain text • Server will send ‘reply codes’ along with text • client doesn’t need to interpret text • Client will send upper-case commands
* Persistent command and reply connection Non-persistent data connection Server is listening on port 21 for connection requests * Insulates users from “raw” FTP commands *Server uses port 20 for data connections * Routes “raw” FTP commands * Receives server’s replies FTP’s Connections 2 client User Interface server User Protocol Interpreter Server Protocol Interpreter Control Connection 21 User Data Transfer Function Data Connection Server Data Transfer Function 20
2 FTP’s Connections – Establishment ftp> open strauss.udel.edu Connected to strauss.udel.edu 220 strauss FTP server ready. 530 Please login with USER and PASS client 331 Password req for haggerty. Password: User Interface 230 User haggerty logged in. ftp> USER haggerty PASS mypass server User Protocol Interpreter Server Protocol Interpreter Control Connection User Data Transfer Function Server Data Transfer Function Data Connection
How FTP Works Primary Command Thread Server
Enter the Client Primary Command Thread Primary Command Thread Socket (21) Client Server
Server Greeting 220 Welcome! Primary Command Thread Primary Command Thread Socket (21) Client Server
USER Identification USER chastine Primary Command Thread Primary Command Thread Socket (21) Client Server
User Verified 331 User OK… Primary Command Thread Primary Command Thread Socket (21) Client Server
PASSword Sent PASS jeffrox Primary Command Thread Primary Command Thread Socket (21) Client Server
User Now Verified 230 User logged in Primary Command Thread Primary Command Thread Socket (21) Client Server
What we have so far… • Client/server connected by a socket • The user identified
2 FTP’s Connections Data Transfer client ls client.txt -rw-r--r-- haggerty client.txt User Interface 226 Closing Data Connection PORT 192,168,100,173,19,137 LIST client.txt 200 Port Command Sucessful 150 Data Connection will be open shortly server User Protocol Interpreter User Protocol Interpreter Server Protocol Interpreter Server Protocol Interpreter Control Connection Passive open on Port 5001 User Data Transfer Function Server Data Transfer Function Data Connection Establish Data Connection
LISTing of Files Primary Command Thread Primary Command Thread Socket (21) Client Server
Set TYPE to ASCII TYPE A Primary Command Thread Primary Command Thread Socket (21) Client Server
Mode of transfer • There are two modes of transfer in FTP: asciiand binary. • ASCII is used only for files saved in ASCII format (this includes Postcript files) • Binary is used for files that are formatted and saved using a wordprocessing software like WordPerfect (.txt), spreadsheets (.xls), images (.jpg, .gif), and many executable programs (.exe) and videos (.avi).
Server Responds 200 Type set to A Primary Command Thread Primary Command Thread Socket (21) Client Server
Now the Tricky Part PASV Primary Command Thread Primary Command Thread Socket (21) Client Server • PASV • Requests server to prepare a new socket • Server listens for client on that new port
Server Sets up New Socket Returns IP and port number 227 Entering Passive Mode (168,28,245,183,28,45) Primary Command Thread Primary Command Thread Socket (21) Secondary Data Thread On port 2845 Client Server
Establish the Data Socket Primary Command Thread Primary Command Thread Socket (21) Secondary Data Thread On port 2845 Secondary Data Thread Client Socket (2845) Server
Request the LISTing LIST Primary Command Thread Primary Command Thread Socket (21) Secondary Data Thread On port 2845 Secondary Data Thread Client Socket (2845) Server
Secondary Thread Is Waiting 150 Opening ASCII mode data… Primary Command Thread Primary Command Thread Socket (21) Secondary Data Thread On port 2845 Secondary Data Thread Client Socket (2845) Server
Establish the Data Socket Primary Command Thread Primary Command Thread Socket (21) Secondary Data Thread On port 2845 Secondary Data Thread Client Socket (2845) Server <Data is transferred>
Secondary Socket Closes Primary Command Thread Primary Command Thread Socket (21) Secondary Data Thread On port 2845 Secondary Data Thread Client Socket (2845) Server
Transfer Complete 226 Transfer Complete Primary Command Thread Primary Command Thread Socket (21) Client Server
What We’ve Done Now • Sent a directory listing by: • Sending the request • Establishing a new socket on a new port • Sent/Read the data • Closed the connection • Return back to the original socket • How about for files?
Transfering Files(Client - Receiving) Primary Command Thread Primary Command Thread Socket (21) Client Server
Set TYPE to Image (binary) TYPE I Primary Command Thread Primary Command Thread Socket (21) Client Server
Server Responds 200 Type set to I Primary Command Thread Primary Command Thread Socket (21) Client Server
Tricky Part PASV Primary Command Thread Primary Command Thread Socket (21) Client Server
Server Sets up New Socket Returns IP and port number 227 Entering Passive Mode (168,28,245,183,28,46) Primary Command Thread Primary Command Thread Socket (21) Secondary Data Thread On port 2846 Client Server
Establish the Data Socket Primary Command Thread Primary Command Thread Socket (21) Secondary Data Thread On port 2846 Secondary Data Thread Client Socket (2846) Server
RETRieve the File RETR Bob.txt Primary Command Thread Primary Command Thread Socket (21) Secondary Data Thread On port 2846 Secondary Data Thread Client Socket (2846) Server
Secondary Thread Is Waiting 150 Opening BINARY mode data… Primary Command Thread Primary Command Thread Socket (21) Secondary Data Thread On port 2846 Secondary Data Thread Client Socket (2846) Server
Establish the Data Socket Primary Command Thread Primary Command Thread Socket (21) Secondary Data Thread On port 2846 Secondary Data Thread Client Socket (2846) Server <Data is transferred>