Presentation is loading. Please wait.

Presentation is loading. Please wait.

Szept 29.-ei előadás pótlása Szept 22.-én a 207-es teremben 16-18-ig.

Similar presentations


Presentation on theme: "Szept 29.-ei előadás pótlása Szept 22.-én a 207-es teremben 16-18-ig."— Presentation transcript:

1 Szept 29.-ei előadás pótlása Szept 22.-én a 207-es teremben 16-18-ig.

2 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 Gyakorlat: 207-es terem, Csütörtök 12-14

3 3 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 Denotes that the File is Written in HTML HyperText Markup Language File Name 123 ProtocolHost Name File Name

4 Önálló feladat Készítsünk egy programot ami feldolgozza a parancssori paraméterként kapott URLt és darabjaira bontja Az URL alábbi részeit minimum tudja felolvasni a program: – 1. protokoll (séma) – 2. Domain név (hostazonosító) – 3. Port (nem protokollnak megfelelő portszám) – 4. Elérési útvonal – 5. Ha Queryt is tartalmaz az URL akkor a paraméterek nevei – 6. Ha Queryt is tartalmaz az URL akkor a paraméterek értékei Ha valaki elkészült a feladattal ellenőrzését és tesztelését én végzem, jelezze mindenki ha mehetek

5 Példák urlparser.exe http://www.hwsw.huhttp://www.hwsw.hu – Protokoll (séma): http – Domain név (hostazonosító): www.hwsw.huwww.hwsw.hu urlparser.exe x://y:1/a?b=c&d=e – Protokoll (séma): x – Domain név (hostazonosító): y – Port (nem protokollból következő): 1 – Elérési útvonal: a?b=c&d=e – Query paraméterek: b,d – Query értékek: c,e

6 FTP protokoll 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 Gyakorlat: 207-es terem, Csütörtök 12-14

7 EMLÉKEZTETŐ

8 Internet protocol stack 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” application transport network link physical

9 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

10 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

11 BEVEZETÉS

12 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

13 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

14 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

15 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.

16 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

17 PROTOKOLL MŰKÖDÉS KÖZBEN

18 FTP ’ s Connections User Interface User Data Transfer Function User Protocol Interpreter Server Protocol Interpreter Server Data Transfer Function client server Control Connection Data Connection * Insulates users from “ raw ” FTP commands Server is listening on port 21 for connection requests 2 * Routes “ raw ” FTP commands * Receives server ’ s replies * Persistent command and reply connection Non-persistent data connection 21 20 *Server uses port 20 for data connections

19 FTP ’ s Connections – Establishment User Interface User Data Transfer Function User Protocol Interpreter Server Protocol Interpreter Server Data Transfer Function client server Control Connection Data Connection 2 ftp> open strauss.udel.edu Connected to strauss.udel.edu 220 strauss FTP server ready. 530 Please login with USER and PASS USER haggerty 331 Password req for haggerty. Password: PASS mypass 230 User haggerty logged in. ftp>

20 How FTP Works Server Primary Command Thread

21 Enter the Client Server Client Socket (21) Primary Command Thread Primary Command Thread

22 Server Greeting Server Client Socket (21) Primary Command Thread Primary Command Thread 220 Welcome!

23 USER Identification Server Client Socket (21) Primary Command Thread Primary Command Thread USER chastine

24 User Verified Server Client Socket (21) Primary Command Thread Primary Command Thread 331 User OK…

25 PASSword Sent Server Client Socket (21) Primary Command Thread Primary Command Thread PASS jeffrox

26 User Now Verified Server Client Socket (21) Primary Command Thread Primary Command Thread 230 User logged in

27 What we have so far… Client/server connected by a socket The user identified

28 User Data Transfer Function Server Data Transfer Function User Interface User Protocol Interpreter Server Protocol Interpreter client server Control Connection Data Connection 2 ls client.txt Passive open on Port 5001 PORT 192,168,100,173,19,137200 Port Command SucessfulLIST client.txt 150 Data Connection will be open shortly 226 Closing Data Connection -rw-r--r-- haggerty client.txt Establish Data Connection User Protocol Interpreter Server Protocol Interpreter FTP ’ s Connections Data Transfer

29 LISTing of Files Server Client Socket (21) Primary Command Thread Primary Command Thread

30 Set TYPE to ASCII Server Client Socket (21) Primary Command Thread Primary Command Thread TYPE A

31 Mode of transfer There are two modes of transfer in FTP: ascii and 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).

32 Server Responds Server Client Socket (21) Primary Command Thread Primary Command Thread 200 Type set to A

33 Now the Tricky Part Server Client Socket (21) Primary Command Thread Primary Command Thread PASV Requests server to prepare a new socket Server listens for client on that new port

34 Server Sets up New Socket Server Client Socket (21) Primary Command Thread Primary Command Thread Secondary Data Thread On port 2845 227 Entering Passive Mode (168,28,245,183,28,45) Returns IP and port number

35 Establish the Data Socket Server Client Socket (21) Primary Command Thread Primary Command Thread Secondary Data Thread Socket (2845) Secondary Data Thread On port 2845

36 Request the LISTing Server Client Socket (21) Primary Command Thread Primary Command Thread Secondary Data Thread On port 2845 LIST Secondary Data Thread Socket (2845)

37 Secondary Thread Is Waiting Server Client Socket (21) Primary Command Thread Primary Command Thread Secondary Data Thread On port 2845 150 Opening ASCII mode data… Secondary Data Thread Socket (2845)

38 Establish the Data Socket Server Client Socket (21) Primary Command Thread Primary Command Thread Secondary Data Thread Socket (2845) Secondary Data Thread On port 2845

39 Secondary Socket Closes Server Client Socket (21) Primary Command Thread Primary Command Thread Secondary Data Thread Socket (2845) Secondary Data Thread On port 2845

40 Transfer Complete Server Client Socket (21) Primary Command Thread Primary Command Thread 226 Transfer Complete

41 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?

42 Transfering Files (Client - Receiving) Server Client Socket (21) Primary Command Thread Primary Command Thread

43 Set TYPE to Image (binary) Server Client Socket (21) Primary Command Thread Primary Command Thread TYPE I

44 Server Responds Server Client Socket (21) Primary Command Thread Primary Command Thread 200 Type set to I

45 Tricky Part Server Client Socket (21) Primary Command Thread Primary Command Thread PASV

46 Server Sets up New Socket Server Client Socket (21) Primary Command Thread Primary Command Thread Secondary Data Thread On port 2846 227 Entering Passive Mode (168,28,245,183,28,46) Returns IP and port number

47 Establish the Data Socket Server Client Socket (21) Primary Command Thread Primary Command Thread Secondary Data Thread Socket (2846) Secondary Data Thread On port 2846

48 RETRieve the File Server Client Socket (21) Primary Command Thread Primary Command Thread Secondary Data Thread On port 2846 RETR Bob.txt Secondary Data Thread Socket (2846)

49 Secondary Thread Is Waiting Server Client Socket (21) Primary Command Thread Primary Command Thread Secondary Data Thread On port 2846 150 Opening BINARY mode data… Secondary Data Thread Socket (2846)

50 Establish the Data Socket Server Client Socket (21) Primary Command Thread Primary Command Thread Secondary Data Thread Socket (2846) Secondary Data Thread On port 2846

51 Secondary Socket Closes Server Client Socket (21) Primary Command Thread Primary Command Thread Secondary Data Thread Socket (2846) Secondary Data Thread On port 2846

52 Transfer Complete Server Client Socket (21) Primary Command Thread Primary Command Thread 226 Transfer Complete

53 Transfering Files (Client - Sending) Server Client Socket (21) Primary Command Thread Primary Command Thread

54 Set TYPE to Image (binary) Server Client Socket (21) Primary Command Thread Primary Command Thread TYPE I

55 Server Responds Server Client Socket (21) Primary Command Thread Primary Command Thread 200 Type set to I

56 Tricky Part Server Client Socket (21) Primary Command Thread Primary Command Thread PASV

57 Server Sets up New Socket Server Client Socket (21) Primary Command Thread Primary Command Thread Secondary Data Thread On port 2847 227 Entering Passive Mode (168,28,245,183,28,47) Returns IP and port number

58 Establish the Data Socket Server Client Socket (21) Primary Command Thread Primary Command Thread Secondary Data Thread Socket (2847) Secondary Data Thread On port 2847

59 RETRieve the File Server Client Socket (21) Primary Command Thread Primary Command Thread Secondary Data Thread On port 2847 STOR Bob.txt Secondary Data Thread Socket (2847)

60 Secondary Thread Is Waiting Server Client Socket (21) Primary Command Thread Primary Command Thread Secondary Data Thread On port 2847 150 Opening BINARY mode data… Secondary Data Thread Socket (2847)

61 Establish the Data Socket Server Client Socket (21) Primary Command Thread Primary Command Thread Secondary Data Thread Socket (2847) Secondary Data Thread On port 2847

62 Secondary Socket Closes Server Client Socket (21) Primary Command Thread Primary Command Thread Secondary Data Thread Socket (2847) Secondary Data Thread On port 2847

63 Transfer Complete Server Client Socket (21) Primary Command Thread Primary Command Thread 226 Transfer Complete

64 User Interface User Protocol Interpreter Server Protocol Interpreter client server Control Connection Data Connection 2 User Data Transfer Function Server Data Transfer Function bye QUIT 221 Service Closing FTP ’ s Connections – Connection Closing

65 PROTOKOLL ÖSSZEGZÉS

66 Other Commands (no additional socket needed) PWD – print (or present) working directory CDUP – Change Dir UP CWD - Change Working Directory RMD - Remove Directory MKD - Make Directory REIN – reinitialize QUIT – logout MODE – Stream*, Block, Compressed *Default

67 Example FTP Responses 120 Service will be ready shortly 200 Command OK 230 User login OK 331 User name OK; password is needed 421 Service not available 530 User not logged in 552 Requested action aborted; exceeded storage allocation

68 Summary of FTP connections FTP has 2 connections -Control (persistent connection) -Server issues a passive open on well-known 21 -Client uses an ephemeral port to issue active open -Server ultimately closes control connection -Data (ephemeral connection) -Client issues passive open on an ephemeral port -Client sends this port to server via PORT command -Server receives the port number and issues active open using its well-known 20 to the received ephemeral port

69 Data Connection continued This does not always work…why? Instead, use PASV command – Client sends PASV command to server – Server chooses ephemeral port: passive open – Server responds with IP, Port in reply (227) – Client issues active open to server ’ s port Ultimately, the data sender closes connection

70 PARANCSSORI/GYAKORLATI HASZNÁLAT

71 Command line FTP Open connection Set transfer mode Transfer single / multiple file(s) Execute command in remote server Execute command in local machine Close FTP connection

72 Basic FTP Client Commands (issued by user interface) FTP - initiate ftp session open - connect to an ftp server binary - specify files to up/download; are more than flat text get - download a file from the server put - upload a file to the server close - close connection to the server bye/quit/exit - end the ftp session user - re-enter login name pwd - display present working directory on server lpwd - display the local present working directory (on connecting machine) cd - change directory dir or ls - directory listing of files/directories on Server lcd - change directory on Local Machine lcd~ - home shortcut *mget *.* - multiple file downloads *mput *.* - multiple file uploads cdup - to move backwards to the previous directory rhelp or remotehelp – list commands the server accepts * Sent to server as multiple command by User Protocol Interpreter

73 73 $ftp ftp > open zenit.senecac.on.ca $ftp zenit.senecac.on.ca Open the FTP connection OR: source: Ling Zhu

74 74 ftp > asc ftp > bin Set the transfer mode source: Ling Zhu Set to ASCII mode: Set to binary mode:

75 75 Commands to transfer files ftp > get ftp > put source: Ling Zhu ftp > mget *.html ftp > mput lecture?? Transfer a single file: Transfer multiple files–Use file name expansion

76 76 Execute commands on the remote server ftp > cd dirctoryName ftp > pwd ftp > ls source: Ling Zhu

77 77 Execute commands on the local machine ftp > lcd dirctoryName ftp > !cd ftp > !dir source: Ling Zhu ftp > !cd dirctoryName ftp > !pwd ftp > !ls Windows machineUNIX/Linux machine

78 78 ftp > close ftp > bye Close FTP connection OR: source: Ling Zhu


Download ppt "Szept 29.-ei előadás pótlása Szept 22.-én a 207-es teremben 16-18-ig."

Similar presentations


Ads by Google