Tải bản đầy đủ - 0 (trang)
Chapter 25. Basic TCP/IP Services and Applications

Chapter 25. Basic TCP/IP Services and Applications

Tải bản đầy đủ - 0trang

generallyusedbyendusers,andtheprotocolsthatthese

utilitiesusetocommunicate.

Troubleshootingutilities,suchasPingandTraceroute,among

others,arecoveredinChapter27,"TroubleshootingToolsforTCP/IP

Networks."



Becauseyou'vealreadyreadabouthowprotocolswithinthe

TCP/IPprotocolsuitesgetdatafromonepointtoanother,it's

timetolookatsomeoftheprotocolsandapplicationsyoucan

useonanetwork.Inthischapteryouwillseeexamplesfrom

variousoperatingsystems,includingUnix,Linux,andWindows.

Forsomeofthemoreimportantapplications,suchasFTPand

telnet,we'lllookcloselyattheprotocolitselfandthemessages

thatareexchangedbetweenclientandserver.Thesearethe

actualprotocolcommandsthataparticularutilityusesto

communicatewithitscounterpart.Theselow-levelmessageor

commandexchangescanbeusefulwhenyouare

troubleshootingtheseapplicationsusingaprotocolanalyzer.

Thesamplesyntaxesforcommandsfoundinthischapterare

meanttoshowyouthatit'sagoodthinghelpfiles(orman

pages)wereinvented.Thedifferenceinacommandfromone

systemtoanothercanvarygreatly.



TheFileTransferProtocol(FTP)

FTPisusedtotransferfilesbetweencomputers.Itisacomplex

protocolthatenablestheexchangeofdatafilesusingdifferent

methodsofdatarepresentationandfilestorage.Initssimplest

form,FTPusesclear-textusernameandpasswordexchanges

andisnotconsideredtobeaverysecureutility.FTPwas

originallycreatedwhentheInternetwasstillcomposedmostly

oflargebusiness,government,andeducationalinstitutions,and

abreachofsecuritywasn'tconsideredthatbigofathreat.

WhenusedontheInternet,however,mosteverylegacyTCP/IP

utilityisbestusedinasecureenvironment.Thecommandsin

thischaptershowyouhowtouseFTP.Toensureasecure

exchangeofinformation,besuretoreadthechaptersinPart

VIII,"SystemandNetworkSecurity."

ThesyntaxforFTPvariesfromonevendor'simplementationto

another.However,thesimplestformat,usedtoinitiatea

connection,is

ftphostname



inwhichyousimplyfollowtheftpcommandwithahostnamefor

example,ftpftp.archive.org.Youalsocanusethedotted-decimal

addressinsteadoftheDNSnameofthesystemwithwhichyou

wanttoestablishaconnection.Alternatively,youcanenterftp

atthecommandpromptandthen,fromtheftp>prompt,enter

thecommandsneededtoaccomplishaparticulartask.



Tip

TheWebsiteftp.archive.orgisagreatplaceto

practiceusingftpcommands,andisalsoagreat

placetoobtainalotoffreefilesifyouareinterested



inhistoricalfilms.Atthissiteyoucansetyour

defaultdirectorytopub\moviesandwillfindseveral

thousand"ephemeral"filmsthathavebeenencoded

inseveraldifferentdigitalformats(takeyourpick).

Thesefilmsincludeeverythingfromhomemoviesto

corporatefilms,aswellasTVcommercialsandforus

oldfolksthoseflicksyouusedtoseeinhighschool

way-back-when,tellingyouhowtobehaveona

date!Thissiteisatreasuretroveoffilesthatyou

shouldinvestigateifyouhaveanyinterestin

twentieth-centurylife.



Alothaschangedinthepast20to30years.Moresecureforms

ofauthenticationanddataexchangehavebeenaddedtocreate

moresecureformsofFTP.BeforewelookatafewcommonFTP

clientsandtheirsyntaxes,let'slookatthebasicFTPprotocol

andgetafeelforhowitworks.



Note

TheFileTransferProtocolcanbefoundinalarge

numberofRFCdocumentsthatwerecreatedover

theyears.ThemainRFCthatmostdocumentspoint

youtoisRFC959,"FileTransferProtocol(FTP)."RFC

2151,"APrimeronInternetandTCP/IPToolsand

Utilities,"isalsoanicereadandcoversmanyofthe

utilitiesinthischapter.RFC2228,"FTPSecurity

Extensions,"dealswiththeinherentsecurity

problemsfoundintheFTPprotocol.ThislastRFC

discussesextensionsthatcanbeusedtoprovidefor

secureauthenticationandencryptionfortheFTP

protocol.Inaddition,thereareseveralproposed

RFCsthatareonthepathtowardbecominga



standard.RFC2640,"InternationalizationoftheFile

TransferProtocol,"andRFC2428,"FTPExtensions

forIPv6andNATs,"provideinsightintothefutureof

FTP.



FTPisbasedonaclient/serverarchitecture.AnFTPserver

(calledadaemononUnixorLinuxsystemsandaserviceon

Windowssystems)managesafilesystem(anythingfroma

singledirectorytoadiskfarm).FTPserversauthenticatethe

clientuserusingausernameandpassword,andthenworkwith

theclienttotransferfilesbetweentheclientandserver

computers.Thebasicprotocolisasimpleexchangeof

messages.TraditionalFTPusesasimplecommand-line

interface.Today,manysharewareandcommercialGUIversions

ofFTPareavailable.Forexample,ifyouarealreadyusinga

favoriteFTPsite,tryusingaURLsuchasftp://ftp.archive.orgto

seewhetheryourbrowsersupportsaGUIinterfaceforFTP.

Eitherway,commandlineorGUI,itisanextremelyuseful

utilitybecauseitallowsthetransferofmanytypesoffiles

betweentwohostsonthenetwork.



Note

FTPclientscomeinmanyforms.Asmentionedin

thetextofthischapter,youcanuseacommand-line

interfaceusingacomputerrunningUnix/Linuxor

anyWindowsoperatingsystem.Really,justabout

anysystemrunningtheTCP/IPprotocolstackis

likelytohaveFTPincludedasaservice.Most

browserssupporttheprefix"ftp"justastheydothe

"www"prefixwhenbrowsingInternetsites.Youcan

alsodownloadGUIFTPapplicationsthatoperate

outsidethecommandlineorbrowserinterface.Use



asearchengineandyouwillfindmanyofthese

applications.Mostdifferentiatethemselvesfrom

othersbyprovidingadditionalfeatures,suchasan

easy-to-useinterfaceorintegrationwithother

applications,suchasWindowsExplorer.



FTPPortsandProcesses

TheFTPserverdaemonlistensinthebackgroundforFTP

requestsonTCPport21.Intheliterature,theserveris

composedoftwocomponents,thoughtheyareoftencombined

intoasingleprogram.ThefirstistheServer-PI,whichstands

for"serverprotocolinterpreter."Thisisthecomponentthat

listenstoTCPport21andinteractswithitsclientcounterpart,

theUser-PI.TheuserprotocolinterpreterinitiatesanFTP

sessionbysendingarequesttotheserver.Theclient'srequest

canincludeaportthattheclientwantstheservertousewhen

itopensadatachannel.

ThesecondcomponentoftheserveristheServer-DTP,which

standsfor"serverdatatransferprocess."Thisisthecodethat

interactswithitscounterpart,theUser-DTP,toperformthe

actualfiledatatransfers.Anoverviewofthisprocessappearsin

Figure25.1.Theimportantthingtonoticeinthisfigureisthat

twochannelsofcommunicationareusedforFTPonefor

commandsandonefortheactualexchangeofdataandthat

bothofthesechannelsworkinbothdirections.



Figure25.1.TheFTPsessionconsistsofbotha

commandandadatachannel.



[Viewfullsizeimage]



Theclient'sUser-PIshouldbelisteningonthespecifiedportfor

incomingdatatransmissionsbeforeithasissuedthecommands

necessarytostartadatatransferfromaremoteserver.The

actualcommandsusedonthecontrolconnectionareinthe

sameformatusedforthetelnetutility(NVT-ASCII),whichis

discussedlaterinthischapter.



DataTransfers

AllFTPdatatransferstakeplaceusingbytes(8bits),

independentofthesizeoftheactualdatabeingtransferred.

Thatis,ifthelocalfilesystemusesadifferentsizeforstorage,

suchasawordorafloating-pointnumericalrepresentation,FTP

justsends8bitsatatime.Thedataisreconstructedonthe

receivingendintoitsoriginalformat.Theclientandserver

applicationsareresponsibleformakingsurethatconversions

aredoneontheirendtomakedatausableontheirrespective

systems.

Whenyou'reusinganFTPclient,itisimportantthatyouknow

whattypeoffileyouaresendingorreceiving.Thedefaultfor



mostclientsistosend/receiveASCIItextfiles.Ifyouwantto

sendorreceiveanexecutableprogram,mostclientsusethe

command"binary"toinformtheserveryouinteractwiththat

thisisnotanASCIItextfile.

Additionally,therearethreemodesthatareusedfortransfers:

StreammodeThisisasimpletransmissionofastreamof

bytes.Torepresentrecordandfilestructuresusingthis

mode,EndofRecord(EOR)andEndofFile(EOF)control

bytescanbeused.Controlbytesconsistof2bytes.The

firstbyteissettoallones(whichistheescapecharacter),

andthesecondbyteisthecontrolcharacter.Avalueof1

forthisbyteindicatesthatitistheEORcharacter.Avalue

of2indicatesthatitistheEOFcharacter.Avalueof3

indicatesbothcharacters(EORandEOF).Notethatifan

actualbyteofallonesisinthedatastream,itis

transmittedasa2-bytesequencealso,withbothbytes

beingsettoallones.

BlockmodeThistransmissionmodesendsaseriesofdata

blocks,eachofwhichhasaheader.Theheaderinformation

consistsof3bytesofinformation.The16lower-orderbits

indicatethebytecount,whichisthetotallengthofthe

block(expressedinbytes).Theremaininghigh-orderbyte

isusedforadescriptorcode.Adescriptorcodevalueof128

indicatesthattheendofadatablockistheendofarecord

(EOR).Avalueof64indicatesthattheendofadatablock

istheendofablockofdata(EOF).Avalueof32isusedto

indicatethatthereisreasontosuspecterrorsinthedata

stream.

CompressedmodeInthismode,datacanbesentusing

variouscompressionmechanisms.

Alltransfersaredonein8-bitbytes,regardlessofthewaythe



bitsareinterpretedonthereceivingsystem.Thedatatypes

thatFTPallowsareverybasic.TheASCIItypeconsistsof

standard8-bitNVT-ASCIIcharacters.Inthisformat,the

carriage-returnandline-feedcharactersareusedtoindicatethe

endofaline.Somesystems,suchasmanyUnixsystems,do

notusethiscombinationofcharacters,andthereceivingside

convertsthereceivedstreamofbytestoitsownformat.

TheEBCDICtype(ExtendedBinary-CodedDecimalInterchange

Code)isamethodofcharacterrepresentationusedmainlyon

IBMmainframecomputers,whichwerequitepopularbackwhen

developmentonFTP(anditspredecessors)firststarted.The

EBCDICandASCIItransfersaresentas8-bitcharactersand

aresimilar,withjustthecharacterrepresentationsofthe

numericalvaluesdiffering.

TheIMAGEmodeoftransfersendsdataasasimplestreamof

bits,whicharestoredintheusual8-bittransferbyteusedby

FTP.Atthereceivingend,thebitsarestoredinacontiguous

manner,withpaddingaddedtotheendofafileorrecordas

necessary.Themethodusedmustensurethattheprocessof

thispaddingcanbereversedifthefileistransferredtoanother

systemthatdoesnotusethatmethod.

TheLOCALtypeallowstheusertosetalogicalsizeforthe

bytestobesent.Alldataisstillsentasabyte,butonthe

receivingendthiscommandallowsthereceivertoknowhowto

reassemblethebitsintothecorrectlysizedbytesforthat

operatingsystem.



FTPProtocolCommands

Thissectionlooksatsomeofthemoreusefulcommandsthat

theprotocolusestocontrolanFTPsession.Thisisnotan

exhaustivediscussionofallpossibleprotocolcommands,

however.Thenextsectionlooksatexamplesofthesyntaxfor



FTPforseveralimplementationssothatyoucanseehow

variousFTPapplicationswork,andhowtheircommand

structurematchesupusercommandstothecommandsactually

usedbytheFTPprotocolprocesses.

Notethatthese"protocolcommands"arethecommands

exchangedbyclientandserverapplicationsonthenetwork.

Commandsenteredbyanenduserareadifferentmatter

altogether.Manyend-usercommandsinvolveasequenceof

protocolcommandstoaccomplishthedesiredfunction.Herewe

examinethecommandsexchangedbetweentheserverand

clientapplications,notthecommandenteredbyauser.

FTPprotocolcommandsstartwiththecommandcodeitselfand

areusuallyfollowedbyoneormorearguments.AllFTPprotocol

commandsarefourcharactersorfewerandcanbegrouped

intoafewcategories:

AccessControlCommands(ACT)Theseareusedto

authenticatetheuser,changedirectories,andsoon.

TransferParameterCommands(TPC)Thesecommands

controltheactualdatatransferprocess,suchastheport

usedandthefilestructure.

FTPServiceCommands(FSC)Thesecommandsindicate

thefunctiontheuserwantstoperform,suchassendingor

receivingafile,orperhapsrenamingordeletingafile.

Table25.1isalistofcommonlyusedcommandsalongwitha

descriptionoftheiruse.

Table25.1.FTPProtocolCommands

Command



Type



Description



USER



ACT



Thiscommandisfollowedbyausername



validontheremotesystem.

PASS



ACT



Thiscommandisfollowedbythe

passwordassociatedwiththeremoteuser

account.



ACCT



ACT



Someimplementationsrequireatext

stringidentifyingauseraccount,whichis

sentwiththiscommand.



CWD



ACT



Changeworkingdirectoryontheremote

system.



CDUP



ACT



Changetoparentdirectory.



SMNT



ACT



Usedtomountadifferentfilesystem.



REIN



ACT



Reinitialize.Thisflushesalluseraccount

andI/Odataandreinitializesthe

connection.Typically,anotherUSER

commandisthenusedtostartanew

session.



QUIT



ACT



Thisisthelogoutcommandtoenda

session.



PORT



TPC



Usedtospecifyahostdataportother

thanthedefault.



PASV



TPC



CommunicateinPassivemode.This

commandcausestheservertolistenona

specifiedportotherthanthedefault.



TYPE



TPC



Thedatarepresentationtype(thatis,

ASCII,IMAGE,andsoon).Anumerical

valueisusedforeachtype.



STRU



TPC



Filestructure.F=file(norecord

structure),R=recordstructure,P=page

structure.Thedefaultisfile.



MODE



TPC



Transfermode.S=stream,B=block,C=

compressed.



RETR



FSC



Retrieve.Instructstheservertosenda

file.



STOR



FSC



Store.Instructstheservertoreceiveand

storeafile.



STOU



FSC



SimilartoSTORbutcreatesaunique

filenameontheserver.



APPE



FSC



Appendwithcreate.Ifthefileexistson

theserver,dataisappended.Ifnot,afile

iscreated.



ALLO



FSC



Usedtoallocatespacebeforefiletransfer.



REST



FSC



Restart.Restartsthefiletransferata

specifiedcheckpoint.



RNFR



FSC



Renamefrom.Theoldpathnameofafile

thatisbeingrenamed.Followedbyan

RNTOcommand.



RNTO



FSC



Renameto.Specifiesthenewpathname

ofarenamedfile.



ABOR



FSC



Instructstheservertoaborttheprevious

commandand/ordatatransfer.



DELE



FSC



Deletesafileontheserver.



RMD



FSC



Removedirectory.Removesadirectory

ontheserver.



MKD



FSC



Makedirectory.Createsadirectoryonthe

server.



PWD



FSC



Displaysthenameofthecurrent

directory(printworkingdirectory).



LIST



FSC



Listsinformationaboutafileorlistsfiles

inadirectory.



NLIST



FSC



Namelist.Sendstheclientalistofjust



Tài liệu bạn tìm kiếm đã sẵn sàng tải về

Chapter 25. Basic TCP/IP Services and Applications

Tải bản đầy đủ ngay(0 tr)

×