Скачать презентацию TCP IP Part II Based on Notes by D Скачать презентацию TCP IP Part II Based on Notes by D

3238cf202bc563c673ac0302e47d567a.ppt

  • Количество слайдов: 88

TCP/IP Part II Based on Notes by D. Hollinger Based on UNIX Network Programming, TCP/IP Part II Based on Notes by D. Hollinger Based on UNIX Network Programming, Stevens, Chapters 7, 11, 22, 27 Also Java Network Programming and Distributed Computing, Chapter 6 Also Online Java Tutorial, Sun. Netprog 2002 - Client/Server Issues 1

Topics l Issues in Client/Server Programming l Advanced TCP/IP Options l Sample Application-layer Protocols Topics l Issues in Client/Server Programming l Advanced TCP/IP Options l Sample Application-layer Protocols – TELNET – FTP Netprog 2002 - Client/Server Issues 2

Issues in Client Programming Identifying the Server. l Looking up an IP address. l Issues in Client Programming Identifying the Server. l Looking up an IP address. l Looking up a well known port name. l Specifying a local IP address. l UDP client design. l TCP client design. l Netprog 2002 - Client/Server Issues 3

Identifying the Server l Options: – hard-coded into the client program. – require that Identifying the Server l Options: – hard-coded into the client program. – require that the user identify the server. – read from a configuration file. – use a separate protocol/network service to lookup the identity of the server. Netprog 2002 - Client/Server Issues 4

Identifying a TCP/IP server. l Need an IP address, protocol and port. – We Identifying a TCP/IP server. l Need an IP address, protocol and port. – We often use host names instead of IP addresses. – usually the protocol (UDP vs. TCP) is not specified by the user. – often the port is not specified by the user. Can you name one common exception ? Netprog 2002 - Client/Server Issues 5

Services and Ports l Many services are available via “well known” addresses (names). l Services and Ports l Many services are available via “well known” addresses (names). l There is a mapping of service names to port numbers. Netprog 2002 - Client/Server Issues 6

Specifying a Local Address When a client creates and binds a socket it must Specifying a Local Address When a client creates and binds a socket it must specify a local port and IP address. l Typically a client doesn’t care what port it is on: l my. Socket = new Datagram. Socket() give me any available port ! Netprog 2002 - Client/Server Issues 7

Local IP address l A client can also ask the operating system to take Local IP address l A client can also ask the operating system to take care of specifying the local IP address: my. Address = Inet. Address. get. Local. Host(); Give me the appropriate address Netprog 2002 - Client/Server Issues 8

UDP Client Design Establish server address (IP and port). l Allocate a socket. l UDP Client Design Establish server address (IP and port). l Allocate a socket. l Specify that any valid local port and IP address can be used. l Communicate with server (send, receive) l Close the socket. l Netprog 2002 - Client/Server Issues 9

Connected mode UDP A UDP client can call connect(address, port) to establish the address Connected mode UDP A UDP client can call connect(address, port) to establish the address of the server. l “connect” is a misnomer: l – A UDP client using a connected mode socket can only talk to that server (using the connected-mode socket). Netprog 2002 - Client/Server Issues 10

TCP Client Design Establish server address (IP and port). l Allocate a socket. l TCP Client Design Establish server address (IP and port). l Allocate a socket. l Specify that any valid local port and IP address can be used. Transparent to Java programmers l Call connect() l Communicate with server (through given streams). l Close the connection. l Netprog 2002 - Client/Server Issues 11

Closing a TCP socket Many TCP based application protocols support multiple requests and/or variable Closing a TCP socket Many TCP based application protocols support multiple requests and/or variable length requests over a single TCP connection. l How does the server known when the client is done (and it is OK to close the socket) ? l Netprog 2002 - Client/Server Issues 12

Partial Close l One solution is for the client to shut down only it’s Partial Close l One solution is for the client to shut down only it’s writing end of the socket. l The shutdown. Output() socket call provides this function. my. Socket. shutdown. Output(); – shutdown. Output() flushes output stream and sends TCP-connection termination sequence. – shutdown. Input() closes input stream and discards any further information (further read()s will get -1) Netprog 2002 - Client/Server Issues 13

TCP sockets programming l Common problem areas: Not a problem with Java Strings. – TCP sockets programming l Common problem areas: Not a problem with Java Strings. – null termination of strings. – reads don’t correspond to writes. – synchronization (including close()). – ambiguous protocol. Netprog 2002 - Client/Server Issues 14

TCP Reads Each call to read() on a TCP socket returns any available data TCP Reads Each call to read() on a TCP socket returns any available data (up to a maximum). l TCP buffers data at both ends of the connection. l You must be prepared to accept data 1 byte at a time from a TCP socket. l Netprog 2002 - Client/Server Issues 15

Server Design Iterative Connectionless Iterative Connection-Oriented Concurrent Connectionless Concurrent Connection-Oriented Netprog 2002 - Client/Server Server Design Iterative Connectionless Iterative Connection-Oriented Concurrent Connectionless Concurrent Connection-Oriented Netprog 2002 - Client/Server Issues 16

Concurrent vs. Iterative Concurrent Large or variable size requests Harder to program Typically uses Concurrent vs. Iterative Concurrent Large or variable size requests Harder to program Typically uses more system resources Iterative Small, fixed size requests Easy to program Netprog 2002 - Client/Server Issues 17

Connectionless vs. Connection-Oriented EASY TO PROGRAM transport protocol handles the tough stuff. requires separate Connectionless vs. Connection-Oriented EASY TO PROGRAM transport protocol handles the tough stuff. requires separate socket for each connection. Connectionless overhead no limitation on number of clients Netprog 2002 - Client/Server Issues 18

Statelessness State: Information that a server maintains about the status of ongoing client interactions. Statelessness State: Information that a server maintains about the status of ongoing client interactions. l Connectionless servers that keep state information must be designed carefully! l Messages can be duplicated! Netprog 2002 - Client/Server Issues 19

The Dangers of Statefullness Clients can go down at any time. l Client hosts The Dangers of Statefullness Clients can go down at any time. l Client hosts can reboot many times. l The network can lose messages. l The network can duplicate messages. l Netprog 2002 - Client/Server Issues 20

Concurrent Server Design Alternatives One process per client Spawn one thread per client Preforking Concurrent Server Design Alternatives One process per client Spawn one thread per client Preforking multiple processes Prethreaded Server Netprog 2002 - Client/Server Issues 21

One child process per client l Traditional Unix server: – TCP: after call to One child process per client l Traditional Unix server: – TCP: after call to accept(), call get. Runtime(). exec(), returns Process. – UDP: after receive(), call exec(). – Each process needs only a few sockets. – Small requests can be serviced in a small amount of time. l Parent process needs to clean up after children!!!! (invoke wait. For() ). Netprog 2002 - Client/Server Issues 22

One thread per client Use new Thread(). start(); l Using threads makes it easier One thread per client Use new Thread(). start(); l Using threads makes it easier (less overhead) to have sibling processes share information. l Sharing information must be done carefully (use synchronized) Watch out for deadlocks! l Netprog 2002 - Client/Server Issues 23

Pre-forked Server l Creating a new process for each client is expensive. l We Pre-forked Server l Creating a new process for each client is expensive. l We can create a bunch of processes, each of which can take care of a client. l Each child process is an iterative server. Netprog 2002 - Client/Server Issues 24

Pre-forked TCP Server Initial process creates socket and binds to well known address. l Pre-forked TCP Server Initial process creates socket and binds to well known address. l Process now calls exec() a bunch of times. l All children call accept(). l The next incoming connection will be handed to one child. l Netprog 2002 - Client/Server Issues 25

Sockets library vs. system call l A pre-forked TCP server won’t usually work the Sockets library vs. system call l A pre-forked TCP server won’t usually work the way we want if sockets is not part of the kernel: – calling accept() is a library call, not an atomic operation. l We can get around this by making sure only one child calls accept() at a time using some locking scheme. Netprog 2002 - Client/Server Issues 26

Pre-forking Having too many pre-forked children can be bad. l Using dynamic process allocation Pre-forking Having too many pre-forked children can be bad. l Using dynamic process allocation instead of a hard-coded number of children can avoid problems. l The parent process just manages the children, doesn’t worry about clients. l Netprog 2002 - Client/Server Issues 27

Pre-threaded Server l Same benefits as pre-forking. l Can have the main thread do Pre-threaded Server l Same benefits as pre-forking. l Can have the main thread do all the calls to accept() and hand off each client to an existing thread. Netprog 2002 - Client/Server Issues 28

What’s the best server design for my application? l Many factors: – Expected number What’s the best server design for my application? l Many factors: – Expected number of simultaneous clients. – Transaction size (time to compute or lookup the answer) – Variability in transaction size. – Available system resources (perhaps what resources can be required in order to run the service). Netprog 2002 - Client/Server Issues 29

Server Design It is important to understand the issues and options. l Knowledge of Server Design It is important to understand the issues and options. l Knowledge of queuing theory can be a big help. l You might need to test a few alternatives to determine the best design. l Netprog 2002 - Client/Server Issues 30

TCP Socket Options l It's important to know about some of these topics, although TCP Socket Options l It's important to know about some of these topics, although it might not be apparent how and when to use them. l Details are in the book(s) - we are just trying to get some idea of what can be done. Netprog 2002 - Client/Server Issues 31

Socket Options l Various attributes that are used to determine the behavior of sockets. Socket Options l Various attributes that are used to determine the behavior of sockets. l Setting options tells the OS/Protocol Stack the behavior we want. l Support for generic options (apply to all sockets) and protocol specific options. Netprog 2002 - Client/Server Issues 32

Option types l Many socket options are boolean flags indicating whether some feature is Option types l Many socket options are boolean flags indicating whether some feature is enabled (true) or disabled (false). l Other options are associated with different data types, e. g. int, representing time. Netprog 2002 - Client/Server Issues 33

Read-Only Socket Options l Some options are readable only (we can’t set the value). Read-Only Socket Options l Some options are readable only (we can’t set the value). Netprog 2002 - Client/Server Issues 34

Setting and Getting option values get{Option}() gets the current value of a socket option, Setting and Getting option values get{Option}() gets the current value of a socket option, e. g. get. Receive. Buffer. Size(); set{Option}() is used to set the value of a socket option, e. g. set. Receive. Buffer. Size(size); Netprog 2002 - Client/Server Issues 35

Some Generic Options SO_BROADCAST SO_DONTROUTE SO_ERROR SO_KEEPALIVE SO_LINGER SO_RCVBUF, SO_SNDBUF SO_REUSEADDR Netprog 2002 - Some Generic Options SO_BROADCAST SO_DONTROUTE SO_ERROR SO_KEEPALIVE SO_LINGER SO_RCVBUF, SO_SNDBUF SO_REUSEADDR Netprog 2002 - Client/Server Issues 36

SO_BROADCAST Boolean option: enables/disables sending of broadcast messages. l Underlying DL layer must support SO_BROADCAST Boolean option: enables/disables sending of broadcast messages. l Underlying DL layer must support broadcasting! l Applies only to Datagram (UDP) sockets. l Prevents applications from inadvertently sending broadcasts (OS looks for this flag when broadcast address is specified). l Netprog 2002 - Client/Server Issues 37

SO_DONTROUTE l Boolean option: enables bypassing of normal routing. l Used by routing daemons. SO_DONTROUTE l Boolean option: enables bypassing of normal routing. l Used by routing daemons. Netprog 2002 - Client/Server Issues 38

SO_ERROR l Integer value option. l The value is an error indicator value (similar SO_ERROR l Integer value option. l The value is an error indicator value (similar to errno). l Readable (get’able) only! l In Java, a Socket. Exception, or IOException is thrown. Netprog 2002 - Client/Server Issues 39

SO_KEEPALIVE Boolean option: enabled means that STREAM sockets should send a probe to peer SO_KEEPALIVE Boolean option: enabled means that STREAM sockets should send a probe to peer if no data flow for a “long time”. l Used by TCP - allows a process to determine whether peer process/host has crashed. l Consider what would happen to an open telnet connection without keepalive. l Netprog 2002 - Client/Server Issues 40

SO_LINGER Used to control whether and how long a call to close will wait SO_LINGER Used to control whether and how long a call to close will wait for pending ACKS. l connection-oriented sockets only. l set. So. Linger(boolean on. Flag, int duration); l get. So. Linger(); returns duration (-1 if option is disabled) l Netprog 2002 - Client/Server Issues 41

SO_LINGER usage By default, calling close() on a TCP socket will return immediately. l SO_LINGER usage By default, calling close() on a TCP socket will return immediately. l The closing process has no way of knowing whether or not the peer received all data. l Setting SO_LINGER means the closing process can determine that the peer machine has received the data (but not that the data has been read() !). l Netprog 2002 - Client/Server Issues 42

shutdown() vs SO_LINGER l You can use shutdown{In|Out}put() to find out when the peer shutdown() vs SO_LINGER l You can use shutdown{In|Out}put() to find out when the peer process has read all the sent data. Netprog 2002 - Client/Server Issues 43

SO_RCVBUF SO_SNDBUF l l l Integer values options - change the receive and send SO_RCVBUF SO_SNDBUF l l l Integer values options - change the receive and send buffer sizes. Can be used with TCP and UDP sockets. With TCP, this option effects the window size used for flow control - must be established before connection is made. – {g|s}et{Send|Receive}Buffer. Size(…); Netprog 2002 - Client/Server Issues 44

SO_REUSEADDR l Boolean option: enables binding to an address (port) that is already in SO_REUSEADDR l Boolean option: enables binding to an address (port) that is already in use. l Used by servers that are transient allows binding a passive socket to a port currently in use (with active sockets) by other processes. Netprog 2002 - Client/Server Issues 45

SO_REUSEADDR l Can be used to establish separate servers for the same service on SO_REUSEADDR l Can be used to establish separate servers for the same service on different interfaces (or different IP addresses on the same interface). l Virtual Web Servers can work this way. Netprog 2002 - Client/Server Issues 46

SO_TIMEOUT Can be used to tell the socket to use non-blocking read. l get. SO_TIMEOUT Can be used to tell the socket to use non-blocking read. l get. So. Timeout() returns the current setting (by default 0, or disabled, representing a blocking read). l E. g. to tell socket to interrupt reading if 5 seconds pass by, use: l my. Socket. set. So. Timeout(5000); Netprog 2002 - Client/Server Issues 47

IP Options (IPv 4) l IP_TOS: allows us to set the “Type-ofservice” field in IP Options (IPv 4) l IP_TOS: allows us to set the “Type-ofservice” field in an IP header. – set. Traffic. Class(int); Netprog 2002 - Client/Server Issues 48

another TCP socket option l l l TCP_NODELAY: can disable TCP’s Nagle algorithm that another TCP socket option l l l TCP_NODELAY: can disable TCP’s Nagle algorithm that delays sending small packets if there is un. ACK’d data pending. TCP_NODELAY also disables delayed ACKS (TCP ACKs are cumulative). Java Sockets: – get. Tcp. No. Delay(); – set. Tcp. No. Delay(flag); Netprog 2002 - Client/Server Issues 49

Out-of-Band Date l Ever been on a date, gone to a dance club and Out-of-Band Date l Ever been on a date, gone to a dance club and the band doesn't show up? – This is becoming a serious problem: u The number of Internet dating services is growing exponentially. u The number of bands is not growing. – RFC 90210 proposes some short term solutions (until the number of bands can be increased). Netprog 2002 - Client/Server Issues 50

Out-of-Band Data TCP (and other transport layers) provide a mechanism for delivery of Out-of-Band Data TCP (and other transport layers) provide a mechanism for delivery of "high priority" data ahead of "normal data". l We can almost think of this as 2 streams: l normal data TCP PORT A TCP PORT B special data Netprog 2002 - Client/Server Issues 51

TCP OOB Data l TCP supports something like OOB data using URGENT MODE (a TCP OOB Data l TCP supports something like OOB data using URGENT MODE (a bit is set in a TCP segment header). l A TCP segment header field contains an indication of the location of the urgent data in the stream (the byte number). Netprog 2002 - Client/Server Issues 52

Sending OOB Data send. Urgent. Data(int data); Puts a single byte of urgent data Sending OOB Data send. Urgent. Data(int data); Puts a single byte of urgent data in a TCP stream (lowest 8 bits). The TCP layer adds some segment header info to let the other end know there is some OOB data. Netprog 2002 - Client/Server Issues 53

Receiving OOB Data l Receiver needs to set OOBInline flag: – set. OOBInline(true); Urgent Receiving OOB Data l Receiver needs to set OOBInline flag: – set. OOBInline(true); Urgent data is inlined with normal data. l Very limited support in Java. l – No special notification of urgent data, and no distinction between normal and urgent data, unless provided by higher-level protocol. Netprog 2002 - Client/Server Issues 54

Socket Options Summary l This was just an overview – there are many details Socket Options Summary l This was just an overview – there are many details associated with the options described. – There are many options that haven’t been described. – UNIX Network Programming is one of the best sources of information about socket Not ALL options. are (fully) supported by Java. Netprog 2002 - Client/Server Issues 55

The TELNET Protocol Reference: RFC 854 Netprog 2002 - Client/Server Issues 56 The TELNET Protocol Reference: RFC 854 Netprog 2002 - Client/Server Issues 56

TELNET vs. telnet l TELNET is a protocol that provides “a general, bi-directional, eight-bit TELNET vs. telnet l TELNET is a protocol that provides “a general, bi-directional, eight-bit byte oriented communications facility”. l telnet is a program that supports the TELNET protocol over TCP. l Many application protocols are built upon the TELNET protocol. Netprog 2002 - Client/Server Issues 57

The TELNET Protocol TCP connection l data and control over the same connection. l The TELNET Protocol TCP connection l data and control over the same connection. l Network Virtual Terminal l negotiated options l Netprog 2002 - Client/Server Issues 58

Network Virtual Terminal intermediate representation of a generic terminal. l provides a standard language Network Virtual Terminal intermediate representation of a generic terminal. l provides a standard language for communication of terminal control functions. l Netprog 2002 - Client/Server Issues 59

Network Virtual Terminal Server Process NVT TCP Netprog 2002 - Client/Server Issues 60 Network Virtual Terminal Server Process NVT TCP Netprog 2002 - Client/Server Issues 60

Negotiated Options All NVTs support a minimal set of capabilities. l Some terminals have Negotiated Options All NVTs support a minimal set of capabilities. l Some terminals have more capabilities than the minimal set. l The 2 endpoints negotiate a set of mutually acceptable options (character set, echo mode, etc). l Netprog 2002 - Client/Server Issues 61

Negotiated Options The protocol for requesting optional features is well defined and includes rules Negotiated Options The protocol for requesting optional features is well defined and includes rules for eliminating possible negotiation “loops”. l The set of options is not part of the TELNET protocol, so that new terminal features can be incorporated without changing the TELNET protocol. l Netprog 2002 - Client/Server Issues 62

Option examples l Line mode vs. character mode l echo modes l character set Option examples l Line mode vs. character mode l echo modes l character set (EBCDIC vs. ASCII) Netprog 2002 - Client/Server Issues 63

Control Functions l TELNET includes support for a series of control functions commonly supported Control Functions l TELNET includes support for a series of control functions commonly supported by servers. l This provides a uniform mechanism for communication of (the supported) control functions. Netprog 2002 - Client/Server Issues 64

Control Functions l Interrupt Process (IP) – suspend/abort process. l Abort Output (AO) – Control Functions l Interrupt Process (IP) – suspend/abort process. l Abort Output (AO) – process can complete, but send no more output to user’s terminal. l Are You There (AYT) – check to see if system is still running. Netprog 2002 - Client/Server Issues 65

More Control Functions l Erase Character (EC) – delete last character sent – typically More Control Functions l Erase Character (EC) – delete last character sent – typically used to edit keyboard input. l Erase Line (EL) – delete all input in current line. Netprog 2002 - Client/Server Issues 66

Command Structure All TELNET commands and data flow through the same TCP connection. l Command Structure All TELNET commands and data flow through the same TCP connection. l Commands start with a special character called the Interpret as Command escape character (IAC). l The IAC code is 255. l If a 255 is sent as data - it must be followed by another 255. l Netprog 2002 - Client/Server Issues 67

Looking for Commands Each receiver must look at each byte that arrives and look Looking for Commands Each receiver must look at each byte that arrives and look for IAC. l If IAC is found and the next byte is IAC a single byte is presented to the application/terminal (a 255). l If IAC is followed by any other code the TELNET layer interprets this as a command. l Netprog 2002 - Client/Server Issues 68

Command Codes IP l AO l AYT l EC l EL l 243 244 Command Codes IP l AO l AYT l EC l EL l 243 244 245 246 247 WILL n WON’T n DON’T n IAC n Netprog 2002 - Client/Server Issues 251 252 253 254 255 69

Playing with TELNET You can use the telnet program to play with the TELNET Playing with TELNET You can use the telnet program to play with the TELNET protocol. l telnet is a generic TCP client. l – Sends whatever you type to the TCP socket. – Prints whatever comes back through the TCP socket. – Useful for testing TCP servers (ASCII based protocols). Netprog 2002 - Client/Server Issues 70

Some TCP Servers you can play with l Many Unix systems have these servers Some TCP Servers you can play with l Many Unix systems have these servers running (by default): – echo – discard – daytime – chargen port 7 port 9 port 13 port 19 Netprog 2002 - Client/Server Issues 71

telnet hostname port > telnet rcs. rpi. edu 7 Trying 128. 113. 33. . telnet hostname port > telnet rcs. rpi. edu 7 Trying 128. 113. 33. . . Connected to cortez. sss. rpi. edu (128. 113. 33). Escape character is '^]'. Hi dave stop it ^] telnet> quit Connection closed. Netprog 2002 - Client/Server Issues 72

telnet vs. TCP l Not all TCP servers talk TELNET (most don't) l You telnet vs. TCP l Not all TCP servers talk TELNET (most don't) l You can use the telnet program to play with these servers, but the fancy commands won't do anything. – type ^], then "help" for a list of fancy TELNET stuff you can do in telnet. Netprog 2002 - Client/Server Issues 73

FTP File Transfer Protocol Reference: RFC 959 Netprog 2002 - Client/Server Issues 74 FTP File Transfer Protocol Reference: RFC 959 Netprog 2002 - Client/Server Issues 74

FTP Objectives (from RFC 959) • promote sharing of files • encourage indirect use FTP Objectives (from RFC 959) • promote sharing of files • encourage indirect use of remote • • • computers shield user from variations in file storage transfer data reliably and efficiently “FTP, although usable directly by a user at a terminal, is designed mainly for use by programs” Netprog 2002 - Client/Server Issues 75

The FTP Model PI: Protocol Interpreter DTP: Data Transfer Protocol Server PI File System The FTP Model PI: Protocol Interpreter DTP: Data Transfer Protocol Server PI File System Server DTP Control Data User Interface User PI User DTP Netprog 2002 - Client/Server Issues File System 76

Control and Data Connections • Control functions (commands) and reply • • codes are Control and Data Connections • Control functions (commands) and reply • • codes are transferred over the control connection. All data transfer takes place over the data connection. The control connection must be “up” while data transfer takes place. Netprog 2002 - Client/Server Issues 77

Control Connection • The control connection is the “well known” service. • The control Control Connection • The control connection is the “well known” service. • The control connection uses the TELNET protocol. • Commands and replies are all line oriented text (default is ASCII). Netprog 2002 - Client/Server Issues 78

Standard Connection Model Control A Data Netprog 2002 - Client/Server Issues B 79 Standard Connection Model Control A Data Netprog 2002 - Client/Server Issues B 79

Alternative Connection Model Control B A Control Data Netprog 2002 - Client/Server Issues C Alternative Connection Model Control B A Control Data Netprog 2002 - Client/Server Issues C 80

Access Control Commands USER PASS CWD CDUP QUIT specify user specify password change directory Access Control Commands USER PASS CWD CDUP QUIT specify user specify password change directory to parent logout Netprog 2002 - Client/Server Issues 81

Transfer Parameter Commands PORT PASV TYPE MODE STRU publish local data port server should Transfer Parameter Commands PORT PASV TYPE MODE STRU publish local data port server should listen establish data representation establish transfer mode establish file structure Netprog 2002 - Client/Server Issues 82

Service Commands RETR STOU APPE ABOR PWD LIST retrieve file send file and save Service Commands RETR STOU APPE ABOR PWD LIST retrieve file send file and save as unique send file and append abort prev. service command print working directory transfer list of files over data link Netprog 2002 - Client/Server Issues 83

FTP Replies • All replies are sent over control connection. • Replies are a FTP Replies • All replies are sent over control connection. • Replies are a single line containing – 3 digit status code (sent as 3 numeric chars). – text message. • The FTP spec. includes support for multiline text replies. Netprog 2002 - Client/Server Issues 84

FTP Reply Status Code First digit of status code indicates type of reply: ‘ FTP Reply Status Code First digit of status code indicates type of reply: ‘ 1’: Positive Preliminary Reply (got it, but wait). ‘ 2’: Positive Completion Reply (success). ‘ 3’: Positive Intermediate Reply (waiting for more information). ‘ 4’: Transient Negative Completion (error - try again). ‘ 5’: Permanent Negative Reply (error - can’t do). Netprog 2002 - Client/Server Issues 85

FTP Reply Status Code • 2 nd digit indicates function groupings. ‘ 0’: Syntax FTP Reply Status Code • 2 nd digit indicates function groupings. ‘ 0’: Syntax (problem with command syntax). ‘ 1’: Information (reply to help or status cmds). ‘ 2’: Connections (problem with a connection). ‘ 3’: Authentication (problem with login). ‘ 4’: Unspecified. ‘ 5’: File system (related to file system). • 3 rd digit indicates specific problem within function group. Netprog 2002 - Client/Server Issues 86

Data Transfer Modes • STREAM: file is transmitted as a stream of bytes. • Data Transfer Modes • STREAM: file is transmitted as a stream of bytes. • BLOCK: file is transmitted as a series of blocks preceded by headers containing count and descriptor code (EOF, EOR, restart marker). • COMPRESSED: uses a simple compression scheme - compressed blocks are transmitted. Netprog 2002 - Client/Server Issues 87

RFC 959 • The RFC includes lots more information and many details including: – RFC 959 • The RFC includes lots more information and many details including: – parameters for commands – lists of reply status codes – protocol state diagrams – support for a variety of file structures – sample sessions Netprog 2002 - Client/Server Issues 88