select.htaccess
.htaccess 时间:2021-01-11 阅读:(
)
Goodnews,everyone!
Version:2015-07-05M.
Brutman(mbbrutman@gmail.
com)http://www.
brutman.
com/mTCP/TableofContentsIntroductionandSetupIntroduction.
7WhatismTCP7Features.
7Testedmachines/environments.
8Licensing.
9Packaging.
9Supportandcontactinformation.
10Setup.
11Introduction.
11Hardwaresetup.
11CreatingthemTCPconfigurationfile.
14Networkingrelatedconfigurationparameters.
15Otherconfigurationparameters.
17Advancedtopics.
18mTCPandVirtualEnvironments.
22DOSBox.
22VirtualBox.
22VMWarePlayer.
23SwsVpkt.
23mTCPApplicationsDHCPclient.
26Introduction.
26Specialhardwareorsoftwarerequirements:26Setupinstructions.
26UsingDHCP.
27DHCPleaseduration.
27DHCPfailures.
28Configurationparameters.
28Recentchanges.
29DNSTest.
30Introduction.
30Specialhardwareorsoftwarerequirements:30Setupinstructions.
30UsingDNSTest.
30Recentchanges.
31FTPclient.
32Introduction.
32Specialhardwareorsoftwarerequirements:32UsingFTP.
32Transfermodes.
33DOSfilenamelimitations.
34FilenamesandQuoting.
34Commandlineediting.
35Scriptingsupport.
35AdvancedConfigurationParameters.
35Recentchanges.
36FTPserver.
37Disclaimer.
37Introduction.
37Specialhardwareorsoftwarerequirements:37Beforeyoufireitup37QuickStartInstructions.
37FTPserverbackgroundinformation.
38Configurationparameters.
39Choosingthenumberofclients.
41Settingupthepasswordfile.
41SettingupAnonymousFTP.
43DOSfilesystemlimitations.
44UsingmTCPFTPserverwithafirewall.
45Starting,runningandendingtheFTPserver.
46NotesonspecificFTPclients.
48Recentchanges.
49ImplementedRAWFTPcommands.
50HTGet.
51Introduction.
51Specialhardwareorsoftwarerequirements:51UsingHTGet.
51Whentheserversendscontent52Returncodes.
53DifferenceswiththeoriginalWATTCPHTGet.
54Recentchanges.
54HTTPServ.
55Introduction.
55Specialhardwareorsoftwarerequirements:55UsingHTTPServ.
55Servingstaticcontent.
57Servingprecompressedstaticcontent.
58Protectingfilesanddirectories.
59Specialserverfunctions.
60ServingtothepublicInternet.
62Miscellaneoustips.
64HTTPServConfigurationoptions.
65HTACCESSFiles.
69Samplefilesforexposingthespecialfunctions.
73IRCjr.
76Introduction.
76Specialhardwareorsoftwarerequirements:76Setup.
76StartingIRCjr.
77UsingIRCjr.
78OptionalConfigurationParameters.
82Recentchanges.
86Netcat.
88Introduction.
88Specialhardwareorsoftwarerequirements:88UsingNetcat.
88NetcatOptions.
88Usage:89Netcatoptions(details)90KeyboardHandling.
92Environmentvariables.
93Examples(andQuickstart!
93Networkprinting.
94Limitations.
95Recentchanges.
95Ping.
96Introduction.
96Specialhardwareorsoftwarerequirements:96UsingPing.
96Funnotes.
97Recentchanges.
97PktTool.
98Introduction.
98Specialhardwareorsoftwarerequirements:98UsingPktTool.
98Scanningforpacketdrivers.
98Displayingpacketdriverstatistics.
99Listeningforpacketsonthenetwork:99Recentchanges.
102SNTP(SimpleNetworkTimeProtocol)103Introduction.
103Specialhardwareorsoftwarerequirements:103UsingSNTP.
103Examples:104Miscellaneousnotes.
104Recentchanges.
104Spdtest.
105Introduction.
105Specialhardwareorsoftwarerequirements:105UsingSpdtest.
105Telnet.
107Introduction.
107Specialhardwareorsoftwarerequirements:107UsingTelnet.
107Telnetprotocolfeaturesandlimitations.
109UploadingandDownloadingfiles.
109ShellingtoDOS.
112ANSIEmulationNotes.
112Specialnote:TelnetBBSesandMUDs.
113[Enter]keyhandling.
113Advancedsetup.
114Recentchanges.
115AdvancedTopicsDebuggingproblems.
117Introduction.
117Hardwareandpacketdriverproblems.
117CollectingmTCPtraces.
119PPPSetup.
122Introduction.
122Prerequisites.
122Networksetupfortheexamplesprovidedhere.
122EstablishthePPPconnectiontotheLinuxmachine.
123ConfiguringmTCPforPPP.
124RoutingbeyondtheLinuxmachine.
125Advancedoptions.
126SLIPsetup.
127Introduction.
127Prerequisites.
127Networksetupfortheexamplesprovidedhere.
127EstablishtheSLIPconnectiontotheLinuxmachine.
128ConfiguringmTCP.
129RoutingbeyondtheLinuxmachine.
130Advancedoptions.
131DOSIdle/PowercontrolforlaptopsandVirtualMachines.
132Introduction.
132HowmTCPminimizesCPUusage.
132Notesonspecificpowersavingprograms.
132Disablingpowercontrol.
133IntroductionandSetupIntroductionIntroductionWhatismTCPmTCPisasetofTCP/IPapplicationsforpersonalcomputersrunningDOS.
Theapplicationsaredesignedtorunwellonolder16bitx86compatiblecomputers.
Applicationsinclude:aDHCPclientforauto-configuringyourmachineforuseonyournetworkanFTPclientfortransferringfilesacrossyournetwork(orfurther!
)athighspeedahighperformanceFTPserverthatsupportsmultipleconnectedclients,anonymousFTPandmoreHTGetforfetchingfilesorwebpagesfromwebserversHTTPServforservingfilesonthewebusingHTTP0.
9,1.
0or1.
1IRCjr,anInternetRelayClientforchattingonIRCnetworkstheNetcatutilityforsendingandreceivingdataeasilyacrossthenetworkthePingcommandwhichisusedforcheckingbasicnetworkconnectivitythePktToolutilityforworkingwithpacketdriversandsniffingpacketsonthenetworkSNTP,aSimpleNetworkTimeProtocolclientforsynchingyourclockwithInternetserversSpdTestforfiguringouthowfastyoursystem/networkcardisaTelnetclientforconnectingtoUnixsystems,BBSsystems,andanythingelsethatsupportsTelnetTheTCP/IPcodeiscompiledintoeachapplicationallowingforeachapplicationtochoosethefeaturesthattheyneed.
Thisapproachallowsforbetterperformanceandper-applicationcustomizationnotpossiblewithotherapproaches,suchasaDOSTSR.
TheTCP/IPcodetakesa"framework"approachtoapplications,allowingyoutoquicklygettotheimportantpartsofyourapplicationwithoutgettingboggeddowninthedetailsofinitialization,errorhandling,etc.
FeaturesSomeofthedesigngoalsofmTCPare:Configurationflexibility:Alotoffeaturesareenabledordisabledatcompiletimeusing#definessothattheTCP/IPcodecanbetailoredtoeachapplication.
Highperformance:Evenontheslowestmachinedatingbackto1981onecangetrawTCPsocketperformancewellinexcessof70KB/sec.
(ThisisdependentupontheEthernetcardbeingused.
)Smallspacerequirements:Thelibraryiscompactwithoutcuttingkeyfeatures.
Buffersizesareconfigurable.
Mostoftheapplicationsruncomfortablyona256KBmachineandmanywillrunwithlessmemory.
Extensivetracing:Nobodylikesabugandacomprehensivetracingmechanismhelpsfindandsquashbugsafterthecodeleavesmyhands.
Robustness:Thelibraryandapplicationsareprettyrigorouslytested.
Someoftheapplicationshavebeenleftrunningforweeksatatimewithnounexplainedmemoryleaksorcrashes.
ThecorrectnessoftheTCP/IPandotherprotocolsarecheckedagainstavarietyoftargetmachines.
Usability:DHCPconfigurationmakesiteasytouseonamodernnetwork.
Commandlineoptionsandtheconfigurationfilearenotmadeneedlesslycomplicated.
IntroductionSomeofthemoreadvancedfeaturesofthemTCPTCP/IPlibraryare:Automaticdetectionandretransmitoflostpacketsusingmeasuredroundtriptimes.
Supportformultipleopensockets.
Supportforlisteningsocketstowriteserverapplications.
DNSresolving(usingUDPpacketsonlyatthemoment).
TCPzerowindowsupport.
IPfragmentreassemblyandautomaticsendingofUDPfragments.
Andsomeofthecurrentlimitations:MinimalsupportforIPandTCPheaderoptionsOnlyonegatewaymaybeconfiguredOnlyonenameservermaybeconfiguredIngeneral,Iimplementedasetoffeaturesthatmakessenseforasmallmachine.
Thereisenoughimplementedtoallowthemachinetointeroperatewellwithavarietyofothermachinesandnotviolatespecifications.
Testedmachines/environmentsmTCPisnotparticularyfussyaboutwhatitrunson.
AslongasyouhavesomevariantofDOSandamachine(physicaloremulated)toruniton,mTCPshouldwork.
Generalrequirements:AnIBMPCcompatiblewithan8088orbetterCPU.
Virtualmachinesandemulatorsareincluded.
128KBto384KBofRAMavailabledependingontheprogram.
DOS2.
1ornewer.
(DOS3.
3ornewerisrecommended.
)Anetworkcardordevicethathasa"class1"(Ethernet)packetdriver.
Herearesomeofthemachines,networkcards,andenvironmentsthatIhavetestedmTCPwith:Machines:IBMPCjr(4.
77Mhz8088classmachine)IBMPCandIBMPCXT(4.
77Mhz8088classmachine)CompaqPortable(4.
77Mhz8088classmachine)IBMPS/2Model25(10Mhz8086classmachine)IBMAT(8Mhz80286classmachine)IBMPS/2L40SX(25Mhz80386classmachine)Generic80386-40cloneCompaqDeskpro433i(66Mhz80486DX-2classmachine)GenericPentium133cloneAptivaE3N(300MhzAMDK6-2classmachine)CPUs:8088,8086,V20,80286,80386,80486,Pentium,etc.
.
.
IntroductionVideocards:Monochrome,CGA,EGAandVGAEthernetcards:Theonlyrequirementisagoodpacketdriver.
CardsthatIhavepersonallytestedare:XircomPE3-10BT(parallelportEthernetadapter)3Com3C503(ISA)NovellNE1000(ISA)NovellNE2000(ISA)WesternDigital/SMC80x3series(ISA)LinkSysLNE100(PCI)IntelEtherExpress8/16OperatingSystems:IBMPC-DOSandMS-DOSversion2.
1shouldworkwell.
Version3.
3andabovearerecommended.
FreeDOS1.
0and1.
1Virtualenvironments:DOSBoxusingtheH-A-L9000"megabuild"(http://home.
arcor.
de/h-a-l-9000/)WindowsNT4,2000,andXPDOScommandwindowsusingSwsVpktVMWareVirtualBoxLicensingEarlyversionsofmTCPweredistributedinbinaryonlyform.
ThismadesenseasIwasdoingalotofdevelopmentandthingswerechurningquickly.
OnMay27th2011Iopen-sourcedthecodeandmadeitavailableunderthetermsoftheGNUGeneralPublicLicenseversion3.
Allversionsfrom2011-05-27through2013-05-23areopensourcewithreadilyavailablesourcecode.
Pleaseseethe"copying.
txt"fileinthosedistributionsforthefulltextofthelicensethatcoversthoseversions.
Startingwiththisrelease(2015-07-05)IamgoingbacktodistributingmTCPasbinaryfilesonly.
Thisisapersonaldecisionbasedonmyneedsandmyexperiences.
Imaychangemymindandreleasesourcecodeagaininthefuture,butatthemomentmTCPdoesnotincludesourcecode.
(Sourcecodeforthe2013-05-23versionwillremainavailableindefinitely.
)PackagingmTCPisdistributedasasetofbinariesandthisdocumentation.
Thebinariesanddocumentationareinseparatefilesbecauseitisassumedthatyouwillwanttoreadthedocumentiononamoremodernmachine.
IntroductionBinariesTherearetwoflavorsofthebinariesavailabletochoosefrom:Standardbinaries:ThesearenormalDOSEXEfilesthatconsumeabout980KBondisk.
UPXcompressedbinaries:Thesearethestandardbinariescompressedusing"UltimatePackerforeXecutables"(http://upx.
sourceforge.
net/).
UPXcompressedbinariestakelessspaceondisk(590KB)andtakejustalittlelongertogetrunning.
Theseareidealforsystemswherespaceistight.
Oncerunningbothsetsofbinariesareequivalent;therearenoperformanceorfeaturedifferencesbetweenthem.
DocumentationThisPDFfileisthedocumentationformTCP.
TheremaybeadditionalinformationavailableatthemTCPhomepage,buteverythingthatyouneedtogetstartedshouldbehere.
ThedocumentationusedtobeprovidedinTXTfiles,oneforeachprogramandseveralothersforsetupandmiscellaneoustopics.
AtthetimeIdecidedtoconsolidatethedocumentationinthisPDFfiletherewere20TXTfilesconsuming328KBofspace.
Thatbecameunwieldy.
MovingtoPDFhasenabledmetoimprovetheformattingandusabilityofthedocumentation.
Iconsiderthedocumentationasimportantasthecode.
Ifyoufindaproblemwiththedocumentationorhaveasuggestiontomakeitbetterpleaseletmeknow.
SupportandcontactinformationLinkstothelatestmTCPcodeanddocumentationcanbefoundatthehomepageathttp://www.
brutman.
com/mTCP/.
Ifyouhavequestions,comments,featurerequestsorbugreportsIcanbereachedatmbbrutman@gmail.
com.
IfyouarehavingaproblemgettingthemTCPapplicationsrunningpleasetrytogivemeagoodideaofyourmachinesetup,yournetworkconfiguration,andthesymptomsyouareexperiencing.
IfIdon'tknowtheansweroffthetopofmyheadwecanusethetracefacilityandtrytofigureitout.
(SeethechapteronDebuggingforhowtodosomebasicdebuggingandgeneratingtraces.
)IfyouarelookingforenhancementstomTCPtosupportacommercialusepleasesendmeanemailwithwhatyouarelookingfor.
Ihaveneveracceptedanymoney,beerorcookiesformywork,howeverIamproudtohaveaddednewfeaturesinexchangeforadonationtoananimalshelter.
(Yougettochoosetheshelter!
).
SetupSetupIntroductionmTCPisbothaTCP/IPstackandasetofapplicationsthatusethatTCP/IPstack.
BeforeyoucanusethemTCPapplicationssomesetupisneeded.
Youneedto:MakesureyourEthernetcardisreadytouse.
TellmTCPwheretofindasetupfile.
Placesomenetworkingvaluesinthesetupfile.
Addsomemoreconfigurationvaluestothesetupfiledependingonwhatprogramsyouwanttouse.
MostofthisworkisrequiredtobedonejustoncewhenyoufirstsetmTCPup.
Afterthat,usingmTCPisquickandeasy.
HardwaresetupAllnetworkingdependsonhavingaconnectionfromonecomputertoanother.
Therearemanywaystomakethatconnection–serialports,parallelports,Ethernet,TokenRing,etc.
Itwouldbetoocomplexforanyprogramtotrytoknowhowtouseeverypossibleconnectiontypesosomesimplifyingassumptionsareusuallymade.
PacketdriversmTCPisdesignedtoworkwithEthernetcards.
ButinsteadofhavingcodetotalkdirectlytoeverypossibleEthernetcardmTCPhascodetoworkwith"packetdrivers.
"ApacketdriverisadevicedriverthatprovidesasimplifiedprogramminginterfaceforEthernetcards.
Ethernetcardsareoftenverydifferentfromeachother;apacketdriverisusedtohidethosedifferences.
Withpacketdriversnetworkingprogramsbecomesimplertowritebecauseinsteadoftryingtoknowthedetailsofeverycard,programsjustneedtoknowhowtotalktopacketdrivers.
Thefullpacketdriverspecificationcanbefoundathttp://www.
crynwr.
com/packet_driver.
html.
Inparticular,mTCPisdesignedtoworkwith"class1"packetdrivers.
ThissetofpacketdriversincludesmostEthernetcards.
Anypacketdriverthatlookslikeaclass1packetdriverwillworkwithmTCP.
Thisincludes"shims"thatconvertothertypesofEthernetdevicedrivers(ODIorNDIS)toclass1packetdriversandpacketdriversthatmakeotherhardware(serialports)looklikeEthernetcards.
(Eventhedefinitionof"card"islooselyused;thereareEthernetdevicesthatconnectusingtheprinterparallelportthatcanbemadetolooklikeEthernetcardsthroughtheuseofapacketdriver.
)Packetdriversthatdonotprovideaclass1interfacesuchassuchasclass3(TokenRing)orclass8(ArcNet)arenotcompatiblewithmTCP.
Forageneraldiscussiononpacketdriversseehttp://www.
brutman.
com/Dos_Networking/.
SetupLoadingthepacketdriverPacketdriversareusuallyloadedfromtheDOScommandlineasterminateandstayresidentutilities.
EachpacketdriverisspecifictoamodelofEthernetcardsoeveryonewillbeslightlydifferent.
Howevermosthavesomecommonoptionsthatarerequired.
SoftwareinterruptSinceapacketdriverdefinesahighlevelprogramminginterfaceforworkingwithanEthernetcard,eachpacketdrivercanbetoldwheretoputtheentrypointtothatinterfacesothathigherlevelprogramslikemTCPapplicationscanfindit.
Thetechnicaltermforthatentrypointis"softwareinterrupt".
Whenyouloadapacketdriveryoutellitwhichsoftwareinterrupttoinstallitsservicesat.
Softwareinterruptsaregenerallywrittenashexadecimalnumbersandarelimitedinrangebetween0x60and0x7F.
YouneedtopickonethatisnotinusealreadybutsincemostDOSsoftwaredoesnotthesesoftwareinterrupts0x60isusuallyavailable.
ThenextsetofparametersisoftenrequiredtotellthepacketdriverwheretheEthernetcardislocatedinyoursystemI/OportEachEthernetcardneedsanI/Oportaddressthatcanbeusedtosendthecarddataandcommands.
TheI/Oportisusuallysetbyajumperonthecardorasoftwareconfigurationutility.
ItisextremelyimportanttospecifythecorrectI/Oportaddress;iftheaddressisincorrectthepacketdriverwillnotbeabletocontroltheEthernetcard.
HardwareinterruptAhardwareinterruptisasignalfromyourEthernetcardtothecomputerthatletsthecomputerknowwhentheEthernetcardhasnewdatathatneedstobereceived.
WhenanewpacketarrivestheEthernetcardwillsendthesignalusingthehardwareinterrupt,wakinguptheloadedpacketdriver.
ThepacketdriverwillthendotheworktomovethedatafromtheEthernetcardtothemainmemoryofthecomputer,andpossiblysignalanyhigherlevelsoftware(mTCP)thatnewdataisavailable.
ThehardwareinterruptnumberthattheEthernetcardusesisusuallysetbyajumperonthecardorasoftwareconfigurationutility.
Thehardwareinterruptnumberisoftenrequiredonthepacketdrivercommandlinesothatthepacketdriverknowswhichhardwareinterruptitshouldbelisteningto.
Ifyoudonotusethehardwareinterruptnumberthatthecardissettouseitwilllooklikeyoucannotreceiveanydata,astheEthernetcardwillbesignalingthatnewworkisavailableononehardwareinterruptwhilethepacketdriverwillbelisteningonadifferentinterruptnumber.
MemorywindowaddressSomeEthernetcardsusesharedmemorytomakethetransferofdatabetweentheEthernetcardandthecomputerfaster.
Thissharedmemoryisusually8KBto16KBinsizeandcardsthatuseitareusuallymuchfasterthatcardsthatuseonlyanI/Oportaddress.
IfyourEthernetcardusessharedmemorythereshouldbehardwarejumpersorasoftwareconfigurationutilitytosetthesharedmemoryaddress.
ItisalsopossiblethatthesharedmemoryaddressusedbytheSetuphardwareissetbythepacketdriverwhenthepacketdriverloads.
Pleasecheckthepacketdriverforyourcardtoseewhichsystemitusesforsharedmemory,ifapplicable.
NoteforISAbussystems:Itisextremelyimportantthatanyhardwareresourcesthatyouusearenotsharedwithanotherpieceofhardwareandthattheyarecorrect.
ThisisageneralISAbusrule.
Usingthewronghardwareinterruptnumber,I/Oportaddressorsharedmemoryregionwillresultinflakysystembehaviororcrashes.
SamplepacketdrivercommandlinesHerearesomesamplepacketdrivercommandlineswithanexplanationoftheirparameters.
ne20000x6030x300ne2000isthepacketdriverfor"NE2000"andcompatiblenetworkcards.
(NE2000isa16bitISAcardthatisthesuccessortotheNE1000card,whichwasapopular8bitISAcard.
)Onthiscommandlinewearetellingthene2000packetdrivertoinstallitsservicesatsoftwareinterrupt0x60,tolistentohardwareinterrupt3,andtocommunicatewiththeNE2000cardatI/Oport0x300.
smc_wd0x610x030x2800xD000smc_wdisapacketdriverfortheSMC/WesternDigital8003seriesEthernetcards.
Thesmc_wdpacketdriverisbeingtoldtoinstallitsservicesatsoftwareinterrupt0x61,tolistentohardwareinterrupt3,andtocommunicatewiththeWesternDigitalcardatI/Oport0x280.
ThelastparametertellsthepacketdrivertosetthecarduptousethememoryatD000:0000asasharedmemoryareafordatabuffersbetweenthecardandthecomputer.
pe3pdSINT=60LPT=2INT=5NONpe3pdisthepacketdriverfortheXircomPE3seriesofEthernetadapters.
TheXircomPE3isinterestinginthatitisanEthernetdevicebutitattachestoyourcomputerusingthestandardprinterparallelport.
Onthiscommandlinewearetellingthepe3pdpacketdrivertoinstallitsservicesatsoftwareinterrupt0x62,tofindtheXircomdeviceonthesecondparallelport,tolistentohardwareinterrupt5(whichshouldbeassociatedwiththatparallelport),andtonotattempttousetheparallelportasabi-directionalparallelport.
Notethedifferentwayinwhichthesoftwareinterruptisspecifiedandtheextraparameterthatisspecifictotheparallelport.
MoreinformationontheXircomPE3Ethernetdevicecanbefoundonlineathttp://www.
brutman.
com/Dos_Networking/xircom_pe3.
html.
FindingpacketdriversPacketdriversarespecifictomodelsofEthernetcards.
OlderISAbuscardsalmostalwayshadpacketdriversavailableforthem.
ManyolderPCIcardsalsohadpacketdriversavailabletoo.
IfyouhavetheoriginaldriverdisketteorCD-ROMthatcamewithyourEthernetcardthatmighthavetheSetuppacketdriverincludedwithit.
Herearesomeotherplacestolook:http://www.
crynwr.
com/drivers/hasacollectionofopensourcepacketdriversforoldercardshttp://www.
georgpotthast.
de/sioux/packet.
htmhassomepacketdriversfornewerEthernetcardsIfyourcarddoesnothaveapacketdriveravailableitmighthaveanODIdriverinstead.
ODIdriverscanbemadetolooklikepacketdriversusingaprogramcalledODIPKT.
COM.
Seeftp://ftp.
hs-koblenz.
de/pub/pc/msdos/networking/odi/odipkt/tofindacopyofODIPKT.
COM.
IfyourcardonlyhasanNDISstyledriverlookforDIS_PKT.
DOS.
Adiscussionofhowtouseitcanbefoundathttp://www.
freedos.
org/wiki/index.
php/Networking_FreeDOS_-_NDIS_driver_installation.
CreatingthemTCPconfigurationfileThemTCPconfigurationfileisasimpletextfilethattellsmTCPapplicationsthenetworkingparametersandotherconfigurationvaluesthattheyneedtorun.
Youonlyhavetospendtimeoncetocreatethefile;afterthatyoumaychangeitoraddtoitbutthebasicswillremainthesame.
CreatingtheminimalconfigurationfileforusewithDHCPThesmallestmTCPconfigurationfileconsistsoflineline.
IttellsthemTCPprogramswheretofindthesoftwareservicesinstalledbythepacketdriverfortheEthernetcard.
Forexample,thiswouldbeavalidmTCPfileforamachinethathasaworkingEthernetcardandapacketdriverforitloadedusingsoftwareinterrupt0x62:PACKETINT0x62Noticethattherearenonetworkingparametersinthefile.
TheonlythingthatthisfiledoesistellmTCPtousesoftwareinterrupt0x62tofindapacketdriver.
ThisiswherethemTCPDHCPclientcomesin.
Insteadofrequiringyoutoaddthenetworkingparameterstotheconfigurationfileyourself,theDHCPprogramcanberunanditwilladdthenetworkingparametersautomatically.
BeforewecanruntheDHCPprogramweneedtosetaDOSenvironmentvariablethattellsmTCPprogramswherethemTCPconfigurationfilecanbefound:(AssumingtheconfigurationfileislocatedinC:\MTCP\MYCONFIG.
TXT)setMTCPCFG=C:\MTCP\MYCONFIG.
TXTNowwhenyouruntheDHCPprogramthefollowingwillhappen:TheDHCPprogramwillloadandlookforanenvironmentvariablecalledMTCPCFG.
ThefilenamepointedatbytheMTCPCFGenvironmentvariablewillberead.
DHCPwilllookforthe"PACKETINT"lineinthefileandseethatitissupposedtousesoftwareinterrupt0x62tocommunicatewithaloadedpacketdriver.
SetupDHCPwillmakeaconnectiontothepacketdriversothatitcansendandreceivepackets.
DHCPwillusethepacketdrivertosendandreceivepacketswithyourDHCPserver.
ThisispartoftheprocessofnegotiatingaDHCPleaseforyourmachine.
(TheleaseistherighttouseanIPaddressforalimitedperiodoftime.
)DHCPwillupdatetheconfigurationfilesothatitlookslikethiswhenitisdone:DHCPVERDHCPClientversionMay22015TIMESTAMP(1432571386)MonMay2512:29:462015PACKETINT0x60IPADDR192.
168.
2.
146NETMASK255.
255.
255.
0GATEWAY192.
168.
2.
1NAMESERVER192.
168.
2.
1LEASE_TIME86400Noticethattwolineswereaddedatthetopandfivemorelineswereaddedatthebottom.
ThefivelinesatthebottomarethenetworkingparametersgiventoyourmachinebytheDHCPserver.
ThetwolinesatthetopareaddedsothatitiseasytodeterminethatDHCPsetthenetworkingparameters.
SettingyourownnetworkingparametersusingstaticconfigurationIfyouareinanenvironmentwithoutaDHCPserverorifyoudonotwanttouseDHCPthenyoucansetthenetworkingparametersinthemTCPconfigurationfilebyhand.
ThebasicstepsarethesameexceptinsteadofusingDHCPtoaddthenetworkingparametersyouwillputtheminthefilewhenyoucreateit.
Hereisasamplefile:PACKETINT0x60IPADDR192.
168.
1.
10NETMASK255.
255.
255.
0GATEWAY192.
168.
1.
1NAMESERVER192.
168.
1.
1ThissampleissimilartotheDHCPcreatedversionexceptthatitismissingtheDHCPspecifics.
Reminder:TousemTCPprogramsyoustillneedtosettheMTCPCFGenvironmentvariabletothelocationofthisfile.
NetworkingrelatedconfigurationparametersWhatfollowsisadetaileddescriptionofthenetworkingrelatedparametersthatarevalidtouseinthemTCPconfigurationfile.
PACKETINTRequired:YesThisisthesoftwareinterruptnumberthatthepacketdriverislisteningon.
Thishastomatchthesoftwareinterruptnumberthatyoutoldthepacketdrivertouse.
Itisspecifiedinhexadecimalnotation.
(eg:0x60)IPADDRSetupRequired:Yes(AutomaticwhenusingDHCP)ThisistheassignedIPaddressofthemachine.
IPaddressesneedtobeuniqueonyournetwork.
IftwomachinestrytosharethesameIPaddressneithermachinewillbeabletocommunicatereliably.
ThevaluecanbeprovidedexplicitlyoritcanbeprovidedbytheDHCPprogram.
IfyouareusingDHCPthenIPADDRwillbeaddedifitisnotfoundoroverwrittenwithanewvaluewhenanewleaseisassigned.
NETMASKRequired:Yes(AutomaticwhenusingDHCP)Thisistheassignednetworkmaskforyourlocalareanetwork.
Thenetworkmaskisusedtodetermineifatargetmachineforapacketisonthesamelocalareanetworkasyourmachineoronaremotenetwork.
PacketsthataredestinedforaremotenetworkwillbesenttothemachinespecifiedbytheGATEWAYconfigurationparameter.
ThevaluecanbeprovidedexplicitlyoritcanbeprovidedbytheDHCPprogram.
IfyouareusingDHCPthenNETMASKwillbeaddedifitisnotfoundoroverwrittenwithanewvaluewhenanewleaseisassigned.
GATEWAYRequired:No,butrecommended(AutomaticwhenusingDHCP)ThisistheIPaddressofthemachinethatwillbeusedtoforwardpacketsdestinedforremotenetworks.
ThisisusuallytheIPaddressofarouter.
Ifthisisnotprovidedoritissetincorrectlyyouwillonlybeabletosendandreceivepacketsthatareonyoursamelocalnetwork.
ThevaluecanbeprovidedexplicitlyoritcanbeprovidedbytheDHCPprogram.
IfyouareusingDHCPthenGATEWAYwillbeaddedifitisnotfoundoroverwrittenwithanewvaluewhenanewleaseisassigned.
MTURequired:NoMTUstandsfor"MaximumTransmissionUnit",whichisthelargestnumberofbytesthatcanbesentbyyournetworkinghardwareinasinglepacket.
ForEthernetthisvalueistypically1500bytes,butthatvaluemightnotworkwellonmixednetworkswhereothernetworkshavesmallerMTUsizes.
Asettingof576shouldbesafeforalmostallenvironments.
SLIPandPPPuserswillhaveasmallervaluedependingontheirSLIPorPPPconnection.
PleaseseetheseparatesectiononMTUforamoredetaileddiscussion.
NAMESERVERRequired:No,butrecommended(AutomaticwhenusingDHCP)SetupThisistheIPaddressofthenameserveronyournetwork,whichisresponsiblefortranslatinghumanreadablemachinenames(www.
brutman.
com)toIPaddresses.
IfthisvalueisincorrectthenconvertingmachinenamestoIPaddresseswillnotwork.
ThevaluecanbeprovidedexplicitlyoritcanbeprovidedbytheDHCPprogram.
IfyouareusingDHCPthenNAMESERVERwillbeaddedifitisnotfoundoroverwrittenwithanewvaluewhenanewleaseisassigned.
NAMESERVER_PREFERREDRequired:NoIfyouareusingDHCPanditisassigningyouanameserverbutyouwanttouseadifferentnameserver,usethisoption.
Forexample,ifDHCPisassigningyouanameserverrunbyyourISPandyouprefertouseGoogleDNSinsteadthenthissettingwilltellmTCPtouseGoogleDNSinsteadofthedefaultnameserver:NAMESERVER_PREFERRED8.
8.
8.
8DHCPwillnotoverwritethispreference.
Sidenote:GoogleDNSisfast,reliable,anddoesnotreturnbogusresultswhenanamedoesnotresolve,unlikemanyISPnameservers.
HOSTNAMERequired:NoThehostnameofyourmachine.
Thehostnamecanbeuptotwentycharacters,andshouldconformtointernetstandards.
(Avoidpunctuationandyoushouldbefine.
)OtherconfigurationparametersThemTCPconfigurationfileisusedformorethannetworkconfiguration.
OthermTCPapplicationsmayreadittolookfortheirconfigurationsettings.
Ingeneral,youcanputanythingyouwantintheconfigurationfile.
LinesthattheDHCPclientdon'tunderstandwillbeleftunaltered.
Herearetherules:BlanklinesareOK.
Commentsstartwitha#characterinthefirstpositionoftheline.
Linesshouldneverexceed140characters.
IfyouusetheDHCPclientitwillrewritetheconfigurationfileandwritenewvaluesforIPADDR,NETMASK,GATEWAY,andNAMESERVER.
Thepreviousvalueswillbelost,butnootherlinesinthefilewillbealtered.
OthermTCPprogramsgenerallyreadbutdonotalterthefile.
Theywillskiplinesthattheydonotunderstand.
(Andthereisnoreasonwhytheycan'twritethefile;noneofthedothatatthemoment.
)SetupHereisasampleofamorecomplexmTCPconfigurationfile:DHCPVERDHCPClientversionMay22015TIMESTAMP(1432571386)MonMay2512:29:462015#Parmsformymachine#packetint0x60mtu1500hostnameDOSBox#IRCjrparms#ircjr_nickZoidbergircjr_userZoidBergircjr_nameJohnFZoidbergircjr_connect_timeout30ircjr_register_timeout60#FTPparms#ftp_connect_timeout15ftp_tcp_buffer8192ftp_file_buffer16384#DHCPgeneratedsettingswillappearhere#IPADDR192.
168.
2.
102NETMASK255.
255.
255.
0GATEWAY192.
168.
2.
1NAMESERVER24.
159.
193.
40LEASE_TIME86400NotethattheDHCPclientadds/replacesthefirsttwolinesofthefileandthelastfivelinesofthefile.
Therestofthelinesinthefilearekeptasisfortheotherapplications.
Configurationparametersforeachapplicationaredocumentedbythatapplication.
Thesamplefileaboveisjustasample;seetheindividualprogramstoseewhichconfigurationparameterstheysupport.
AdvancedtopicsTheMTUsettingMTUstandsfor'MaximumTransmissionUnit'andittellstheTCP/IPstackhowbigofapacketitcansendonthelocalnetwork.
Biggerpacketsgenerallymeanlessoverhead.
InaworldwhereallnetworksarebuiltusingthesametechnologytheMTUsettingwouldnotbeneeded.
Butthatisnotourworld.
Ethernetpredominates,butthereareotherphysicaltransportsouttherethatyoumightnotbeawareofthatyouareusing.
YourEthernettrafficcanbetransmittedovermanydifferentthingsthatdon'tlooklikeEthernetbeforeitreachesitsfinaldestination.
TCP/IPuses'fragments'todealwiththisproblem.
Ifapacketistoobigtopassfromonenetworktoanotherthegatewaymachinewillbreakthepacketintofragmentssuitableforthenextnetwork.
ItispossiblethatasingleSetuppacketwillbebrokenintofragmentsmultipletimesoverthecourseofitsjourney.
ThereceivingsideisresponsibleforgatheringallofthefragmentsforanIPpackettogetherandreassemblingthem.
Whilethisprocessworksitisnotideal.
Itcausesaperformancelossasthepacketsarefragmentedbythegatewaysandabiggerperformancelosswhenthefragmentsreachtheirfinaldestinationandhavetobereassembled.
Inadditiontotheperformanceloss,itrequiresquiteabitofmemorytoo.
Andlosingafragmenthurtsperformanceevenmorebecausealloftheotherfragmentsforthatpackethavetobethrownaway.
Intherealworldfragmentsarerare.
MostmodernserversusingTCPsocketsdosomeformofpathMTUdiscoverytodeterminethelargestpacketthatcanbesentwithoutcausingfragmentstobecreated.
ForaTCPsocketitworksverywellandyouwillhavetoworkhardtotrytogetaservertosendyouapacketthatneedsfragmenting.
Ontheotherhand,thatmechanismisnotapplicabletoUDPpackets.
AserversendingaUDPpackethasnochoiceabouthowto'chunk'thedatatoavoidfragmentation;ithastosendwhattheapplicationsaystosend.
MostUDPbasedprogramsavoidsendinglargepacketsthatwillbefragmented,butthereareexceptions.
(NFSandprogramssendingstreamingvideodataaretwonotableexceptions.
)mTCPsupportsthereassemblyoffragmentedpackets,withsomerestrictions.
Thereisalimitonthetotalsizeofthefragmentedpacketthatissetatcompiletime,andthereisalimittothenumberoffragmentsthatcanbereassembledatthesametime.
Currentlythoselimitsaresetat1500bytesperpacket,and4packetsatatime.
Whilelow,thoselimitswillprotectyouagainstaserveronastandardEthernetthatgoesthroughamisconfiguredgatewaythatcausesfragmentstobecreated.
(ForUDPapplicationsthatrequirelargerpacketsthatcanbesetatcompiletimewhensuchanapplicationiscreated.
Therearenosuchapplicationsavailableatthemoment.
)EventhoughmTCPcanreassemblefragmentstherearestillallsortsoffragmentrelateddangersfloatingaroundoutthere:SomeTCP/IPserverssetthe'Don'tFragment'bitontheirpackets.
Ifthepacketneedsfragmentationatagatewayandthisbitisset,thepacketeffectivelygetsdroppedatthegateway.
mTCPwillhavenoknowledgeandnowaytogetaroundthedroppedpackets,otherthanmysterioustimeoutsfromtheapplication.
Whiletheservermightbetryingtoavoidadditionaloverheadcausedbyfragmentation,itisreallydoingadisservicebyforcingthesepacketstobedropped.
(I'drathergetthedataslowlythannotgetitatall.
)Somehomerouter/firewallsthrowfragmentsawayratherthantrytoprocessthemcorrectly.
ThisisespeciallytruewhenNAT(NetworkAddressTranslation)isused.
Thegoodnewsisthatyouhavesomecontrolovertheproblem.
ApplicationsthatuseTCPsocketswilltelltheremotesidewhattheirMSS(MaximumSegmentSize)is.
(MSSisbasedonMTU.
)ThishappensduringthesocketconnectandoncetheremotesideknowsyourMSSitwillnotknowinglysendyouapacketthatneedstobefragmented.
(Somethinginthemiddlemightcausefragmentation,soitisstillpossible.
MTUpathdiscoveryissupposedtoavoidthatdangerbyactivelyprobingallgatewaysbetweentheserverandyourmachine.
)IfyouarehavingproblemwithdroppedpacketsonaTCPsocket,setyourMTUto576.
Thatisguaranteedtoworkonallgatewaysandallrouters.
ThisisalsothedefaultformTCPifyoudonotspecifyanMTUsize.
SetupUDPshouldnothavethisproblem;ifanapplicationknowinglysendsalargepacketitwillnotturnontheDon'tFragmentbitintheIPheader.
Doingsowouldeffectivelybreaktheapplication,asthedatawouldneverbeabletogetout.
OnalargeUDPpacketfragmentationistheonlysolution;thereisnoconceptofMSS.
MostUDPpacketsusedbymTCPneverexceed512bytesofdata,sofragmentationisnotanissue.
ForbestperformancesetMTUhaslargeasyoucan.
ForEthernetthatvalueisusually1500bytes.
Thisminimizestheoverheadoftheprotocolheadersandminimizesinterrupthandling.
Ifyouarehavingstrangeconnectionissuesyoumightbebumpingintoafragmentationproblem.
Manytimesthereisnowarningmessagebecausethepacketsjustsimplydon'tarrive,andtheICMPmessagesgetsentdirectlytotheserver,notthemTCPcode.
IfthishappenssetyourMTUto576andtryagain.
SLIPandPPPconnectionsgenerallyhavesmallerMTUsettingswhichmaycausefragmentation.
Thisisunavoidable;consideritpartofthejoyofusinglowspeedpoint-to-pointlinks.
YourlocalgatewaythatisprovidingtheSLIPorPPPconnectivitywillgeneratefragmentsthatmTCPwillhavetoreassemble.
SLIPandPPPnotes(PleaseseethechaptersonPPPandSLIPfordetailedinstructionsonhowtosetupPPPandSLIPconnections,includinghowtouseaLinuxmachineasthegateway.
)IdesignedandimplementedeverythingallofthiscodeassumingEthernet.
QuiteabitdowntheroadsomebodypointedoutthatmycodewasinaccessibletoanentireclassofpeopleusingSLIP(SerialLineIP)andPPP,whichisoftenusedondial-up.
I'vetestedthecodeusingSLIPandPPP.
Herearethekeythingsyouneedtobeawareof.
YouneedtouseapacketdriverthatsimulatesEthernet.
SLIPPRandCSLIPPERcandothisforSLIPconnections,andDOSPPPcandothisforPPPconnections.
ForSLIPPRusethe"ether"optiontodothis.
ForDOSPPPusetheEPPPDprogram.
mTCPassumesthatARPisnecessary,whichiscompletelywrongonapointtopointconnection.
ItwillnotgetaresponsetoanARPqueryforthegateway,anditwilltimeout.
Toavoidthissetthefollowingenvironmentvariable:setMTCPSLIP=trueDothisforbothSLIPandPPP.
ThisenvironmentvariablestuffsabogusARPentryintothemTCPARPtableforyourgateway.
ThatallowsittoimmediatelysendpacketstothegatewaywithoutsendinganARPrequest.
TheEthernetaddressinthesentpacketswillbewrong,butnothingislookingatitanyway.
I'vetestedconfigurationsusingstaticaddressing.
YouwillhavetofindawaytopasstheIPaddress,netmask,etc.
tomTCPusingit'sconfigurationfile.
Itisbeyondthescopeofthisdocumenttoexplainaddressinginapoint-to-pointconfiguration.
Hereissomethingtokeepinmindthough.
Ifyouusethesmallestpossiblenetmask(255.
255.
255.
252)youcaneasilycreateaconfigurationthatSetupworks.
Withthatnetmaskonlythelasttwobitsaresignificant.
Consideringthelasttwobitsonly:.
0-reservedaddressmeaning'thishost'.
1-usable,goodforthegatewayaddress.
2-usable,goodforyouraddress.
3-IPbroadcastaddressforthisnetworkSettingupyournetmaskandaddresseslikethisissimpleandshouldavoidroutingproblems.
BasicallyyouforcemTCPtoalwayssendthingstothegatewaybecausenothingelseisonyoursubnet.
SLIPandPPPgenerallyusesmallerMTUsettingsthanothernetworksbecausetheirtransportlayerisslower.
BesurethatthemTCPMTUsettingreflectswhatyourSLIPorPPPconnectionisusing.
Dependingontheapplication,serversandgatewaysyoumayexperiencesomefragmentation,especiallyonUDPpackets.
(TCPgenerallyavoidsthisbyusingtheMTUsettingtocomputeMSS.
)HowtheconfigurationfileworksAtthebeginningoftime,mTCPusedenvironmentvariablesforalloftheconfiguration.
ThisworkedwelluntiltheIRCclientcamealongandIhadtostartincreasingthesizeoftheDOSenvironmentspace.
ThencametheDHCPclient-Icouldn'tfindawaytosetenvironmentvariablesfromwithintheDHCPclientandmakethemstickforthenextprogramwithoutwritingoutafile.
Atthatpointtheconfigurationfilewasborn.
WhentheDHCPclientstartsupitreadsthePACKETINTandHOSTNAMEparametersfromtheconfigurationfileandignorestherest.
(HOSTNAMEisoptional.
)ItthentriestocommunicatewiththeDHCPserveronyournetwork.
IfitgetsanaddressfromtheDHCPserveritwillwriteanewconfigurationfile.
Allofthecontentsoftheoldconfigurationfilearecopied,exceptfortheIPADDR,NETMASK,GATEWAY,NAMESERVER,andLEASE_TIMEparameterswhichgetupdatedwithnewvaluesattheendofthefile.
HavingDHCPwriteaconfigurationfilehasaninterestingsideeffect.
Itmeansthatatitscore,everymTCPapplicationassumesstaticnetworkaddressing.
Theyallreadtheconfigurationfiletogetthenetworkparameters,andtheycan'ttellifthenetworkparametersweresetbyahumanoramachine.
Atstart-upeachapplicationlooksfortheMTCPCFGenvironmentvariableandtriestoreadtheconfigurationfile.
ItmakesonepasstogetthenetworkingparametersthatitneedstoinitializetheTCP/IPstack.
Ifanapplicationhasotherconfigurationparametersthatitneedstoreaditwillreopentheconfigurationfileandscanforthem.
Theformatforaparameterisasingletokenthatrepresentstheparametername,aspaceforadelimiter,andthenthevalueoftheparameter.
Theentirerestofthelineisassumedtobetheparameter.
Linesmustbeunder75charactersintotallength.
mTCPandVirtualEnvironmentsmTCPandVirtualEnvironmentsIfyouwanttotryDOSandmTCPbutdon'thaveanoldcomputertodedicatetoit,don'tworry!
Allofthisrunsfineinvirtualandemulatedenvironments.
Herearesomenotestogetyoustarted.
IfyoufindthatyourvirtualmachineischewingupalotofCPUpleasereadthesectiononDOSPowercontrol.
Usingthewrongpower/idlemanagementprogramwillreduceyourCPUusagebutalsohurttheusabilityofmTCP.
DOSBoxDOSBoxisanx86PCemulatordesignedtorunoldDOSgamesonmodernhardwarerunningmodernoperatingsystems.
WhileWindowsXPhasaDOS-likecommandlineitisnotsufficienttorunmanyoldgames.
ThisiswhereDOSBoxtakesoverandshines.
Whilerelativelyfullfeatured,DOSBoxisnotafullmachineemulator.
DOSisemulatedjustenoughtomaketheoldgamesrun.
Thecommandpromptrecognizesafewmajorcommands;youmayneedtoaddmorefromyourfavoriteDOSversion.
DOSBoxcanbeconfiguredtosharepartofthehostoperatingsystemfilesystemsothatmovingfilesinandoutiseasy.
BydefaultthereisnonetworkingsupportinDOSBox.
TogetanemulatednetworkdeviceyouneedtouseaspecialbuildofDOSBoxcreatedby"HAL9000".
TheHAL9000"megabuilds"addNE2000emulationallowingnetworkingapplicationstorun,plusafewothergoodies.
WhenusingtheNE2000emulationDOSBoxwillappeartobephysicallyconnectedtothenetwork.
(Thisiscommonlyknownas"bridged"mode.
)IhavebeenusingthemegabuildsforoverfouryearsnowandIamverypleasedwiththeirquality.
IdomostofmyfunctionaltestingwithDOSBoxsoIknowthatitworkswellwithmTCP.
ThebiggestfunctionmissingfromDOSBoxisproperCtrl-BreakandCtrl-Chandling.
mTCPletsyoubreakoutofsomelongrunningapplicationsusingCtrl-BreakandCtrl-CsounderDOSBoxthatfeaturemightnotwork.
ButforthemostpartDOSBoxisagreatwaytorunmTCP.
DOSBoxmainsitehttp://www.
dosbox.
com/HAL9000DOSBoxmegabuildshttp://home.
arcor.
de/h-a-l-9000/NE2000packetdriverforusewithDOSBoxhttp://www.
brutman.
com/mTCP/NE2000.
COMVirtualBoxVirtualBoxisanopensourceprogramthatcreatesavirtualx86machinewithinyourhostoperatingsystem.
Youdefinetheamountofmemory,thesizeofthevirtualharddrive,theamountofvideomemory,networkingsupport,andafewotherattributestocreateavirtualmachine.
ThenyoubootthevirtualmachineandinstallDOSonit,justlikeyouwoulddoonabaremachinethatyouareinstallingforthefirsttime.
ThevirtualmachineemulationtakesadvantageofmodernCPUfeaturesmakingitextremelyfast-almostasfastasrunningdirectlyonthehardwarewithoutthehostoperatingsystemintheway.
VirtualmachinesslowdownwhendoingI/Ooperationsbutitisnotenoughtoworryabout.
VirtualBoxhasavarietyofnetworkcardsthatitcanemulateanditcanmakeyourvirtualmachinelooklikeitisdirectlyonthenetwork("bridged"),behindafirewall("NAT",orNetworkAddressTranslation),andafewmTCPandVirtualEnvironmentsotheroptions.
Iuse"bridged"modeandtheAMDPCNetdevice,whichisthesamedeviceusedbyVMWarePlayer.
Ifyouuseadifferentemulateddevicebesuretofindthecorrectpacketdriverforit.
AllofthemTCPapplicationsrunwellexceptforPING,whichrunsbutseemstosufferfromatimingproblem.
IreprogramtheintervaltimertogethigherresolutiontimingsthanarenormallypossibleonDOSanditlooksasthoughPINGistrippingonthis.
Itwilleventuallycompletebutittakesmuchlongerbetweenpingpacketsthanitshould.
(Thepackettimingsareaccurate,butthewaittimebetweenpacketsistoolong.
)VirtualBoxmainsitehttp://virtualbox.
org/AMDPCNetpacketdriverhttp://www.
brutman.
com/mTCP/PCNTPK.
COMVMWarePlayerVMWarePlayerisaclosedsource(butfree)virtualx86machinethatisverysimilarinoperationtoVirtualBox.
(VMWarepredatesVirtualBoxbyquiteabit.
)Youdefineyourvirtualmachine,installDOS,andthenrunitsidebysidewithyourhostoperatingsystem.
ThenetworkingworksbasicallythesamewayasitdoesinVirtualBox-"bridged"makesyourvirtualmachinelooklikeitisdirectlyconnectedtotheLAN.
"NAT"(NetworkAddressTranslation)makesitlooklikeyourvirtualmachineishidingbehindafirewallonyourhostoperatingsystem.
"Host-only"isthemostlimited,anditallowsyoutocommunicateonlywiththehostoperatingsystem.
VMWareemulatessomeformofAMDPCNetEthernetdevice.
Iamusingversion3.
1.
3onWindowsXP.
Everythingworksperfectly,includingPING,soVMWarePlayerprobablydoesabetterjobofemulatingthePCtimerhardwarethatIamreprogramming.
VMWarePlayermainsitehttp://www.
vmware.
com/products/player/AMDPCNetpacketdriverhttp://www.
brutman.
com/mTCP/PCNTPK.
COMSwsVpktSwsVpktisavirtualpacketdriverthatallowsDOSnetworkingapplicationstorundirectlyunderWindowsNT4,2000andXPinacommandwindow.
SwsVpktworksbylettingthoseapplicationssendRAWEthernetpacketstoandfromthenetworkusinganetworkcardonthemachine.
UnliketheothersolutionsonthispageSwsVpktdoesnotgiveyourcodetheillusionofhavingaseparatenetworkcardwithauniqueMACaddress.
YourDOSapplicationwillbesendingandreceivingpacketsusingtheactualMACaddressofthecardyouselecttouse.
IfyouusethesamecardthatyourhostoperatingsystemisusingyouneedtoconfiguremTCPtouseadifferentIPaddressthanwhatyourhostisusing.
ThismakesDHCPunusableasyourDHCPserverwillseetheMACaddressandgivemTCPthesameaddressthatitgaveyourhostoperatingsystem.
Asaresult,staticconfigurationoftheIPaddressinthemTCPconfigurationfileisrequired.
Herearesomeusagenotes:Use"swsvpkt-l"tolistavailableadapters.
Use"swsvpkt-a"toloadswsvpktanduseaspecificadapter.
istheadaptertouseandyouneedtochooseonethatisconnectedtoyournetwork.
isthemTCPandVirtualEnvironmentssoftwareinterruptthatmTCPwillusetotalktoswsvpkt.
BesurethatyousetupyourmTCPconfigurationfilebyhandandthattheaddressyouchooseisdifferentthantheaddressbeingusedbythehostmachine!
Onmymachine"swsvpkt-l"findsfournetworkadaptersitcanbindto:E:\DOSPROGS\MTCP>swsvpkt-lPacketdriverforWindowsVDMversion1.
05,updatedFriMay1912:59:332006Copyright(C)2005,2006LawrenceRust.
Allrightsreserved.
Foundinterface:0:VMwareVirtualEthernetAdapter1:VMwareVirtualEthernetAdapter2:Intel(R)82562V-210/100NetworkConnection(Microsoft'sPacketScheduler)3:NOCExtranetAccessAdapter(Microsoft'sPacketScheduler)TorunIuseswsvpkt-a20x60:E:\DOSPROGS\MTCP>swsvpkt-a20x60PacketdriverforWindowsVDMversion1.
05,updatedFriMay1912:59:332006Copyright(C)2005,2006LawrenceRust.
Allrightsreserved.
Foundinterface:0:VMwareVirtualEthernetAdapter1:VMwareVirtualEthernetAdapter2:Intel(R)82562V-210/100NetworkConnection(Microsoft'sPacketScheduler)3:NOCExtranetAccessAdapter(Microsoft'sPacketScheduler)InstalledonSWI0x60,usingIRQ7.
ThemTCPapplicationsseemtoworknormallywhenrunusingswsvpkt.
Ihavenoticedthatswsvpktleavesthecommandwindowinastrangestate-commandlineeditingnolongerworksafterIhaverunit.
I'mnotquitesurewhatisgoingon,soifyouknowwhatitispleasedropmealine.
(Othercommandlinewindowsarenotaffected.
)SwsVpktmainsitehttp://www.
softsystem.
co.
uk/products/swsvpkt.
htmmTCPApplicationsDHCPclientDHCPclientIntroductionADHCPclientisasmallutilitythathelpsyouautomaticallyconfigurethenetworkingparametersforamachine,allowingittouseyournetwork.
Thisisanalternativeto"static"addressingwhereyousetthenetworkparametersforyourmachinemanually.
MostnetworkshavearouterthathasaDHCPserverbuiltin,makingDHCPthepreferredwaytoconfigureamachinefornetworking.
ThisDHCPclientcanbeusedtoautomaticallyconfigurethenetworkingparametersforallofthemTCPapplicationsandwithsomeclevernessitcanbeusedforothernetworkingstacksaswell.
Specialhardwareorsoftwarerequirements:NoneSetupinstructionsDHCPisbuiltusingthemTCPlibrary.
ThedetailedsetupinstructionsformTCPcanbefoundinSETUP.
TXT.
Hereisthequickstory:1.
Loadyourpacketdriver.
IfyourpacketdriverloadscorrectlyitwillprobablyreporttheMACaddressofyourEthernethardware.
2.
CreateaconfigurationfileformTCP.
TheconfigurationfileisatextfilethatallmTCPappswillreadwhentheystart.
ThesmallestpossibleconfigurationfilehasonelineinittotellmTCPwherethepacketdriverisloaded.
Hereisanexample:packetint0x60Justreplacethe0x60withwhateversoftwareinterruptyourpacketdriverissettouse.
Therearemorethingsyoucanaddtotheconfigurationfilebutthiswillgetyoustarted.
3.
SettheMTCPCFGenvironmentvariabletothefullpathandnameoftheconfigurationfile.
Forexample:setMTCPCFG=c:\mtcp\tcp.
cfgAndnowyoushouldbereadytorunDHCP.
DHCPclientUsingDHCPTheDHCPcommandlineformatis:dhcp[options]whereoptionsare:-helpShowahelpmessage-retriesRetryntimesbeforegivingup(default=3)-timeoutSettimeoutforeachattempttonseconds(default=10)WhenDHCPrunsitwillsendaseriesofUDPpacketsandtrytonegotiateaDHCPleasewithaDHCPserveronyournetwork.
IfDHCPissuccessfulitwillsetareturncodeof0,showthenetworksettingsitreceivedonthescreen,andwritethenewnetworksettingstothemTCPconfigurationfile.
IfDHCPfailsitwillsetareturncodeof1.
YoucancheckthereturncodeinabatchfileusingERRORLEVEL.
Hereisasimpleexample:ne20000x603setmtcpcfg=e:\mtcp\tcp.
cfgdhcp-retries3-timeout20echooffiferrorlevel1gotoErrmsgechoDHCPworkedgotoEnd:ErrmsgechoDHCPfailed!
:EndYoushouldrunthisprogramatleastonceaday,andbeforerunninganyothermTCPprograms.
ThisprogramwillwritethesettingsitgetsintoaconfigurationfilethattheothermTCPprogramswilllookforanduse.
(YoudonotneedtorunDHCPbeforeeachmTCPapplication.
)DHCPleasedurationRememberthataDHCPleasehasanexpirationtime;yourrouterwillnotletyouuseanaddressforever.
Thenormalleasedurationisafewhoursbutitcanbemuchshorterthanthat.
DHCPstoresthetimetheleasewasgrantedandtheexpirationtimeinthemTCPconfigurationfile.
WhenanmTCPprogramstartsitwillcheckthecurrenttimeandtheleaseexpirationtime.
Itwillissueawarningandrefusetostartiftheleaseisgoingtoexpirewithinanhour.
IfyourDHCPserverissuesshortleases(lessthananhour)thiswillbeaproblem.
ThereisaconfigurationoverridethatyoucanaddtothemTCPconfigurationfiletooverridethatthreshold.
ThenameofthevalueisDHCP_LEASE_THRESHOLDandthevalueisthenumberofsecondstosetthethresholdto.
Forexample:DHCP_LEASE_THRESHOLD1800DHCPclientwillchangethethresholdto1800secondssothatifyourDHCPleaseexpirationisfurtherthan30minutesoutintothefutureyouwillnotgetawarning.
DHCPfailuresDHCPisoftenthefirstthingthatrunsafterauserdoesthebasicmTCPconfiguration.
Asaresultitisoftenthefirstthingtofail.
Themostcommonformoffailureisatimeout.
Belowaresomefactorsthatcancausetimeouts:amisconfiguredcardusingthewrongpacketdriverbadparameterstothepacketdrivercabling/networkissuesAdetaileddiscussionofthesefactorscanbefoundintheDebuggingsection.
IntheunlikelyeventthatyoucannotuseDHCPyoucanstillusemTCPapplications;youwillhavetodothenetworkparametersetupmanuallythough.
SeetheSetupsectionfordetails.
(IhavenotyetmetaDHCPserverthatmTCPdoesnotworkwithsobeingforcedtodoamanualsetupisunlikely.
)ConfigurationparametersNormallyconfigurationparametersareread-onlyandareusedtosetthebehaviorofaprogram.
DHCPisuniqueinthatitwritessomeconfigurationparameterstothemTCPconfigurationfile.
Theseparametersarenetworkingrelatedparameters.
ParametersprovidedbytheDHCPserver:TheseconfigurationparameterswillbeoverwrittenbythevaluesthatyourDHCPserversends.
IPADDRThisistheassignedIPaddressofyourDOSmachine.
NETMASKThisistheassignednetworkmaskforyourDOSmachine.
GATEWAYIfprovided,thisistheIPaddressofthedefaultgatewaythatyourDOSmachinewillusetoconnecttomachinesthatarenotonthesamenetworksegment.
(Whileoptional,itisalmostalwaysprovided.
)NAMESERVERDHCPclientIfprovidedthisistheIPaddressoftheDNSserverthatwillbeusedtoresolvehostnamestoIPaddresses.
IfthisisnotprovidedhostnameswillnotbeabletobeconvertedtoIPaddresses.
LEASE_TIMEThisisthenumberofsecondsthattheDHCPleaseisvalidfor.
mTCPapplicationswillcheckforleaseexpirationwhentheystart,buttheywillnotcheckagainwhiletheyarerunning.
SoifyourDHCPleaseisduetoexpiresoontherewillbeawarningatstart-up.
Configurationparameters:DHCP_LEASE_THRESHOLDThisoptionsetswhenmTCPapplicationswillwarnyouthatyourleaseisabouttoexpire.
PleaseseeDHCPleasedurationforhowitworks.
NAMESERVER_PREFERREDThisoptioncanbeusedtotellmTCPapplicationstouseadifferentnameserverthantheoneprovidedbyyourDHCPserver.
Forexample,ifyouwanttouseGooglepublicDNSserversinsteadofyourISP'snameserversyoucouldusethefollowing:NAMESERVER_PREFERRED8.
8.
8.
8TheNAMESERVERoptionsetbyyourDHCPserverwillcontinuetobeupdated,butmTCPprogramswilluseNAMESERVER_PREFERREDifitisset.
Recentchanges2015-04-10Addpreferrednameserversupport2014-06-01AddDHCP_LEASE_THRESHOLDconfigurationparameter2013-03-29AddnumericaltimestamptotheDHCPtimestampmessagetomakeiteasiertocomputewhentheleaseexpires.
DNSTestDNSTestIntroductionThisisasimpleutilityforresolvingmachinenamestoIPaddresses.
ItusesUDPonly,whichisstandardforDNS.
Ifyouarecuriousthereisalotofdebugoutputavailableusingacommandlineoption.
Specialhardwareorsoftwarerequirements:NoneSetupinstructionsDNSnameresolvingdependsontheNAMESERVERconfigurationsettinginthemTCPconfigurationfilebeingsetcorrectly.
IfyouareunsureofwhattosetNAMESERVERto,GooglerunsapublicDNSsystemthatisfastandreliable.
TheIPaddressesfortheGoogleDNSserversare8.
8.
8.
8or8.
8.
4.
4.
Seehttps://developers.
google.
com/speed/public-dns/fordetails.
UsingDNSTestUsageislikethis:dnstest-name[options]Optionsare:-helpShowahelpmessage-norecurseDonotrequestarecursiveDNSlookup-timeoutTimeoutafterseconds-verboseTurnonverbosedebugmessagesThe-norecurseoptionrequiressomeexplanation.
NormallymTCPwillsendDNSrequestswiththe'recursionrequested'flagturnedonintherequest.
Thismakesthenameserversdoalotoftheworknecessarytoresolveaname.
IfyousetthisoptionthatflagwillnotbesetandyouwillseealotmoreactivityonyourmachinetodothesameDNSlookup.
Itisinterestingtoplaywithbutisinefficientfornormallookups.
Usethisoptionwiththe-verboseoptiontoseethefulleffect.
Hereissomesampleoutput:dnstest-namewww.
brutman.
commTCPDNSTestbyMBrutman(mbbrutman@gmail.
com)(C)opyright2009-2013Version:May22015Timeoutsetto10seconds,DNSRecursion=onPress[ESC]or[Ctrl-C]toquitearlyMachinenamewww.
brutman.
comresolvedto208.
73.
32.
24Elapsedtimeinseconds:0.
055DNSTestIfyouspecifythe-verboseoptionsyouwillseealotmoreoutput!
Recentchanges2010-06-21PortedtoOpenWatcom2009-01-18Makeresolvingmorerobustwhenrecursivemodeisturnedoff.
2008-12-30FirstpublicversionFTPclientFTPclientIntroductionThisisanFTPclientlikemanyotherFTPclientsyouhaveprobablyusedbefore.
Featuresincludefairlyhighperformance,lowmemoryrequirements,andcompatibilitywithawideselectionofFTPservers.
Specialhardwareorsoftwarerequirements:NoneUsingFTPFTPusesthefollowingsyntax:ftp[-port]Optionsare:-helpShowahelpmessage-portConnectusingportinsteadofport21YouhavetospecifytheFTPserveraddressonthecommandline.
AfterthecontrolsocketisopenedyouwillbepromptedforauserIDandpassword.
AfterthatyougetacommandlinejustlikeonotherFTPcommandlineclients.
Herearethecommands:dir[]directorylist(fulldetails)ls[]directorylist(namesonly)pagerpauselsordiroutputafterapproximatelynlinescd[]changetoadirectoryontheservercdupmoveuptotheserverparentdirectorypwdprintthecurrentserverdirectorylcd[]changethelocaldirectorylmd[]makealocaldirectorymkdir[]makeadirectoryontheserverrmdir[]removeadirectoryontheserverFTPclientasciichangethefiletransfermodetoASCIIimage,binaryorbinchangethefiletransfermodetobinaryget[]getafilefromtheserverput[]putafileontheserverdeletedeleteafileontheserverprompttogglepromptingformget,mputandmdeleteonoroffmgetgetmultiplefilesmatchingserver_filespecmputputmultiplefilesmatchinglocal_filespecmdeletedeletemultiplefilesmatchingserver_filespecrenamerenameafileontheserverxfermode[]setPORTorPASSIVEtransfermode(seesectionbelow)quotesendarawcommandtotheFTPservertoexecutequitquitthisprogramshellshellouttoDOSinteractiveswitchinputfromascriptfiletothekeyboardTheprogramcapturesCtrl-BreakandCtrl-C.
IfyouuseCtrl-Breakduringafiletransferordirectorylistingthecurrentoperationwillstop(prematurely)andyouwillbereturnedtothecommandlineafterabriefdelay.
IfyouuseCtrl-BreakorCtrl-Catthecommandlinetheprogramwillend.
(Thismighttakeupto20secondsdependingonthestateofthesockets,sopleasebepatient.
)Theshellcommandshouldbeusedwithcare.
Withtheshellcommandyoucandolocaldirectorylistings,renamelocalfiles,lookinsideoffiles,anddomostnormalthings.
KeepinmindthatwhileyouareattheDOScommandpromptthemTCPcodeisnotservicingthesocketconnection-ifyoustayinDOStoolongyoumightloseyourconnectiontotheFTPserver.
TransfermodesThexfermodecommandrequiresalittleexplanation.
InthebeginningoftimeFTPserversalwayssentdatabydoingaconnecttotheFTPclient,whichwaslisteningfortheincomingconnectiononadefaultport.
TheFTPserverinNCSAtelnetdoesthis.
Iwillcallthis'Classic'FTPclientmodeandyoucantellthisFTPclienttohandledatatransfersthisway.
'Classic'modeisonlyusefulforancientFTPserversthatcan'tdoanythingelse.
MostmodernFTPserverswillnotconnecttoanFTPclientonthedefaultportsandmostfirewalls/routerswouldn'tallowitanyway.
'Port'modeisthecurrentdefaultformanyclients.
InsteadofhavingtheFTPserverconnecttotheclientondefaultports,theclientwilltelltheFTPserverexactlywhatportitshouldusefortheconnection.
ThisisslightlybetterthanClassicmode,andshouldbeusableonmoreFTPservers,firewallsandrouters.
'Passive'modeisprobablythebestandmostcompatiblemodetousewithmodernFTPservers.
ItturnsthingsaroundbymakingtheclientconnecttotheFTPservertomakedataconnectionsinsteadofhavingtheFTPserverconnecttotheclient.
(FromthestandpointoftheFTPserveritis'passive'anditwaitsforaconnectionfromtheclient.
)Thiswillworkwithalmostanyfirewallandrouter.
ThisisthemodeI'drecommendusingtoo.
Passiveisthedefaultmodeforthisclient.
DOSfilenamelimitationsAsthisFTPclientrunsunderDOS,itissubjecttoDOSpathandfilenamelimitations.
Whenspecifyingafilenameontheserveryoucanusewhateverfilenamesarelegalfortheserver.
Thismayrequiretheuseofquotingfilenames(seebelow).
WhendealingwithlocalfilesyoumustobeytherulesforDOS.
Forexample,DOSfilenamesmustfitthe8.
3namingconventionandsomecharactersareforbidden.
TheFTPclientwillnottrytocheckandrejectinvalidDOSfilenames;itwilljustletDOSdealwiththem.
Sometimesthisresultsinfilenamesbeingtruncatedtofitthe8.
3format.
OthertimesitmightresultinanerrorandanuncompletedoperationbecauseDOSrefusedtoworkwiththefilename.
PleasebeawareofyourfilenamesandtrynottobreakDOStoobadly.
Oneimportantexception:theFTPclientwillallowyoutouseeitheraforwardslashorabackwardslashasadirectorydelimiterforlocalDOSfilenames.
FilenamesandQuotingDOSdoesnotallowafilenametohaveaspaceinit.
However,youmayfindthatFTPserversrunningrealoperatingsystemsdosupportfilenamesanddirectorynameswithspacesinthem.
FTPsupportsaddingquotesaroundfilenamesanddirectorynamessothatyoucanworkwiththeseservers.
(YoustillhavetoprovidealegalDOSfilenameforreceivingfiles.
)Ifyouneedtospecifyafilenamethathasthedoublequotecharacterinitusetwodoublequotecharactersinarow.
Thiswillresultinonedoublequotecharacterbeingsent.
Ifyouhavetodealwithembeddedspacesatthesametime,addanextrasetofquotestoenclosetheentireparameter.
Examples:FTPclientYouenter:Theserversees:"Spaceyname"Spaceyname(Alloneparm)""QuoteChar"""QuoteChar"(Alloneparm)""QuoteChar""Uhoh.
.
youget"QuoteasoneparmandChar"asthesecondparm.
Thatisbecausethetwosetsofdoublequotescollapseintoasingledoublequote,butdonotdoanythingtomarkitallasoneparameter.
"""QuoteChar""""QuoteChar"(Alloneparm).
Notetheusageofthetriplequotes.
CommandlineeditingIfyouareusingFTPinteractivelyyoucantakeadvantageofthecommandlineeditor.
Itdoesallthatyouwouldexpectittodo:backspace,delete,insert,home,end,etc.
Italsoincludesatenlinecommandbuffersothatyoucanrecalloldercommandseasilywithoutretypingthem.
ScriptingsupportFTPwilltakeinputfromafileredirectedtostdin.
Thisallowsyoutoautomatesomesimpletasks,likeloggingintofetchafile.
Herearesomenotesforusingthissupport:BecauseyouhavetostartFTPwithstdinredirectedfromafile,youwillprobablyhavetoincludeyourlogininformationasthefirsttwolinesofthescriptfile.
FTPwillinterpret"endoffile"as"quit".
Sowhenthescriptends,sodoesFTP.
Ifyoudon'twantFTPtoquitwhenithitstheendofthescriptfile,addthe"interactive"commandtotheendofthefile.
ThiswilltellFTPtostartreadingfromthekeyboardagain.
AdvancedConfigurationParametersThefollowingareoptionalconfigurationsettingsthatyoucanputinyourmTCPconfigurationfile.
SeeSETUP.
TXTforhowtomakechangestothatfile.
FTP_CONNECT_TIMEOUTSetthetimeoutforasocketconnectiontonseconds.
Thedefaulttimeoutis10seconds.
FTP_TCP_BUFFERSetthesizeofbufferusedbyTCPforreceivingdatatonbytes.
Thedefaultis8192bytes.
Forbestperformancethisshouldbesettoamultipleof1024(1KB).
Thedefaultisreasonablecompromisebetweensizeandperformance.
Youcangolowertoconservememoryorupto16384bytestoimproveperformance.
FTPclientFTP_FILE_BUFFERThiscontrolsthesizeofthebufferusedtostoredatawhenreceivingafile.
Thedefaultis8192bytes.
Forbestperformancethisshouldbesettoamultipleof1024bytes.
Thedefaultisareasonablecompromisebetweensizeandperformance.
Themaximumsizeis32768bytes.
FTP_SEND_FILE_BUFFERAsofthisreleasethisconfigurationoptionisignored.
ThevaluesetbyFTP_FILE_BUFFERisusedforbothsendsandreceives.
FTP_MLIST_BUFFERWhenyouuseMGET,MPUTorMDELETEFTPhastofetchalistoffilesfromtheserverorfromyourlocalmachine.
Thisbufferholdsthatlistoffiles.
IfthelistoffilesistoolongtheMGET,MPUTorMDELETEcommandwillfail.
Onesolutionistochangeyourfilespecsothatthelistofbetransferredissmaller,andusemultipleMGETorMPUTStodowhatyouneed.
Theothersolutionistoincreasethisbuffersize.
Thedefaultsizeis4096bytes,whichisplentyformostusage.
Themaximumsizeis16384bytes.
Recentchanges2015-05-29ChangeparsingofPASVresponsestoworkaroundpoorlyconfiguredservers.
2015-02-27Addmdeletecommand;makehelptextmorehelpful.
RemoveseparateSEND_FILE_BUFFERoptiontosimplifysetup.
Removelengthrestrictionsonlocalfilenamestoallowforpathstobespecifiedwithfilenames.
Andsomecodecleanup.
2013-03-28Allowforlargerusercommands;addsomeabilitytohandlepacketswhilewaitingforuserinput;supportscreenslargerthan80x25;Fix125messagehandling.
2011-09-23Makepassivethedefaultxfermode.
Fixasmalldisplaybugwheneditingthecurrentcommand.
2011-01-02Fixhandlingofmulti-lineerrormessages2010-11-27MiscellaneousTCPlibrarychangestoimprovehandlingwhenbuffersarefull.
Addsendingandreceivingrateatendoftransfers.
Watcomruntimeworkaround:improvecompatibilitywitholdermachines.
2010-10-20Addlmdcommand(localmakedirectory).
Addcommandlineeditingwitha10commandrecallbufferFTPserverFTPserverDisclaimerWhileImakenearlyeveryattempttoensurethatmycodeisfreefrombugsandsafetorunonyoursystem,Iamnotperfectandthingscanhappen.
Youareencouragedtotestthiscodeinisolationonamachinethatyoucanaffordtoreinstalltogetcomfortablewithit.
Whilethat'sextreme,it'sprobablytheonlyprudentthingtodowithanynewcode.
Usethis,andanythingelsethatIwriteatyourownrisk.
Itakenoliabilityforanythingthatmighthappentoyou,yourcomputer,yournetwork,house,descendents,pets,etc.
IntroductionThisisanFTPserverforDOS.
Someofthefeaturesincludesupportforpassiveandactiveconnections,supportformultipleusersatthesametime,asandboxmodewhichisusefulforsettingupanonymousFTP,andgoodcompatibilitywithawidevarietyofFTPclients.
Specialhardwareorsoftwarerequirements:TheFTPservercanruninaslittleas190KBifyoujusthaveoneFTPclientconnectingatatime.
Ifyouwanttosupportmultipleconnectedclientsmorememorywillbeneeded.
Beforeyoufireitup.
.
.
SettingupandrunninganFTPserverisalittlemoreinvolvedthanrunningtheothermTCPapplications.
Youneedtoconsideryoursecurityandperformancerequirements.
Securityisespeciallyimportant;anFTPuserwithfullprivilegestoyoursystemcandoseriousdamage,accidentalorotherwise.
QuickStartInstructions1.
ConfiguremTCPandensurethatyouhavebasicnetworkconnectivity.
YoushouldbeabletoruntheothermTCPapplicationsfirst.
2.
AddtheFTPSRV_PASSWORD_FILEandFTPSRV_LOG_FILEconfigurationparameterstothemTCPconfigurationfile.
(FTPSRV_LOG_FILEisoptionalbutrecommended.
)3.
Createaminimalpasswordfile.
(Seetheincludedsamplefile,ftppass.
txt)4.
Run.
YoushouldbeabletousetheFTPserverfrommachinesonyourhomenetworkwithnofurtherconfiguration.
5.
IfyouareplanningonofferinganonymousFTPontheinternetorusingitwithFTPclientsontheothersideofafirewall,readtherestofthisfile.
FTPserverFTPserverbackgroundinformationActiveconnectionsvs.
PassiveconnectionsFTPclientsconnecttoFTPserversonasocketconnectionknownasthecontrolconnection.
Theclientsendscommandsandgetsreturncodesonthecontrolconnection.
FTPserversusuallylistenfornewcontrolconnectionsonport21,althoughothernon-standardportsarepossible.
WhenanFTPclientandserverwishtoexchangedatatheywillopenanewsocketconnectionthatwillbeusedforthatonedatatransfer.
Adatatransferisadirectorylisting,afilesendorafilereceive.
(Yes,evenadirectorylistingrequiresanewsocketconnection.
)Afterthedatatransferisdonethenewsocketisclosed,leavingonlytheoriginalcontrolconnection.
Dataconnectionsarenotusedformorethanonedatatransfer.
Therearetwowaysthenewsocketconnectionfordatacanbecreated.
An"active"connectioniswhentheclienttellstheserverwheretoconnectto,listensonaport,andwaitsfortheservertoopenthenewsocketconnection.
A"passive"connectioniswhentheclientaskstheservertolistenonaportandtheclientopensthenewsocketconnection.
Notethat"active"and"passive"arefromthepointofviewoftheserver.
Intherealworldactiveconnectionsaremoredifficulttosupportbecausemosthomeusersarebehindfirewalls.
Firewallscauseproblemsbecausetheyusuallyarepermissiveaboutlettingmachinesmakeoutgoingconnectionstotherestoftheworldbuttheydonotreadilyletincomingconnectionsin.
Thisisaproblembecausewheninactivemode,anFTPserverwillhavetomakeanewincomingdataconnectionbacktotheclient.
Firewallshavespecialcodetoallowthisincomingconnectionbutitoftendoesn'tworkcorrectlyforavarietyofreasons.
Ontheotherhand,passivemodeconnectionsalmostalwayswork.
IfyourclientwasabletocreatethecontrolconnectiontotheFTPserverinthefirstplace,thenitprobablycancreateotherconnectionstotheFTPserver.
PassivemodeisgenerallypreferredbyFTPclientsbecauseitworkswithawidervarietyoffirewalls.
IfyouhaveafirewallitisprobablyoptimizedtoallowFTPclientsmakeconnectionstotheoutsideworld.
RunninganFTPserverbehindafirewallbecomesaproblembecauseyouneedtoallowincomingconnectionsfromtheoutsideworld.
(We'lltalkaboutthatmorelater.
)UserIDs,AnonymousFTP,andpermissionsAnonymousFTPallowsanybodytoconnecttoanduseyourFTPserver.
Thereisnoauthenticationrequired.
Whileusefulfordistributingdata,anonymousFTPcanbedangerouswhennotconfiguredcorrectly.
InadditiontoanonymousFTPthemTCPFTPserversupportsnamedFTPaccountsthatrequireapasswordbeentered.
Namedaccountsprovidemoresecuritybuttheyarenotfoolproofeither-FTPtransmitspasswordsintheclearandanamedusercanstilldoaccidentaldamagetoyoursystem.
TogiveyousomecontrolandsecuritythemTCPFTPserverhasthefollowingfeatures:Theabilitytolockauserintoaspecificpartofthedirectoryhierarchy.
Thisabilitycanbeusedtocreate"sandboxes"thatcanlimitwhatuserscanseeanddo.
Theabilitytorestrictuploadstoaparticulardirectorywhethertheuserisinasandboxornot.
Theabilitytosetpermissionsforindividualoperationsthatmightbedestructiveinsomeway,suchasFTPserverdelete,makedirectory,removedirectory,rename,andstore(store,storeunique,orappend)files.
mTCPFTPserverdoesnotletyouoverwritefileswhenuploading.
Youmustexplicitlydeleteafilebeforereplacingit.
Itisn'tdifficulttosetuptheserverinasecureway.
Butitdoesrequirealittleplanning.
ConfigurationparametersTherearenocommandlineoptionsthatareusedwhenstartingtheFTPserver;allconfigurationparametersaresetinthemTCPconfigurationfile.
Thefollowingconfigurationparametersarerecognized:Requiredparameters:FTPSRV_PASSWORD_FILEThisshouldbesettoafullpathandfilenameofapasswordfile.
Thepasswordfileformatisexplainedin"Settingupthepasswordfile.
"Optionalparameters:FTPSRV_LOG_FILEThisshouldbesettoafullpathandfilenameofafilethatwillbeusedtologuserconnectionsandfiletransfers.
Thefilewillbeappendedtoeachtimeitisopened.
Ifyoudonotspecifythisoptionthennologgingofuseractivitywillbedone.
FTPSRV_SESSION_TIMEOUTThisconfigurationparameterallowsyoutosettheinactivitytimeoutforFTPsessions.
Thedefaultis180seconds(threeminutes).
Themaximumis7200seconds(twohours).
Thisconfigurationparameterisoptional.
FTPSRV_CONTROL_PORTThestandardportforanFTPservertolistentofornewcontrolconnectionsisport21.
Youmayspecifyanalternateportif21isnotavailableorusable.
AlotofISPswillblockincomingaccesstoport21,sotoacceptconnectionsfromtheoutsideworldyoumayneedtouseahighnumberedportsuchas2021.
Thisisnotstandardsoyouwillneedtomakeitcleartoanypossibleclientwhatthenewportnumberis.
FTPSRV_EXT_IPADDRIfyouarebehindafirewallandyouareacceptingpassiveconnectionsfromtheoutsideworldyouwillneedtousethisoptiontotelltheFTPserverwhatyourexternal(public)IPaddressis.
ThisallowstheFTPservertoputthecorrectconnectioninformationintheresponsetothePASVcommandsentfromtheclient.
Seethesectiononfirewallconsiderationsformoreinformation.
FTPserverFTPSRV_PASV_BASEIfyouareacceptingpassiveconnectionsyoucanusethisoptiontospecifyastartingportnumberforpassivedataconnectionstouse.
Thedefaultstartingportnumberis2048.
Beingabletosetthisvaluemightbehelpfulforconfiguringyourfirewall.
FTPSRV_PASV_PORTSThisoptioncanbeusedtosetthenumberofportsusedforpassivedataconnections.
Thedefaultistouse1024differentports.
Beingabletosetthisvaluemightbehelpfulforconfiguringyourfirewall.
FTPSRV_CLIENTSThisoptionisusedtosetthemaximumnumberofclientsthatcanbeconnectedatonetime.
Thedefaultisthreeclients.
Themaximumnumberofconnectedclientsis10.
FTPSRV_MOTD_FILEThisshouldbesettoafullpathandfilenameofafilethatwillbeusedtogreatnewuserswhentheyfirstlogintotheFTPserver.
ThefileshouldconsistofplainASCIItextwithlinesnolongerthan70characters.
Thetotalfilesizeshouldbenomorethan600bytes.
FTPSRV_FILEBUFFER_SIZEEachconnectedclienthasabufferusedforreadingandwritingfiles.
Thedefaultsizeis8KB.
Youcansetitbetween4KBand16KBin1KBincrements.
Largerbuffersizesperformslightlybetter,butonsmallsystemsthetotalamountofbufferspacecanaddup.
FTPSRV_TCPBUFFER_SIZEEachconnectedclienthasabufferusedforreceivingdataontheTCP/IPdatasocket.
Thedefaultsizeis8KB.
Youcansetitbetween4KBand16KBin1KBincrements.
Largerbuffersizesperformslightlybetter,butonsmallsystemsthetotalamountofbufferspacecanaddup.
Buffersizesbelow8KBmightcauseflowcontrolproblemswithfastersystems.
FTPSRV_PACKETS_PER_POLLThisisanadvancedoptionthatonlymakessenseonsmallersystems.
TheFTPserverchecksthepacketdriverfornewincomingpacketstoprocesseachtimethroughthemainprogramloop.
Themostefficientwaytoprocesspacketsistoscoopupanyavailablepacketsthatmightbeavailableandprocessthemallatthesametime.
Whileefficient,thiscandelaythesendingofoutgoingpacketsforashorttime.
Onslowsystemsthatdelaycancauseflowcontrolproblemswithfastersystems.
ThissettingtellstheFTPserverhowmanypacketstoprocesseachtimethroughthemainprogramloop.
Thedefaultis1,whichissafeforanysystem.
IfyouwanttoexperimentwithlargervaluesforbetterFTPserverperformanceyoucansetitashighas10.
FTPSRV_EXCLUDE_DRIVESThisoptionallowsyoutoexcludespecificdrivelettersfromthescanforvaliddrivelettersthatisdonewhenFTPSRVstarts.
ThisisusefulifyouwantFTPSRVthingslikenetworkdrivesorfloppydrives.
Forexample:FTPSRV_EXCLUDE_DRIVESABwilltellFTPSRVtoignoredrivelettersAandB,makingthemunavailabletouserseveniftheyhavediskettesinthem.
ChoosingthenumberofclientsItdoesn'ttakealotofCPUtohaveaconnectedclient.
Intheoryalowendmachinecanhandlemanyconnectedclients.
Theproblemsstartwhenthoseclientstrytotransferlargeamountsofdata.
Ifyouhavemultipleclientstransferringfilesatthesametimetheclientswillbecompetingwitheachotherforthefollowing:CPUtimeDiskI/ONetworkI/OClientsthatarebrowsingdirectorylistingsarenotaburdenonthesystem.
Clientsthatareactivelytransferringfileswillsplittheseresources.
Dependingonthespeedofyoursystemmultipleactiveclientsmayreducetransferspeedstoanunacceptablelevel.
Atthelowestendofthespectrum,an8088basedPCXTwiththeoriginalMFMharddriveandareasonableEthernetcardshouldbeabletoserviceonefiletransferatarateof30KB/sec.
Multipleclientswillsplitthatbandwidth.
Ahigherendsystemlikea386-40withanIDEharddrivecanserviceonefiletransferataratearound400KB/sec.
Multipleclientssplittingthisbandwidthisobviouslynotasmuchofanissue.
Besidestheavailablebandwidthmemoryrequirementsareanotherconsideration.
Eachconnectedclientrequiresaround11KB.
Ifafiletransferisinprogresstheclientwillrequireanother8KBforthelengthoftimethetransferisinprogress.
Sinceitisunlikelythateveryclientwilltrytotransferafileatthesametime,youcanprobablygetbywithlessthantheworstcasememoryscenario.
Ihaven'tmeasureditprecisely,butyoushouldnotneedmorethan400KBintheworstcase.
SettingupthepasswordfileThelocationofthepasswordfileissetbytheFTPSRV_PASSWORD_FILEconfigurationparameterdescribedin"ConfiguringthemTCPFTPserver.
"ThepasswordfileisusedtodefinewhichusersareallowedtoconnecttotheFTPserverandwhatdirectoriesFTPserverandfunctionstheycanuse.
Thereisoneentryperline.
Entriesareinthefollowingformat:useridpasswordsandbox_directoryincoming_directorypermissionsuseridThiscanbeupto10charactersinlength.
passwordPasswordscanbeupto10charactersinlength.
Youmaychooseanyreasonablemixofcharactersforapassword;onenotableexceptionisthatspacesarenotallowed.
Ifyouusethekeyword"[email]"(withoutthequotes)theFTPserverwillpromptforanemailaddressinsteadofapasswordandwillpermitanyuserinputexceptablankline.
The"[email]"keywordisusedtoimplementanonymousFTP;besuretoread"SettingupAnonymousFTP"beforesettingupanonymousFTP.
FTPpasswordsarealwaystransmitted"intheclear"onthewire,sotheyarenotterriblysecure.
sandbox_directoryIfyouwishtorestrictausertoaspecificdirectory(andallofitssubdirectories)setthisfieldtobethefullyqualifieddriveletterandpathofthedirectory.
Ifyoudonotwantauserrestrictedusethekeyword"[none]"withoutthequotesbutwiththebrackets.
ThedriveandpathformatisnotinthestandardDOSformat.
Theformatusedbytheprogramis:/drive_X/pathwhereXisaDOSdriveletter.
Forexample,D:\FTP\INCOMINGisexpressedas/drive_d/ftp/incoming.
Whenasandboxisinusetheuserwillbeunawarethattheyarebeingrestrictedtoasandbox.
Theywilljustseethedesignateddirectoryasthetopofthedirectoryhierarchy.
Forexample,ifyouspecifyasandboxdirectoryof"/drive_c/ftpdata"theuserwillonlyseethatdirectoryas"/".
TheFTPserverautomaticallyputs"/drive_c/ftpdata"infrontofanyrequests,anditpreventstheuserfromtryingtoescapethesandbox.
Thesandboxmustbespecifiedusingafullpath,includingdriveletter,intheformatdescribedabove.
Ifauserisnotrestrictedtoasandboxtheyarefreetomovetoanydirectoryanddriveletteronthesystem.
Toswitchdrivestheusermustuseapathintheformatdescribedabove.
Forexample,toswitchtodriveE:theuserwouldenter"cd/drive_e/".
ThissyntaxlookslikeastandardUnixpath,whichprovidesthebestcompatibilitywiththewidestrangeofclients.
(PreviousversionsoftheFTPserverusedamoreDOS-likesyntax.
Butcompatibilitywithclientswasanightmare.
Thisworksmuchbetternow.
.
.
-Mike)incoming_directoryIfyouwanttorestrictuploadstoaspecificdirectoryenterthedirectorynamehere.
IftheusertriestoFTPserveruploadafileinadifferentdirectorytherequestwillbedenied.
Iftheuserisalsoinasandboxthentheincomingdirectoryspecifiedhereshouldbearelativepathnamewithinthesandbox.
Forexample,ifthesandboxis"/drive_c/ftpdata"andthisparameteris"/incoming",thenalluploadedfileswillbedepositedin"/drive_c/ftpdata/incoming".
(Theuserwillseeitas"/incoming"duetothewaythesandboxworks.
)Iftheuserisnotinasandboxthentheincomingdirectoryshouldbeanabsolutepathnameincludingadriveletterinthesameformatdescribedin"Sandboxdirectory".
Iftheuserisnottoberestrictedthenusethekeyword"[any]"(withoutthequotes).
permissionsThisfieldisusedtocontrolpermissiontocommandsthatmightalterthefilesystem.
Youcanchoosetograntpermissiontoallcommandsbyusingthe"all"keyword(withoutthequotes).
Ifyoudon'tuse"all"youmustgrantpermissionstoeachcommandindividually.
Thecommandsyoucangrantpermissiontoare:DELEdeleteafileMKDcreateadirectoryRMDremoveadirectoryRNFRrenamefrom(thisisusedtostartafilerename)STORstore(receiveafilefromtheclient)APPEappend(createanewfileorappendtoanexistingfile)STOUstoreunique(receiveafileformtheclient,buttheserverpicksauniquefilename.
)Ifyoudonotgrantpermissiontoacommandtheusercannotuseit.
TheotherFTPcommandsforchangingdirectories,gettingdirectorylists,changingmodes,etc.
arealwaysavailable.
Hereisasamplepasswordfilethatdemonstratesanameduserwithnorestrictions,anameduserwithrestrictionsonuploading,ananonymousaccountwithuploading,andaread-onlyuserwithnouploading:brutmanpassw0rd[none][any]alltesterb0guspw[none]/drive_e/ftp/incomingstorstouanonymous[email]/drive_e/ftp/incomingstorstoureadonly[email]/drive_e/ftp[any]Thefirstuserhasnorestrictionsondirectoriesandpermissiontouseallofthefilesystemalteringcommands.
Thesecondusercanseetheentiresystembutisrestrictedtoonlyuploadinginonedirectory,andtheycanonlyputfiles-theycan'tdelete,createorremovedirectories,orappendtoexistingfiles.
Thethirduserisrestrictedtoonedirectoryanditssubdirectories(asandbox)andmayonlyuploadtoonedirectorywithinthatsandbox.
Thelastusercanonlylookinonedirectoryanditssubdirectories(asandbox)andmaynotupload.
(Ignorethe[any]field,it'sjustholdingaplace.
)SettingupAnonymousFTPSettingupanonymousFTPisfairlyeasybutyoushouldbeawareofthepotentialsecurityproblemsifyoudoitFTPserverwrong.
First,asanoperatingsystemDOShasnorealuserpermissionsystem.
TheFTPservercandoanything,andbyextensionyouruserscandoanythingthattheFTPserverallowsthemto.
Theoperatingsystemdoesnothingtohelpkeepthingssecure.
Ananonymoususeraccountiscreatedwhenyousetthepasswordfieldofauseraccountto"[email]".
Theuseridistraditionallynamed"anonymous"or"ftp",butitcanbeanynameifthepasswordfieldissetto"[email]".
Settingthepasswordfieldto"[email]"turnsoffallpasswordcheckingforthatuserandsimplyrecordswhattheuserentersforthepasswordastheiremailaddress.
Itisabsolutelynecessarytolockanonymoususersintoasandbox.
Ifyoudonot,anonymoususerswillbeabletolookinanydriveandanysubdirectoryonyoursystem.
DependingonhowyousetthepermissionstotheFTPcommands,itwouldbepossibleforananonymoususertotrashyoursystem.
Ifyouplanonlettinganonymoususersuploadyoushoulddesignateadirectorywithinthesandboxthatwillbeusedtoholdalluploadedfiles.
Thatallowsyoutoeasilyidentifyandsortnewfilesinasingleplaceinsteadofhavingthemspreadthroughthesandbox.
TherecommendeduserpermissionsforanonymoususersareSTORandSTOU.
Thisletsthemuploadfileswithauniquenamethattheychoose,orwithauniquenamethattheserverchooses.
mTCPFTPserverwillnotoverwriteanexistingfilesobothSTORandSTOUaresafeforexistingdata.
APPE(append)isnotsafe;itcanalterexistingfiles,soitisnotrecommendedforanonymousFTPusers.
IfyoudonotplanonacceptinguploadsfromanonymoususersthendonotevengivethemSTORandSTOU.
Theywillstillbeabletoretrievefilesfromanywhereinthesandbox.
BelowaresamplelinesthatcanbeusedinthepasswordfiletoimplementanonymousFTP.
anonymous[email]/drive_e/ftpdata/incomingstorstouftp[email]/drive_e/ftpdata/incomingstorstouTheselinesassumethatthee:/ftpdataisthesandboxthattheFTPuserswillbeusing.
Store(STOR)andStoreUnique(STOU)aregranted,andtheuserhastobeinthe/incomingdirectorytouploadfiles.
(Withthesandboxtakenintoaccountthefullpathfortheincomingdirectoryis/drive_e/ftpdata/incoming.
)Twodifferentuserswiththesamesandbox,incomingdirectoryandpermissionsareusedbecauseanonymousFTPusuallyhonorsboth"anonymous"and"ftp"asusernames.
Itispossibletoassigndifferentuserstodifferentsandboxes;thereisnolimitationonthenumberofsandboxesonasystem.
(Thesandboxanduploaddirectoryareaperusersetting.
)Youcanusethistohavedifferentclassesofanonymoususers;perhapsoneclassisnotallowedtoupload,whileasecondandslightlymoreprivilegedclassisallowedtoupload.
DOSfilesystemlimitationsForthoseofyouusedtoUnixormodernWindowssystemsthisisgoingtobeashock.
Hereisthebriefrun-downontheDOSfilesystemandwhatthelimitsare:FTPserverAfullyqualifiedfilenameinDOSlookslikethis:d:\path\filename.
extThemaximumlengthforafullyqualifiedfilenameis78characters.
Thecomponentsare:driveletter2characters(letterplusacolon)path63charactersincludingabeginningandending"\"filename13charactersin8.
3formatTheofficialdirectorydelimiterisalwaysa"\"(backslash).
Validcharactersforafilenameareallletters,numbers,thefollowingpunctuationcharactersandall"highbit"charactersnumberedASCII128andabove.
TherenderingofhighbitcharactersdependsonyouractiveDOScodepage-mTCPFTPserverassignsnomeaningtothematall.
Ifyourusertriestouseaninvalidpathorfilenametheirrequestwillberejected.
GentlyremindthemthattheyareonDOS,andthat8.
3isn'tjustapainintherear,it'sthelaw.
TokeepcompatibilitywiththelargestnumberofFTPclientstheFTPserverdoesn'tshowDOSstyledrivelettersandpathstoconnectedusers.
Itrewritesthedriveletterparttolooklike/drive_X/whereXisthedriveletterandthepathdelimitersuseforwardslashes,notbackslashes.
TheFTPserveralsopresentstheimageofarootfiledirectory'/'wherethesubdirectoriesaretheavailabledriveletters.
Aconnectedusermustuseafullpath(in/drive_x/path/form)tochangedirectories.
Ifarelativepathisuseditisrelativetothecurrentdriveletterandpathforthatuser.
UsingmTCPFTPserverwithafirewallIfyouplanonallowinguserstouseyourFTPserverthroughafirewall,readon.
IfyouarenotallowingaccessfrompeopleoutsideofyourLANyoucanskipthissection.
MostfirewallsaredesignedwiththeneedsofFTPclientsinmind.
Nowyouwillberunningaserver,wherethingsdon'tworksowell.
ChoosingacontrolporttolistenonIfyourISPallowsitusethestandardFTPport(21).
IfyourISPdoesnotallowitoryouwanttoimproveyoursecurityslightlychooseanalternateport.
ISPsgenerallydon'tblockportsnumbered1024andhigher.
Whileitworks,non-standardportsarenotasconvenientforyourclientstouse.
(Youruserswillhavetofindawaytospecifythenewportnumberintheirclient.
)SetupyourfirewalltoforwardthecontrolportMostfirewallsblockincomingconnectionsfromtheinternet.
Thismakessense,asyourpersonalmachinesbehindthefirewallwillmakewhateveroutgoingconnectionstheyneed.
Thisdoesn'tworkwhenyourunaserverthough.
YouhavetobeabletoallowincomingconnectionsfromtheoutsideworldtogettoyourFTPserver.
FTPserverMostfirewallsallowyoutospecifywhereincomingconnectionsfromtheoutsideworldshouldbeforwardedto.
Theforwardingisdonebasedonportnumbers.
SetupyourfirewalltoforwardincomingconnectionsonyourchosencontrolporttothemachinerunningtheFTPserver.
SetupyourfirewalltoforwarddataportsClientsconnectingtoyourFTPserverfromtheoutsideworldareprobablybehindfirewallsthatalsodonotallowforincomingconnections.
Theywillprobablyneedtousepassivemodefordataconnections,whichmeansthattheyexpecttomakeincomingconnectionstoyourFTPserver.
BydefaultmTCPFTPserverwilluseports2048through3071fordataconnections.
(Thestartingportnumberandthenumberofportstousecanbeconfiguredifthedefaultsarenotsuitable.
)YouwillneedtoconfigureyourfirewalltopassalloftheseportnumbersthroughtotheFTPserver.
TellmTCPFTPserveryourpublicIPaddressIfyouarebehindafirewallyouareprobablyusingaprivate,non-routableaddressassignedbyyourfirewall.
ThisaddresswasobtainedusingDHCPorconfiguredbyhand.
ThefirewallisresponsiblefortranslatingincomingandoutgoingIPpacketsbetweentheprivatenon-routableaddressesandthepublicaddressassignedbyyourISP.
Thismappingiscalled"NetworkAddressTranslation"anditisnormallytransparenttoyou.
ThereisasnagwhenrunninganFTPserver;whenaclientrequestsapassiveconnectionforadatatransfertheserverwillrespondwithanIPaddressandportthattheclientshouldconnectto.
TheFTPserverknowsitsIPaddress,whichisthelocalnon-routableaddressonyourhomenetwork.
Withoutanyinterventionthatistheaddressitwillgivetotheconnectedclientrequestingapassivemodeconnection.
Clearlythataddressiswrongforanexternalclient.
TogetaroundthisyoucanusetheFTPSRV_EXT_IPADDRconfigurationparametertotellmTCPFTPserverwhataddressitshouldsendtoclientsinsteadoftheprivate,non-routableaddressthatitknows.
TheaddresstouseisthepublicaddressthatyourISPhasassignedtoyourfirewall/cablemodem/DSLmodem.
AcommercialgradefirewallwillmodifytheFTPserverpassiveresponseautomatically,buthomegradefirewallswillnot.
Whenaserverisrunningonanon-standardportalmostnofirewallswillbeabletofixtheproblem.
FTPSRV_EXT_IPADDRgivesyouaworkaround.
mTCPFTPserverissmartenoughtoknowifaclientisonthesameinternalLANasitis,oriftheclientiscomingfromadifferentLAN.
IftheclientisonthesameLANastheserverthenthepassivecommandresponsewillusethelocalnon-routableprivateaddress.
Thatwayyourlocalmachinescanusepassivemodeconnectionstoo.
Starting,runningandendingtheFTPserverThisassumesthatyourpacketdriverisloadedandthatthebasicworktosetupmTCPisdone.
(YoushouldhavetheMTCPCFGenvironmentvariablepointingatavalidmTCPconfigurationfile,andyoushouldhavetestedyournetworkconnectivity.
)FTPserverStartingTorunftpsrv,justgotothedirectorywhereitislocatedandrunit.
FtpsrvwillreadthemTCPconfigurationfile,andthenscanthepasswordfile.
Ifalllooksgoodanditcangetthememorythatitneeds,itwillstartrunning.
Ifanythingfailsyoushouldgetanerrormessagethattellsyouwhatiswrong.
Thethreemostcommonreasonsforittofailare:ThemTCPconfigurationfilecannotbefoundorisnotcorrect.
Thepasswordfilehasanerrorinit.
Notallerrorswillbespotted,butithastolooklikeareasonablepasswordfile.
Youdon'thaveenoughmemoryavailable.
IfmTCPstartsrunningitwillgiveyouasetofmessages,andthenitwillstarttousethescreentologevents.
Eventswillalsobewrittentoalogfileondiskspecifiedbytheconfigurationfile,ifdesired.
Successfulstart-upwilllooksomethinglikethis:mTCPFtpSrvbyMBrutman(mbbrutman@gmail.
com)(C)opyright2009-2015Version:Sep282011Openingpasswordfileate:\ftppass.
txtPasswordfilelooksreasonable.
mTCPFtpSrvversion(Sep282011)startingClients:10,Clientfilebuffersize:8192,TCPbuffersize:8192Packetsperpoll:1,TCPsockets:21,Sendbuffs:35,Recvbuffs:40Clientsessiontimeout:120secondsControlport:21,Pasvports:2048-3071RealIPaddress:192.
168.
2.
100,PasvresponseIPaddr:8.
8.
8.
8Press[Ctrl-C]or[Alt-X]toendtheserverThePasvresponseIPaddressandotherparameterswillbedifferentforyourmachineandconfiguration.
Thetoplineofthescreenhasasmallstatuslinethatshowsyouthetotalnumberofconnectionsandthenumberofactivesessions.
Therestofthescreenisusedforlogmessages.
Atthispointyourserverisreadyforincomingconnections.
RunningThefollowingkeysarerecognizedontheconsole:Alt-BTogglethebeeperthatsignalswhenuserssignonAlt-HHelpAlt-SShowstatisticsAlt-XExitThereisnotmuchtodowhiletheserverisrunning.
IwouldturnoffthemonitorandcheckonitonceinawhilebyconnectingtoitwithanFTPcommandandusingtheSITESTATSorSITEWHOcommand.
FTPserverIfyouareacceptinguploadedfilesyoushouldcheckfornewfilesandprocessthemonceinawhile.
Youcandothisbydownloadingthefilestoanothermachine,examiningthem,andtheneithermovingthemusingtherenamecommandordeletingthemfromtheserver.
Youshouldhavearoughideaofhowmuchfreespaceyoustartedwith;fileuploadswillfailifyourunoutofdiskspace.
YoucanchecktheamountofavailablediskspacewiththeSITEDISKFREEcommand.
WithfiveorlessclientsconfiguredthemTCPFTPallocatedenoughTCP/IPsocketstocovereverypossiblecombinationofconnections.
Afterfiveusersitisassumedthatnoteveryclientwilltrytodoadatatransferatthesametime,sotheworstcasenumberofTCP/IPsocketsarenotcreated.
Ifbysomefreakaccidenteveryconnectedclientdoestrytodoapassivemodedataconnectionatthesametimesomeofthemmightfail-thefailurewillbetemporaryandtheywillbeabletotryagain.
Ifmorepeopletrytoconnectthanthereareconfiguredclientseachnewconnectionwillgeta"421-pleasetryagainlater"message.
Thedefaulttimeoutperiodforaninactivesessionisthreeminutes.
Youcansetitaslowasoneminuteorashighas10minutes.
Aninactiveusershouldbedisconnectedwithin10secondsafterexceedingthelimit.
EndingToendtheserverhitCtrl-Catthekeyboard.
Ctrl-Cwillberecognizedwithinasecond,anditwilltakeupto10secondstocloseallofthecurrentdataconnections.
NotesonspecificFTPclientsTheFTPserverpresentstheillusionofaUnixfilesystemtoconnectedclients,evenwhileallowinguserstoswitchdriveletters.
HidingthefactthatitisrunningunderDOSkeepstheclientsfromgettingconfused.
Asaresult,thereshouldbeveryfewclientspecificproblems.
SomeclientssendaLISTcommandassumingthatthereisaUnixsystemrunning/bin/lsontheotherend.
TheysendoptionswiththeLISTcommandthataresupposedtobeinterpretedby/bin/ls,butlooklikeavalidDOSfilename.
(Hint:A'-'characterisvalidasthefirstletterofaDOSfilename.
)TheFTPstandarddoesnothaveamechanismforsendingoptionsonaLISTcommandsotheseclientsaretechnicallybroken.
PreviousversionsofFTPserverdidnothandletheseoptionsandthusitlookedlikeclientscouldnotgetdirectorylistings.
Thisversionignoresthoseoptions,whichshouldimprovecompatibilitywiththoseclients.
WhenrunningonaslowmachineitispossiblethatfasterclientswillfloodtheTCP/IPsocket,causingtheTCP/IPflowcontrolmechanismstokickin.
Sometimestheykickintoohardandmakefileuploadsveryunpredictable.
IfthishappensyoucanincreasethefilebufferandTCPreceivebuffersizesused,andifyourclientsupportsitthrottletherateatwhichitsendsdata.
(FileZillaisoneclientthatcandothis.
)ThestandardcommandlineWindowsXPFTPclientdoesnotsupportpassivemodedataconnections.
Onaninternalnetworkthisisnotaproblem,butifthereisafirewallbetweenyouandtheWindowsXPmachineitwillbenearlyworthless.
Getabetterclient.
InternetExplorer,FirefoxandChromeworkwellagainstmTCPFTPserverwhenanFTPURLisusedtoaccessFTPservertheserver.
CommandlineLinuxclientshavenoknownproblems.
AndofcoursethemTCPFTPclienthasnoknownproblems.
;-0Recentchanges2015-05-29Changethelogfiletobeoptionalinsteadofrequired2013-02-13EnabletheSIZEcommand;makeFTPSRV132colaware2012-12-23IgnoreUNIXstyle/bin/lsoptionsonLISTandNLST2012-04-29Reducememoryutilization;addoptiontoexcludedrives2011-09-28Rewritedriveletterhandling;fixMDTMcommand;rewritescreenhandling;addadditionalconfigurationparameters;scanforvaliddrivelettersatstart-up;addoptionalMOTDfile;miscbugfixes2011-05-18Fixparsingerroronpasswordfile2011-04-06ChangeDOSpathdelimiterhandlingtomakeFileZillahappy2011-01-02FirstreleasedversionFTPserverImplementedRAWFTPcommandsUSERSetuser(onlyvalidduringinitialloginsequence)PASSSendpassword(onlyvalidduringinitialloginsequence)RNFRrenamefrom(originalfilename)RNTOrenameto(newfilename)DELEdeletefileCWD/XCWDchangedirectoryCDUP/XCUPmove"up"onedirectoryinthehierarchyPWD/XPWDprintworkingdirectoryMKD/XPWDmakedirectoryRMD/XRMDremovedirectoryPASVrequestpassivemodePORTusePORTmodeABORabortcurrentdatatransferLISTdirectorylistNLSTnamelistRETRretrieve(sendfiletoclient)STORstore(receivefilefromclient)STOUstoreunique(receivefile,butserverchoosesauniquename)APPEappendtoexistingfile(orcreateanewfile)MODEsettransfermode(onlystreamissupported)STRUstructure(onlyfileissupported)TYPEstructure(onlyfileissupported)SIZEgetthefilesizeofafile(BINARYmodeonly)HELPhelpALLOallocate(obsolete,butnotanerror)FEATfeaturenegotiation;willrespondwithMDTMMDTMmodificationtypeNOOPdonothingsuccessfullySTATgiveserverstatusordoadirlistingoverthecontrolsocketSYSTidentifysystemtype(respondswith"215DOSType:L8")SITEdoSITEspecificcommandsREINre-initialize(notsupported)ACCTaccount(notsupported)RESTrestartposition(notsupported)SITEcommands:SITEDISKFREEshowfreediskspaceforagivendriveletterSITEHELPgivehelpfortheSITEcommandSITESTATSrespondwithsomefunstatisticsSITEWHOshowwhoisonlineHTGetHTGetIntroductionHTGetisasmallutilitythatcanfetchfilesservedfromHTTPservers.
ItusesHTTP1.
1whichisthecurrentHTTPprotocolthatenablesusewithvirtualhosts.
HTTP1.
0issupportedforcompatibilitywitholderHTTPservers.
HTGetwasinspiredbyaversionwrittenbyKenYap(ken@syd.
dit.
csiro.
au)in1997fortheWATTCPstack.
Thisversionisacompleterewriteusingsomeoftheconceptsfromtheoriginal.
Specialhardwareorsoftwarerequirements:NoneUsingHTGetUsageislikethis:htget[options]Optionsare:-hShowshelptext-vPrintextrastatusmessages-headersFetchonlytheHTTPheaders-mFetchfileonlyifmodifiedafter'sdate-oWritecontenttoinsteadofstdout-passSendauthorization-10UseHTTP1.
0protocol-11UseHTTP1.
1protocol(default)TheURLformatis:http://yourservernamehere[:port]/pathTheportparameterisoptional-ifitisnotspecifiedthedefaultisport80.
AuthenticationinformationisnotincludedintheURLsyntax;thisisslightlynonstandardbutitmakesthecodesimpler.
(Seethedescriptionofthe-passoptionbelowfordetailsonhowauthenticationissupported.
)WhenyourunHTGetitwillattempttoconnecttotheHTTPserver,sendheaders,andreceivecontent.
IfyoudonotgiveanyoptionsthedownloadedcontentissenttoSTDOUT.
YoucanredirectSTDOUTtoafileorusethe-ooptiontospecifyafilenameforHTGettowritetodirectly.
Using-vgivesyouextramessagesthattellyouhowthedatatransferisprogressing.
TheextraoutputissenttoSTDERRtoavoidinterferingwiththecontentthatisbeingsettoSTDOUT.
HTGetThe-moptionchecksthemodificationdateofthefilethatwasspecifiedwiththe-ooptionandsendsthatdatetotheserverduringtherequestphase.
Ifthecontentontheserverhasnotbeenupdatedsincethetimestamponthelocalfiletheserverwillreturna"304"statuscodeandnocontent.
Ifthecontentontheserverhasbeenupdatedyouwillgetthenewcontentinstead.
Thisoptionisusefulforwhenyouonlywanttoupdateafilebasedonifithasbeenupdatedontheserver.
TouseityoushouldhavetheTZenvironmentvariableset.
(SeeSNTP.
TXTfornotesonhowtousetheTZenvironmentvariable.
)Ifthecontentyouarerequestingispasswordprotectedtryusingthe-passoption.
The-passoptiontakesastringintheformofusername:passwordandencodesitusingBASE64beforesendingittotheHTTPserver.
Theauthenticationtypeisknownas"BASIC"-itisnotsecurebutitiswidelysupported.
IftheHTTPserverrequiressomethingmoresecurethenthisoptionprobablywillnotwork.
ThecurrentHTTPprotocolversionnumberis1.
1whichiswhatthisprogramisusing.
Thebigimprovementthatversion1.
1addsissupportforvirtualhosts,whichareHTTPserversthatsharethesameIPaddress.
SincethisprogramisdesignedtorunonvintagecomputersitisquitepossiblethatyoumightrunintoavintagewebserverusingHTTP1.
0.
TheseolderserversmightnotunderstandtheheadersusedbyHTTP1.
1;ifthathappenstherequestwillfail.
Tryusingthe-10optiontoforcetheprogramtofallbacktoHTTP1.
0ifyoususpectyouhaveanancientserverthatisconfusedbyHTTP1.
1.
Examples:htget-ogoogle.
htmhttp://www.
google.
com/ThisdownloadstheGooglesearchpageandwritesittogoogle.
htm.
htget-m-ogoogle.
htmhttp://www.
google.
com/Thisdoesthesamethingasabove,butifthecopyontheserverhasnotchangedsincethelocalcopywaswrittenitwillnotbedownloadedandrewritten.
htget-passjohn:secrethttp://someserver.
com/protected/secret.
fileThisgrabsthepasswordprotectedfile"secret.
file"using"john"astheuseridand"secret"asthepassword.
TheuseridandpasswordgetconvertedtoBASE64beforebeingsenttotheserver.
IftheserversupportsHTTPBASICauthenticationyouwillgetthefile.
htget-10http://yeancient.
server.
net/readme.
txtForceHTTP1.
0modeforaprehistoricserverthatdoesnotuseHTTP1.
1.
htget-headershttp://www.
google.
com/Don'tgetthecontent-justlookattheheadersthatwouldhavebeensent.
Whentheserversendscontent.
.
.
Theservercansendcontentevenwhentheserverreportsabadreturncode.
ThecontentmightbeapagethatHTGetdescribestheerrorandtellsyouwhattodo.
HTGetwillnotwriteoutputifthereisasocketerrororifthefilehasnotbeenmodifiedandyouusethe-mswitch.
ButduetothewayHTTPworks,itwillwritedataifitisgivencontent,evenifthecontentisanerrormessage.
Sodon'toverwriteanythingimportantassumingthattheserverwillgiveyouafreshcopy-itmightgetreplacedwithanerrormessage.
ReturncodesTheHTTPserveralwaysreturnsaresultcodewhichcanbeusedtotellyouiftherequestwassuccessful.
Unfortunately,therangeofpossiblereturncodesfromtheHTTPserverisgreaterthanwhatcanbeexpressedinaprogramexitcodesoHTTPreturncodescannotbeusedasexitcodesdirectly.
Itisvaluabletobeabletodetermineifarequestwassuccessfulornotusingaprograminsteadofhavingahumanmakethedecision.
TomakethiseasierHTGetmapsHTTPresponsecodestoasmallersetofreturncodes.
Herearesomeofthemappings:0Nosocketerrors,butunknownHTTPcode(shouldneverhappen)1Socketorprotocolerror10HTTPresponsecodefrom100to19920HTTPresponsecodefrom200to299ifnotshownbelow21200OK24203Non-AuthoritativeInformation30HTTPresponsecodefrom300to399ifnotshownbelow32301MovedPermanently35304NotModified37307TemporaryRedirect40HTTPresponsecodefrom400to499ifnotshownbelow41400BadRequest42401Unauthorized43403Forbidden44404NotFound45410Gone50HTTPresponsecodefrom500to599ifnotshownbelow51500InternalServerError53503ServiceUnavailable54505HTTPVersionNotSupported55509BandwidthLimitExceededHTGetThegeneralideaistogivethecommonresponsecodesauniquereturncodeandcompresstherestintoagenericreturncodes.
Foracompletelistofthemappingsrefertothesourcecode.
DifferenceswiththeoriginalWATTCPHTGetAsmentionedearlier,thisisacompleterewriteoftheoriginalHTGet.
Afewvariablenamessurvived-notmuchelse.
Herearethemajordifferences:HTTP1.
1requestsupportwithaswitchtouseHTTP1.
0ifnecessaryTheabilitytohitCtrl-Break,Ctrl-CorESCtoabortatransferFarbetterperformanceduetobetterbufferhandling.
Returncodesthattrytogiveabetterindicationofwhathappened.
ThisversionusesmTCP:-)Recentchanges2011-07-17InitialversionHTTPServHTTPServIntroductionHTTPServisasmallHTTP(web)serverdesignedforearlyIBMPCsandsimilarmachines.
Featuresinclude:HTTP/0.
9,HTTP/1.
0andHTTP/1.
1supportHTTP/1.
0andHTTP/1.
1persistentconnectionsHTTP/1.
1requestpipeliningsupportUpto8simultaneousrequestscanbeservicedwithupto8morequeuedAbilitytoimproveperformancebyservingpre-compressedcontentEasymappingofincominglongURLpathcomponentstoDOS8.
3filenamesHTTPBasicAuthenticationImprovedperformancethroughcachingofdirectoriesandHTACCESSfilesOptionalserverstatuspageCachingofselectedfilesinRAMLoggingHTTPServisnotareplacementforamodernHTTPserverbutifyouarelookingforaneasywaytomakethefilesonanoldmachinebrowsablefrommodernmachinethenitshouldworkwellforyou.
Andifyouareahardcoreretro-computingenthusiast,youcanprobablyserveyourstaticHTMLpagesdirectlyfromanoldmachine.
Specialhardwareorsoftwarerequirements:Morememory:Atleast256KBavailablememory,512KBormoreisrecommendedAmassstoragedevice;servingfromfloppieswillworkbutyouaregoingtohaveabadtime.
HTTPServneedsmorememorythanmostmTCPapplicationsbecauseitisassumedthatitshouldtrytohandlemultiplerequestsfromconnectedclientsatthesametimeinsteadofjustqueuingtherequestsandmakingtheconnectedclientswaituntilitistheirturn.
Youcanuseconfigurationoptionstoreducememoryrequirementsatthecostofsomeperformanceandreducedfunction.
UnlessyouhaveverylittlecontenttoserveryouwillneedamassstoragedevicesuchasaharddriveoraZipdrive.
Thefasterthedeviceis,thebetter–itisassumedthatmostoftheobjectsbeingservedwillbeservedfromdiskstorageandwillnotbecachedinmemory.
Onolder8088classmachinessomeversionsofDOSareextremelyslowtocalculatethefreespaceontheharddrive.
ThiscanleadtolongpauseswhereHTTPServisunabletodoanywork,possiblycausingTCP/IPerrors.
DOS5andlaterversionsseemtobeaffectedthemost.
FortheseslowermachinesDOS3.
3isrecommended.
UsingHTTPServTheHTTPServcommandlinelookslikethis:HTTPServhttpserv[options]Optionsare:-helpShowshelpforthecommandline-clientsSetthenumberofconcurrentclientssupported(default=8)-dir_indexesEnablegeneratingdirectorylistings(defaultisnotto)-doc_rootSetdirasthedocumentroot-portUseportnforincomingrequests(defaultisport80)Althoughcommandlineoptionsareprovided,theconfigurationoptionsinthemTCPconfigurationfileshouldbeusedinstead.
Commandlineoptionsaretreatedasatemporaryoverrideforanythingfoundintheconfigurationfile.
ThisallowsyoutodoquicktestsorrunHTTPServforquickfiletransferswithoutalteringyournormalconfigurationoptionsintheconfigurationfile.
Foramoredetaileddiscussionoftheseoptionsseetheircorrespondingconfigurationfileoptionsinthe"Configurationoptions"section.
ConsolemessagesandcontrolsTheHTTPServconsoleisdesignedtoshowyouwhatisgoingonatthemoment.
Ataglanceyoucanseethetotalnumberofconnectionsserved,thetotalnumberofobjectsserved,andthecurrentnumberofactiveconnections.
Recentrequestsanderrormessagesareshownonthescreen.
Thefollowingkeycombinationscanbeused:HTTPServAlt-HShowhelptextAlt-BTogglebeepingonandoffAlt-VSettheverbositylevelAlt-XShutdowntheserverThestateofthebeeperandtheverbositylevelareshownonthesecondlineofthescreen.
Thedefaultverbositylevelis1,whichgivesyouanoverviewofwhateachrequestisandwhatthereturncodewas.
Atverbosityleveltwoyoucanseesomeoftheadditionalfieldsfromtherequest,includingtheuser-agentandreferer.
Verbositylevel3includesdebugmessageswhichareprobablynotveryinteresting.
Allmessagesfromtheserverareloggedtothelogfile;theverbosityleveljustdetermineswhatgetsshownonthescreen.
(Well,almost.
Debugmessagesdonotgetloggedunlessyouarealsoshowingthemonthescreen.
)ServingstaticcontentLikeonotherservers,thecontentthatyouwanttoserveislocatedunderadirectorycalledthedocumentroot.
OnHTTPServyoucansetthedocumentrootusingthecommandlineorintheconfigurationfile.
AllURLsservedbyHTTPServarerelativetothedocumentroot.
Remember,youareonaDOSmachinesotherearesomelimitsyouhavetoobserve:DOSfilenamesandsubdirectorieshavetousethe8.
3filename.
extformat.
DOSfilenamesarenotcasesensitive.
DOSdosnotlikefilenamesthatcontainspecialcharacters,likespacesServingcontentisafairlystraightforwardprocess.
TheURLshouldidentifyadirectoryorfilenamerelativetothedocumentroot.
Juststartatthedocumentroot,openthedirectoryorfilenamespecifiedbytheURL,andsendthebytesoverthesocket.
IftheURLdoesnotexistsendbackanerrormessageinstead.
Inrealityservingismorecomplex,butthisisthebasicidea.
IfyouaredesigningcontentfromscratchthenallofthelinkswithinyourcontentthatareonthesameserverwillfollowtheDOSfilenameconventions.
Thiscanmakethelinkslookalittlegoofybecausetheywillbetersecomparedtootherwebsites,butitworks.
IfyouwanttouseURLsthatlookmorelikenormalURLsHTTPServhasatrickyoucanuse.
YourfilesstillhavetomeettheDOS8.
3namingrequirementbutyoucandefinelongeraliasesthatmaptothefiles.
Thatallowsyouuseuselinkslike"http://servername/ThisIsALongSubdir/MyContent.
html"insteadof"http://servername/long.
sub/mcontent.
htm".
Themagichappenseachtimearequestcomesin;thepartsoftheURLareparsedandoptionalmappingsfromlongnamestoshortDOS8.
3filenamesareconsulted.
IfamappingexiststheserversubstitutesintheproperDOS8.
3filenameautomatically.
Tousethisfeaturepleaseseethe"Map"directiveintheHTACCESSfilesappendix.
UsingHTACCESSfilescanslowthingsdownandtheyrequiremorememory,butwhenusedcorrectlytheperformanceandmemorycostsareminimal.
ThisfeaturealsomakesiteasiertomoveexistingcontenttoaDOSmachineforservingwithouthavingtorewriteallofthelinkswithinthecontent.
HTTPServServingprecompressedstaticcontentSendingdataoveranetworkrequiresbothnetworkbandwidthandCPUusage.
TheCPUusagetosendandreceivedataisroughlyproportionaltotheamountofdatabeingsent.
CompressingdatabeforesendingitrequiresadditionalCPUusageforthecompressionstepbutitcanresultinlessCPUusedduringthetransmitstageandlessnetworkbandwidthrequired.
DependingonyournetworkconnectionandCPUspeed,compressingcontentbeforesendingitcanmakesense.
ModernHTTPserversusuallychoosetocompresscontentbecausetheirCPUsaresopowerfulandpreservingnetworkbandwidthismoreimportant.
HTTPServcannotcompresscontenton-the-flyyet,butitcanservecompressedcontentifyouprepareitaheadoftime.
AnycontentthatyouchoosetocompresscanbestoredondiskinadirectorytreethatparallelstheHTTPDocsdirectoryhierarchy.
ThisparalleldirectorytreeisknownasHTTPZips.
AtruntimewhenaclientmakesarequestHTTPServwillsearchthenormaldocumentroot(HTTPDocs)forthefiletheuserrequested.
IftheclientindicatesthatitcanacceptGZIPedcontentHTTPServwillthencheckHTTPZipsforacompressedversionofthefile.
Ifacompressedversionofthefileisfounditwillbesentinsteadofthestandardversionofthefile.
Ifnocompressedversionisfound,thestandardversionofthefileissentinstead.
HTTPServexpectsthedirectoryhierarchyinHTTPZipstobethesameasitisinHTTPDocs.
Itwilllookforthecompressedversionofthefileusingthesamepath,substitutingyourHTTPZipsdirectoryforyourHTTPDocsdirectorywhenlookingforcompressedcontent.
Ifthecompressedfileisnotinthesamerelativeplaceitwillnotbefound.
(Note:HTACCESSfilescanbeusedtoalterhowURLsaremappedtodirectories.
Servingcompressedcontentdoesnotchangethis;theHTACCESSfilesinthethenormaldocumentrootarestillused.
TheonlychangethathappensisthatinsteadofreadingthefinaltargetoutofHTTPDocsHTTPZipswillbetriedinstead.
)HTTPServalsohasnoideaifthecompressedversionofafileisequivalenttothestandardversionofthefile.
Youneedtomakesurethatthetwostayinsync;ifyouupdateafileinHTTPDocsthenyoushouldupdatedthecompressedversioninHTTPZipsordeleteituntilyoucanupdateit.
Tomakecompressedcontentavailablefollowthesehigh-levelsteps:CreateanHTTPZipsdirectoryandsubdirectoriesunderitthatmirrorsyourHTTPDocsdirectoryhierarchy.
Gzipfilesthatwillcompresseasily;humanreadabletextfilesaregoodcandidates.
JPG,ZIParchives,andotherfilesthatarealreadycompressedwillnotbenefitfromfurthercompression.
DOSfilenamesarelimitedtothestandard8.
3format.
Conventionstatesthatgzip'edfilesshouldhavea".
gz"suffixonthem,butthatisnotpossibleinDOS.
ThatiswhyHTTPZipsisaseparateparalleldirectoryhierarchy-itisassumedthateverythinglocatedinHTTPZipshasa".
gz"suffixonit.
Pre-compressingthecontentrequiresadditionaldiskspaceandsomeextrafilemanagement.
ButifyouhavethespaceIrecommenddoingit;itcutsdownontheamountofCPUtimerequiredforrequeststhatcanbeservedfromthecompressedcopies,givingtheclientsfasterresponsetimeandlettingyouservemorepotentialclients.
TheuseofHTTPZIPSiscompletelyoptional.
IfyouareonlyanoccasionaluserofHTTPServthenitprobablyHTTPServisnotworththeextrawork.
ProtectingfilesanddirectoriesHTTPServsupportsHTTPBasicAccessAuthentication.
With"basicauth"therearenocookies,sessionsorloginpages.
Buttherereallyisnosecurityeither;theuserIDandpasswordistransmittedbythewebbrowserbasically"intheclear.
"Thismeansthatbasicauthisbestsuitedtothingsthatyouwanttolightlyrestrictaccesstoo,butnothingthatwouldbeharmfulifitweremorewidelyavailable.
Toprotectafileusingbasicauthyoumarkthefileasbelongingtoarealm.
Arealmisatag(oftenadescription)thatallowsyoutologicallygroupfilesthatneedprotectiontogether.
Eachrealmhasapasswordandalistofusersassociatedwithit.
WhenauserrequestsaccesstoaprotectedfileachallengeissentbackaskingforauserIDandpassword.
Thechallengegenerallyappearsasadialogboxonthewebbrowserwithamessagethatincludestherealmthefileispartof.
TheuserthenentersauserIDandpasswordandthebrowserretriestherequest,sendingtheinformationalonginanadditionalHTTPheader.
IftheentereduserIDandpasswordarecorrectfortherealmtheuserisgrantedpermissiontoviewthecontent.
WebbrowsersoftencachetheentereduserIDandpasswordforafewminutes.
IftheusertriestoaccessanotherfileprotectedbythesamerealmthecachingallowsthewebbrowsertoretrytherequestwithoutpromptingtheuserfortheuserIDandpasswordagain.
(Iftherealmdifferentornotinthecachethentheuserwillgetthedialogbox.
)Filesanddirectoriesmarkedwithaparticularrealmdonotneedtobelocatedneareachother;realmisatagthatcanbeappliedwhereveritisneeded.
HTTPServletsyouprotectafileoradirectoryusingtheFileAuthdirectiveintheHTACCESS.
---filewherethefileordirectoryresides.
Oneveryimportantthingtobeawareofisthatifyoumarkadirectoryasbeingprotected,itisassumedthatiftheusergetstheuserIDandpasswordcorrectthateverythingunderthatdirectory(filesandsubdirectories)isalsoavailable.
Thisistrueevenifthosefilesanddirectorieshavedifferentprotectionspecified-thatprotectionisignoredbecausetheuserhasbeengrantedaccessatahigherlevel.
Thisisashortcomingofbasicauth-onlyoneauthorizationheadercanbesentforarequestsoitisnotpossibletoprovidelayersofprotectionforfilesanddirectoriesalongaURIpath.
Realmsaredefinedinatextfilethatyouprovide.
TheHTTPSERV_REALMSconfigurationdirectiveinthemTCPconfigurationfiletellsHTTPServwheretoreadthefile.
Eachlineintherealmsfiledefinesarealm,thepasswordandalistofusersauthorizedtotherealm.
BelowisasampleREALMS.
TXTfile:InyourmTCPconfiguration:HTTPSERV_REALMSe:\realms.
txtIne:\realms.
txt:"Serverfunctions"s3cr3troot"RestrictedFiles"passw0rdbrutmaneddie"RestrictedDirs"pfft123brutmanwarezanonInthisexamplethreedifferentrealmsaredeclared.
TherealmshavespacesintheirnamessotheyareHTTPServsurroundedbyquotestoindicatethatbothwordsarepartoftherealmname.
Nextcomesthepasswordandaftercomesalistofusersthatarevalidfortherealm.
Allfieldsaredelimitedbyspacesandhavethefollowinglengthrestrictions:realmname:Upto50characters(notincludingquotes)passwords:Upto12charactersuserids:Upto16charactersThelengthofeachlineislimitedsodon'tgooverboard.
(Asofthiswritingthemaximumlinelengthis255bytes.
)DonotlocateyourrealmsfileunderHTTPDOCSwhereitcanbeserved.
That'sjustanaccidentwaitingtohappen.
SpecialserverfunctionsBesidesservingstaticfilesHTTPServhassomespecialfunctionsthatitcanperform.
Thespecialfunctionscanbeusedtoshowstatuspagesormaketheserverperformoperationssuchascachingcontentinmemoryorperformingashutdown.
Bydefaultallofthefunctionsareenabledbutthereisnowaytogettothem.
Thereisnohard-codedURLthatyoucanuseandfindthefunctions.
ToenableafunctionyoucreateanpseudofilenameentryforitinadirectoryusingtheHTACCESSfileforthatdirectory.
ThisseemscomplicatedbutitletsyoudefinewhattheURLpathtousetogettofunctionandallowsyoutoprotectthefunctionusingtheexistingHTTPBasicAuthenticationmethod.
TheappendixonHTACCESSfilesshowsyouthesyntaxforenablingthesefunctions.
TheappendixcalledSamplefilesforexposingthespecialfunctionsgivesaconcreteexampleofhowtosetthesespecialfunctionsup.
Whatfollowsnextisadescriptionofthefunctions.
HTTPServStatusPageThisisausefulbutharmlesspagethatgivesyoustatisticssuchashowlongtheserverhasbeenrunning,howmuchmemoryisavailable,howmanyobjectshavebeenserved,TCP/IPstatistics,etc.
HTTPServClientsPageThispageshowsyoutheIPaddressofcurrentlyactiveconnections,andifpossiblewhatrequestisbeingservedoneachofthem.
Youcanonlyseeactiverequestswhichlimitstheusefulnessofthepage.
(Inthefuturethispagemightberemoved.
)FilecachefunctionsHTTPServletsyouuseRAMtocachefiles.
Ifyouchoosethefilestocachecarefullythiscanreallyspeedthingsup,especiallyonoldersystemswithslowdiskaccess.
Threecachefunctionsareprovided-onetoreadafileintomemory,onetotellyouwhatfilesareinmemory,andonetoclearallofthefilesfromthecache.
ThecachefunctionsareimplementedwithonehandlerthatusesHTTPServURLparameterstopasscommandstotheserver.
Toaddafiletothecachesendaparameterwiththename"add"andtheURLofthefiletocacheasthevalueoftheparameter.
HTTPServwillprocesstheURLandresolveittoaDOSfile,includingdoinganylongnametoDOSfilenamemappingspecifiedintheHTACCESSfiles.
Forexample:http://192.
168.
2.
148/proc/cacheadd=%2Fpcjr.
cssInthisexampleIhaveasubdirectorycalled/prochangingoffmyHTTPDOCSdirectory.
TheHTACCESSfilefor/procdefinesapseudo-filenamecalled"cache"toenablethecachingfunction.
The"/pcjr.
css"object(relativefromthedocumentroot)istobeaddedtothecache.
ThestringlookshorriblebecausethespecialcharactersneedtobeescapedintheURL.
AneasierwaytodothisistoprovideasimpleHTMLfileinthedirectorywithaformthatlookslikethis:Theformversionismucheasiertouseandthebrowserhandlesescapingthespecialcharactersforyou.
Theformmethodmustbe"get"asHTTPServdoesnothandlethepostmethodyet.
WhenyouaddafiletothecacheHTTPServwillcheckthedocumentroottoseeifitexists.
Ifthefiledoesexistitwillbereadintomemoryandservedfrommemoryfromthatpointforward.
IfagzippedversionisavailableinHTTPZipsthatversionwillbecachedinstead;mostmodernclientswillrequestcompressedcontentandthissavesmemoryinRAM.
Remember,eventhoughDOSisnotcasesensitiveURLpathsare.
MakesureyouusethepropercombinationofupperandlowercasewhenspecifyingtheURLpathsoffilestocache.
Toseethelistoffilesinthecachesendaparameterwiththename"show"andnovalue.
Forexample:http://192.
168.
2.
148/proc/cacheshow=Aformcanalsobeusedtosimplifythis:Showcachedfiles:Thecacheclearcommandissimilar;theparameternametouseis"clear".
Individualfilescannotbeclearedfromthecache;theentirecachemustbeclearedatthesametime.
ThisisdonetopreventmemoryfragmentationintheDOSheap.
RemoteshutdownfunctionTheremoteshutdown(quit)functiondoeswhatyouthinkthatitdoes.
Becareful;ifyouenablethisyoumustprotectitwithHTTPBasicAuthenticationoranybodywhofindsthelinkwillbeabletoshutyourserverdownremotely.
Andthereisno"Areyousure"prompt,soifyoudoinvokethisfunctiontheserverwillshutdownandreturntoDOS.
HTTPServServingtothepublicInternetTeachingyouhowtorunapublicHTTPserverisbeyondthescopeofthisdocument.
Iassumeabasicknowledgeofnetworkingandsecurity.
Thesearejustafewremindersandthingsyoushouldbeawareof.
Security,Security,Security.
.
.
Ifyouconnectamachinetoanetworkyouopenituptoawidearrayofpossibleproblems.
Virusesormalwaremaytrytoinfectyourmachine.
Peoplemighttrytofindsensitiveinformationonyourmachine.
Peoplemighttrytocrashyourmachinejustforfun.
Ihavemadegreateffortstoprotectagainstthesethingsbutnothingisperfect.
Youareresponsiblefornotexposingsensitiveinformation;ifyoudon'twantitaccidentallypublisheddon'tputawebserveronthemachine.
Ihavetriedtoprotectagainstbufferoverruns,maliciousURLs,etc.
butthisworkprettymuchneverendswhichiswhyitneedstobetestedandbugsneedtobereported.
Andlastly,ifsomebodydecidestoDoS(DenialofService)yourDOSmachinewithacellphoneorafastermachine,thereisnotmuchthatcanbedone.
Youtakeresponsibilityforrunningawebserver.
Itcanbefun,butittakessomecare.
HerearesomethingsI'vedonetomakeHTTPServsafer:IfsomethingisprotectedwithHTTPBasicAuthenticationthenthedefaultistofailtoservethefileunlesstheuseridandpasswordfortherealmmatchup.
HTACCESS.
---filesareneverserved.
Theserveraggressivelydefendsagainstbufferoverflowattacks.
Theserverdoesnotallowaccesstospecialfilenames,likeLPT1:,$CLOCK,etc.
Ifitisnotafileoradirectory,itwillnotbeserved.
Theservertimesidleconnectionsoutautomatically,andmorequicklyifconnectionsarelimited.
Afairamountofinputcheckingisdonetoweedoutmal-formedrequests.
ThereareprobablythingsthatwillbreakandIwillfixthemastheycomeup.
YourISPprobablyhatesprivateserversMostresidentialgradeinternetserviceprovidersprohibitrunningserversonyournetworkconnection.
Theusualmethodofenforcementistoblockincomingrequeststo"wellknownports"thatcorrespondtoservicesthatyoumightwanttorun.
Theusualwayaroundthisrestrictionistorunyourserviceonanalternativeport.
Forexample,thestandardportforHTTPtrafficisport80.
Incomingrequeststoport80willbeblockedonyourconnectionbutifyouchoosetouseport8080insteadthetrafficwillprobablynotbeblocked.
(Andforrealvintagecomputingstreetcred,runonport8088.
)TheHTTPSERV_PORTconfigurationoptioncanbeusedtotellHTTPServwhatporttouseforincomingrequests.
Ifyouuseanon-standardporttheportmustbeincludedinanyURLsthatpointtoyourserver.
Forexample,whilehttp://yourserver.
net/worksforaserverrunningonthestandardHTTPportthesameserverusingport8080wouldneedaURLthatlookslikehttp://yourserver.
net:8080/.
HTTPServConfiguringyourhomefirewallMostpeoplehaveahomefirewallofsomesortthatallowsyoutohavemultiplemachinesinyourhousesharingthesameconnectionfromyourISP.
Whilethisisavaluablefunctionthefirewallalsoservesanothervaluablepurpose-itgenerallyblocksincomingrequestsfromarbitrarymachinesontheInternet.
Onereasonfordoingthisisthatarequestfromanunknownmachinemightbehostile.
Theotherreasonfordoingthisisthatthefirewallreallydoesnotknowwhichmachineonyournetworkshouldhandleaparticularincomingrequest.
Droppingthoseincomingrequestshelpsimprovesecuritybutitbecomesaproblemwhenyouaretryingtorunawebserver;allofthetraffictothewebserverlookslikeincomingrequestsfrompossiblyhostilemachinesontheInternet.
MosthomefirewallscanbeconfiguredtoallowincomingrequestsonthepublicIPaddressonspecificportstobesenttoaspecificmachineandportnumberonyourinternalnetwork.
Thissolvesthetechnicalproblemofwheretorouteincomingrequeststo.
Theforwardingisdoneonaportbyportbasissoyougenerallytellthefirewalltoonlyforwardanythingcominginonport80tothespecificmachineinyournetworkrunningthewebserver.
Requestsonotherportsstillgetdropped.
KeepinmindthatyourISPisprobablyblockingincomingrequeststoport80andthatyouprobablyhavetouseanalternateport,suchas8080.
Ifthatisthecasethenyourportforwardingshouldalsoreflectthat;incomingrequeststoyourcable/DSLmodemonport8080willneedtobeforwardedtoyourHTTPserver.
TheHTTPservercanberunningonanyport;theydonothavetomatch.
ThisallowsyoutosetupHTTPServtorunonport80onyourprivateLANandonlypeopleconnectingfromoutsidewillhavetousethenon-standardportthatyouchosetogetaroundyourISP.
(Thefirewallhandlestheforwardingofthetrafficincludingthemappingofportsautomatically.
)TellingpeopleyourservernameOnyourinternalnetworkyourservernameistheIPaddressofthemachineorahostnameifyouhaveDNSconfiguredinternally.
ButusersoutsideofyourLANontheothersideofyourfirewallwillseetheworlddifferently.
TheywillconnecttoyourserverusingtheIPaddressassignedtoyoubyyourISPandtheywillalsoprobablyhavetouseanon-standardportnumber.
Ingeneralthisisnotaproblem.
Arequestwillcometoyourfirewallonthepublicaddress.
Yourfirewallwillforwardtherequesttoyourserver.
Theserverwillrespond,andeverythingisgood.
Theproblemsarisewhenyourserverhastotelltheoutsidepersonwhataddresstouseforfollowuprequests.
Forexample,ifapersonspecifiesaURLthatmapstoasubdirectorythentheyaresupposedtoprovideatrailingslash('/')toindicatethatitisadirectory.
Iftheyomitthetrailingslashtheserverwillrespondwitha301totellthemthecorrectURLtouse,andthoseheaderswillalsoincludetheservername.
Iftheservernameisnotaccuratethefollowuprequestwillfail.
ThedefaultservernameistheIPaddressofthemachineandtheportyouarelisteningon.
ThisworksfineonyourinternalLANbutitdoesnotworkforusersontheothersideofyourfirewall.
TogetaroundthissettheHTTPSERV_SERVERNAMEconfigurationoptiontobetheIPaddressandportthatyouaretellingpeopletoconnectto.
Forexample:IftheIPaddressofyourHTTPserveronyourinternalLANis192.
168.
1.
124anditislisteningonport80and…Yourcable/DSLmodem(firewall)hasapublicaddressof67.
43.
212.
82and…HTTPServYourISPblocksport80soyouareusingport8080forconnectionsfromthepublicInternetandyouhavesetyourrouteruptoforwardthemtoyourHTTPserver,then.
.
.
YourHTTPSERV_SERVERNAMEshouldbesetto67.
43.
212.
82:8080.
Thatway,ifyourHTTPserverhastorespondwitha301HTTPheaderitwillgivethecorrectaddresstouseforthefollowupconnection.
Ifyoudon'tsetHTTPSERV_SERVERNAMEthenitusesthelocalIPaddressofthemachine(192.
168.
1.
124:80inthisexample)whichmakesnosensetoanoutsideuser.
MiscellaneoustipsChoosingfilestocacheinmemorySincemostclientssupportgzippedcontentyoushouldcacheonlygzippedversionsofyourcontenttostretchyourmemory;clientsthatdonotsupportgzippedcontentarerare.
Cachedfilesneedtobeunder64KBinsize;ifafileisabovethatsizetherequestwillberejected.
Yougetmorebang-for-the-buckbycachingseveralsmallfilesinsteadoffewerlargeones.
Thereasonforthisisthatthereisoverheadtofindingandopeningafileandthatoverheadisthesamewhetherthefileislargeorsmall.
Asafractionoftotaltransfertimethatoverheadislargerforsmallfilesthanitisforlargefiles.
Soitmakessensetotrytoeliminatethatoverheadforsmallfiles.
Filesthatareusedacrossmultiplepagesaregoodcandidatesforcaching.
ThisincludesCSSfiles,smalllogosandicons,etc.
Yoursite'shomepageandanypagesthatyouthinkwillbevisitedoftenarealsogoodcandidatesforcaching.
LogfileconsiderationsIfyouarerunningaserverforyourownpersonaluseonaprivateLANthenyouprobablydonotneedtohavethelogfileenabled.
Nothavingalogfilemayprovidesomemodestspeedimprovement.
Itwillalsocutdownontherequiredmemory.
Ifyouarerunningapublicserverthenyoureallyshouldhaveloggingturnedon.
Thedatawrittentothelogfileisprettyverbose.
Makesurethatthedrivethelogfileresidesonhasenoughspace;afewmegabytesisasafenumbertostartwith.
DuringmylargescaletestHTTPServserved7175requestsandgeneratedalogfilethatwas6.
4MBinsize.
Thatisanaverageof900bytesforeachrequest.
Inthefuturelogswilleitherbewritteninacompressedformatatruntimeortherewillbea"logrolling"functionaddedtoperiodicallyclosethelogfile,compressit,andstartanotherone.
DonotwriteyourlogfiletoaRAMdisk.
Ifthemachinecrashesyouwilllosethelogfile.
UsingdiskcachingsoftwareIfyouareonamachinethathasexpandedorextendedmemorythatcanbeusedtocachediskoperationsthenyoushoulduseit.
Suchcachingsoftwarewillgenerallycachethemostuseddiskblocks,automaticallyHTTPServremovingblocksfromthecachethatarenolongerbeingused.
ThismakesmoresensethanusingconventionalmemorytocachespecificfilesusingthecachefunctionofHTTPServ;youhavemuchmorememoryavailabletoyouifyouhaveexpandedorextendedmemory.
Theonlydangermightbethatthelogfilewriteswouldalsobecached;ifsomethingcrashesoryoulosepoweryoumightlosesomeofyourlogs.
HTTPServConfigurationoptionsHTTPServcanberunusingcommandlineargumentsonly;nofurtherconfigurationisneededunlessyouwanttouseadvancedoptions.
IfyouwanttosetconfigurationoptionstheycanbeplacedinthemTCPconfigurationfilepointedatbytheMTCPCFGenvironmentvariable.
ThefollowingoptionscanbeusedtoconfigureHTTPServbehavior:HTTPSERV_HTTPDOCSSetthedocumentrootHTTPSERV_HTTPZIPSSetthedocumentrootforpre-compressedfilesHTTPSERV_LOG_FILESetthelocationofthelogfileHTTPSERV_REALMSSetthelocationoftherealmsfileforHTTPAuthenticationHTTPSERV_SERVERNAMESetthenameusedwhensendingresponsestoclientsHTTPSERV_PORTSettheportusedforincomingHTTPrequestsHTTPSERV_VERBOSITYControlhowverbosetheon-screenmessagesareHTTPSERV_DIR_INDEXESSetthedefaultforgeneratingdirectoryindexesHTTPSERV_DIR_CACHESethowmuchmemoryisusedforcachingHTACCESSfilesHTTPSERV_CLIENTSSetthenumberofconcurrentclientstosupportEachconfigurationoptionisexplainedinmoredetailbelow:HTTPSERV_HTTPDOCSEquivalentcommandlineoption:-doc_rootFormat:HTTPSERV_HTTPDOCSEverywebserverhasa"documentroot"thatisadirectorythatservesastherootofthedirectorytreeforfilesbeingservedbytheserver.
ThisconfigurationoptionisusedtotellHTTPServwhichdirectorytouseasthedocumentroot.
Thedocumentrootshouldbeprovidedasafullyqualifiedpathincludingadriveletter.
Filesinthedirectoryandsubdirectorieswithinthedocrootcanbeseenbypeoplebrowsingtheserver;filesoutsideofthedocrootarehiddenandnotavailable.
Examples:HTTPSERV_HTTPDOCSd:\httpdocsHTTPSERV_HTTPDOCSc:\HTTPSERV_HTTPDOCSe:\public\toshareHTTPServIfyoudonotsetthisconfigurationoptionthenyoucansetitontheHTTPServcommandlineusingthe"-doc_root"option.
Ifboththe-doc_rootoptionandHTTPSERV_HTTPDOCSarespecifiedthenthe-doc_rootwillhavepriorityandbetreatedasthoughitwasoverridingHTTPSERV_HTTPDOCS.
HTTPSERV_HTTPZIPSEquivalentcommandlineoption:Notapplicable(seebelow)Format:HTTPSERV_HTTPZIPSHTTPSERV_HTTPZIPStellsHTTPServwhereyourpre-compressedfilesare.
Pre-compressedfilesallowforbetterperformanceatthecostofadditionaldiskspace.
SeeServingprecompressedstaticcontentforthedetailsonhowitworks.
Example:HTTPSERV_HTTPZIPSd:\httpzipsTheuseofHTTPZIPSiscompletelyoptional.
HTTPSERV_HTTPZIPSisonlyvalidifthedocumentrootissetusingHTTPSERV_HTTPDOCSintheconfigurationfile.
Ifyouusethe-doc_rootcommandlineoptiontotemporarilychangethedocumentrootthenservingprecompressedcontentwillbedisabled.
NoequivalentcommandlineoptionforHTTPSERV_HTTPZIPSisprovided.
HTTPSERV_LOG_FILEEquivalentcommandlineoption:NotapplicableFormat:HTTPSERV_LOG_FILEIfyouaregoingtorunanysortofpublicserveryouprobablywantalogfilesoyoucankeeptrackofwhichIPaddressesareconnectingtoyourserverandwhattheyaredoing.
ThisconfigurationoptionisusedtotellHTTPServwhichfiletouseasthelogfile.
HTTPServalwaysappendstothisfile.
AsofthiswritingHTTPServdoesnotcompresslogfilesorrotatethemsoyoushouldlocateyourlogfileonadriveletterthathasplentyofavailablespaceandyoushouldperiodicallychecktoseeifthelogfilesneedstobecompressedandmovedoffline.
DonotlocateyourlogfileinanareaofthediskbeingservedbyHTTPServ-thatisapotentialsecurityproblem.
HTTPSERV_LOG_FILEisoptional.
Usingitcanslowtheserverdownalittlebitbutifyouareallowingtrafficfromoutsideofyournetworkyoureallyshoulduseit.
PleaseseeLogfileconsiderationsformorediscussiononthelogfileandloggingtechniques.
HTTPSERV_REALMSHTTPServEquivalentcommandlineoption:NotapplicableFormat:HTTPSERV_REALMSIfyouareusingHTTPBasicAuthenticationtoprotectanyofyourfilesordirectoriesthenyouneedarealmsfiletodefinethepasswordforeachrealmyouareusingintheHTACCESSfiles.
PleaseseeProtectingfilesanddirectoriesforthedetailsonhowtousethisfile.
HTTPSERV_SERVERNAMEEquivalentcommandlineoption:NotapplicableFormat:HTTPSERV_SERVERNAMEHTTPServknowstheIPaddressofthemachinethatitisrunningonbutitdoesnotreallyknowwhatthehostnameofthemachineis.
Hostnamecanbeambiguous,especiallyformachinesthatareDHCPclientsorthatarebehindfirewalls.
Thehostnamethatyoutellclientstousemayhavenothingtodowiththehostnamethemachineisconfiguredfor,especiallyifportforwardingisinvolved.
IfHTTPServisgoingtoservetraffictomachinesoutsideofyourimmediateLANortomachinesthatareontheothersideofafirewallthatchangesnetworkaddressesthenyouprobablydidsomeconfigurationtogettherequestsroutedtoHTTPServ.
WhateverhostnameyouaretellingtheclientstousetoconnecttoHTTPServshouldbesetonthisconfigurationoption.
Onewayinwhichthisisusediswhentheclientrequestsadirectorybutdoesnotincludeatrailingslash('/');thatrequiresHTTPServtosendaredirect(301HTTPheader)tolettheclientknowthatthecorrectURLincludesatrailingslash.
Theredirectmessageneedstohaveaservernamethattheclientcanuse.
Example:(AssumeyourmachineisbehindafirewallthatusesNATandtheaddressis192.
168.
1.
124)HTTPSERV_SERVERNAMEbogus.
dyndns.
org:8080InthisexampleyouareusingadynamicDNSserviceandportforwardingtoprovideconnectivitytoyourmachinefromtheoutsideworld.
TherealIPaddressdoesnotmakesensetoclientsoutsideofyournetworksoifyourserverneedstosendaresponsethatincludestheservername,itwilluse"bogus.
dyndns.
org:8080"insteadof192.
168.
1.
124.
SeethesectionentitledServingtothepublicinternetforamoredetailedexplanationofthisandotherfirewallrelatedissues.
HTTPSERV_PORTEquivalentcommandlineoption:-portHTTPServFormat:HTTPSERV_PORTBydefaultHTTPServlistensonthestandardWWWport,whichisport80.
Ifyouneedtouseanalternativeportusethisoptionorthe"-port"optiononthecommandline.
HTTPSERV_VERBOSITYEquivalentcommandlineoption:NotapplicableBydefaultHTTPServprintsaminimalamountofinformationontheconsoleabouteachrequestitisserving.
Ifyouwouldliketoseemoredetailforeachrequestyoucansettheverbositylevelhigher.
Supportedlevelsare"low"(thedefault),"medium"and"high".
Example:HTTPSERV_VERBOSITYmedium"Medium"isactuallyprettyverbose.
"High"isusedfordebugmessages.
HTTPSERV_DIR_INDEXESEquivalentcommandlineoption:-dir_indexesBydefaultHTTPServwillnotgeneratedirectorylistingsfordirectories;thisisforsecurityreasons.
Ifyouwouldliketochangethedefaulttoenabledirectorylistingsthenusethisoption.
Enablingdirectorylistingsbydefaultissafeandharmlessifyouaretheonlypersonusingtheserver.
Butifyouaregoingtoallowotherpeopletobrowseyourmachineyoushoulddisabledirectorylistingsandprovideastatic,perdirectoryfilethatlinkstowhatyouwantuserstobeabletosee.
Thatgivesyouanopportunitytoprovidedescriptionsforeachfilenexttothelinktoit.
Forsomecaseslikealargesharewarerepositorythatmightnotbepractical.
Useyourbestjudgment.
Alsokeepinmindthatjustbecauseafiledoesnothavealinktoitdoesnotmeanthatanexternaluserwon'tbeabletoseeit.
Theycanalwaysguessatlinks.
Ifyoudon'twantsomethingserved,don'tputitonyourserver.
Legalvaluesforthisoptionare"yes"and"no.
"AsettingforaspecificdirectoryinitsHTACCESSfileoverridesthisglobalsetting.
Example:HTTPSERV_DIR_INDEXESyesThatwillenabledirectoryindexesbydefaultacrossalldirectories.
HTTPSERV_DIR_CACHEHTTPServEquivalentcommandlineoption:NotapplicableServingfilesusingHTTPisafairlyexpensiveoperationforanoldmachine,especiallywhenHTACCESSfilesareused.
TheremaybeanHTACCESSfileinanydirectoryandeachHTACCESSfilemayhavealotofdirectives.
ServingafilerequireswalkingtheentirepathintheURLandexaminingeachdirectoryandpossibleHTACCESSfilealongtheway.
TomakethisreasonableonslowermachinesthedirectorystructureunderHTTPDocsandthecontentsofHTACCESSfilesarecachedinmemory.
Thecachecanbesetfrom8KBto63KBinsize.
Example:HTTPSERV_DIR_CACHE32Thatwillsetthedirectorycacheto32KBinsize.
IfyoumakeextensiveuseofHTACCESSfilesyoushouldincreasethisvaluetothemaximumsetting.
Youcanrunwithlessbutitmightslowthingsdown.
Thecacheisfixedinsizeandnotverysophisticated;tokeeptheprogrammingandmemorymanagementreasonablesomecompromisesweremade.
Ifthecacheoverflowsitgetserasedandrebuiltstartingwiththedatafromthecurrentrequest.
Ifthecacheistoosmallitwillkeepgettingerased,whichisalmostlikehavingnocacheatall.
HTTPSERV_CLIENTSEquivalentcommandlineoption:-clientsFormat:HTTPSERV_CLIENTSModernwebbrowsersopenmultipleconnectionstoawebserveratthesametimetospeedtheprocessingofrequests.
Tothewebservereachconnectionisanindependenttransactionsooneclientswithmultipleconnectionsistreatedthesameasmanyclientseachwithoneconnection.
HTTPServallowsyoutosetthenumberofsimultaneouslyconnectedclientsthatitcanserverequeststo.
Thedefaultiseight,meaningthateightdifferentclients(oroneclientbeingapig)canconnectatthesametime,issuearequest,andhavetherequestprocessed.
HTTPServwilldoitsbesttoservicetherequests;interleavingtheprocessing.
Thisisbetterthanjustsimplyqueuingtherequestsandprocessingthemoneatatime.
However,itisnotmagic-wheninterleavingtheprocessingeverythingtakeslonger.
Ifmorethanrequestsarriveatthesametimetheadditionalrequestswillbequeuedandmadetowait.
HTACCESSFiles(Note:TheactualfilenameusedforanHTACCESSfileis"HTACCESS.
---".
Thatshouldbeobscureenoughtoavoidcollisionswithrealfilenames.
)InanydirectorythathascontentbeingservedbyHTTPServyoucancreateaspecialfilecalledHTACCESSthatcanbeusedtotellHTTPServtoperformspecialfunctions.
ThesespecialfunctionsincludemarkingfilesHTTPServanddirectoriesasprotectedusingHTTPBasicAuthentication,mappingpartsofaURLtostandardDOS8.
3filenameformat,providingadefaultfiletodisplaywhentheusernavigatestoadirectory(insteadofprovidingadirectorylist),etc.
AnHTACCESSfileinadirectoryonlyaffectsthehandlingofnamesinthatdirectory.
(Namesincludesnamesforrealfilesandnamesforsubdirectoriesinthatdirectory.
)IfyounavigateawayfromthatdirectorytheHTACCESSfileisnolongerrelevant;nothingisinheritedfromit.
(Well,almostnothing.
.
.
readthedescriptionoftheFileAuthdirectivefordetails.
)Eachlineofthefilehasadirectiveandsomeoptions.
Allfieldsonthelinearedelimitedbyasinglespace.
Belowisadescriptionofthedirectives.
MapDirectiveHTTPURLsaresupposedtolooselymaptosubdirectoriesandfilesontheHTTPserver.
ExceptionstothisincludeparametersintheURLandpathsthatrefertogeneratedcontent.
AsHTTPServrunsonDOSitexpectstoserveURLsthatarecomposedoflegalDOSfileanddirectorynames.
ThisbecomesaproblemwhenyouconsiderthatDOSfileanddirectorynamesareatmost8byteslongwithanoptional3byteextension-thedreaded8.
3format.
DOSfileanddirectorynamesarealsonotcasesensitive.
Mapletsyougetaroundtheselimitsbyallowingyoutodefinelong,casesensitivenamesthatarealiasesforDOS8.
3names.
ThisisusefulifyouwanttohostanexistingwebsitewheretheexistingHTTPURLsdonotconformtoDOS8.
3namingconventions.
OfcoursethefilesthemselveshavetoconformtoDOS8.
3namingconventionsbutyoudonothavetogointothefilesandchangeallofthelinkstomatchorupdatealloftheexistingURLs.
TheMapdirectivehasthefollowingformat:MapNiceLongNamefilename.
extwhere:NiceLongNameisacasesensitivenameupto51bytesinlength.
Ifthisnamecontainsspacespleasewrapitinquotes.
filename.
extistheDOS8.
3filenamethatshouldbeusedinplaceofNiceLongName.
Thisnameisnotcasesensitive.
Forexample:MapDownloads.
htmldls.
htmThatexamplesaysthatiftheURLfromtheuserhas"Downloads.
html"asthefilenameinitthatHTTPServshouldconvertthatto"dls.
htm"instead.
WhenHTTPServisprocessingaURLit"walks"througheachpartoftheURLandconsidersitonacomponentbycomponentbasis.
Themappingiflongnamestoshortnamesisdoneateachstageofthewalk.
ConsiderthefollowingURL:http://yourserver.
com/Reference/Downloads/Downloads.
htmlHTTPServInthepathpartoftheURLwefindthreeparts-"Reference","Downloads",and"Downloads.
html".
ReferenceandDownloadsrefertosubdirectoriesandDownloads.
htmlreferstoafile.
ButnoneofthesearevalidDOS8.
3filenamesthatHTTPServcanread.
TohandlethisURLwecandothefollowing.
Assumethatyourserverisconfiguredwith"E:\HTTPDOCS"asyourHTTPdocumentrootandthatE:\HTTPDOCS\REF\DLS\DLS.
HTMisthefullpaththatshouldbeservedforthatrequest.
"E:\HTTPDOCS"istherootofyourserverandithasanHTACCESSfilethatincludesaMapdirective:MapReferenceREFThatallowsHTTPServtomoveintotherealREFsubdirectorywhenitsees"Reference"atthefirstleveloftheURL.
InsideoftheREFsubdirectorythereisanotherHTACCESSfilethatincludesanotherMapdirective:MapDownloadsDLSThatallowsHTTPServtomoveintotheDLSsubdirectorywhenitsees"Downloads"atthenextleveloftheURL.
InsideoftheDLSsubdirectoryweneedonemoreHTACCESSfilewithonemoreMapdirective:MapDownloads.
htmlDLS.
HTMThatallowsHTTPServtosubstituteDLS.
HTMasthefiletobesenttothewebbrowser.
MappingonlyhappensonceperURLcomponent.
Youcannothaveonemappingmaptoanotherlongname,whichinturnmapstosomethingelse;ifthatwereallowedausermistakecouldleadtoanendlessloop.
FileAuthDirectiveTheFileAuthdirectiveletsyoumarkafileordirectoryasbeingprotectedbyanHTTPBasicAuthenticationrealm.
(See"ProtectingFilesandDirectories"aboveforanoverview.
)TheformatoftheFileAuthdirectiveis:FileAuthfilename.
extrealmwhere:filename.
extistheDOSfileordirectorythatyouareprotectinginDOS8.
3format.
OnlyDOS8.
3formatfileanddirectorynamesmaybeprotected;ifyouareusinglongnamesinyourURLsyouneedtouseMAPdirectivestoconvertthemtoDOS8.
3formattobeabletoservethem.
realmisastringthatdescribeswhatyouareprotecting.
Mostwebbrowsersshowthisstringtotheuserwhenpromptingforauseridandpassword.
Therealmmustbedefinedina"realms"filethatyourmTCPconfigurationtellsHTTPServtouse.
Iftherealmisnotfoundinthatfilenobodywillbeabletoauthenticateandseethefileordirectory.
Example:FileAuthsecret.
txt"SensitiveFilesArea"Theexampleshowsthat"secret.
txt"ismarkedasbelongingtorealm"SensitiveFilesArea".
OnlyuserslistedHTTPServintherealmsfilewhoknowthepasswordwillbeabletoseesecret.
txt.
GeneratedPageDirectiveAsofthiswritingHTTPServhastwospecialpagesandonespecialfunctionthatcanbeaccessedusingaURL.
Bydefaultthesepages/functionsarenotavailable.
YoucanusetheGeneratedPagedirectivetomakethemavailableasapageinthedirectorywheretheHTACCESSfileislocated.
Theformatis:GeneratedPagefilename.
extspecial_functionwherefilename.
exeisaDOS8.
3formatfilenamethatwillbeusedasthenameofthepage/function.
Yes,itisalittlestrangetorequireaDOS8.
3formatnameforsomethingthatdoesnotactuallyexistbutitmakesthecodesimpler.
special_functionnamesthespecialpageorfunction.
Thecurrentpages/functionsare:serverstatusgenerateapageofstatisticsfortheserverclientsgenerateapagethatshowstheconnectedclientsserverquitendtheserverimmediatelyExample:(AssumethesedirectivesareinE:\HTTPDOCS\SPECIAL\HTACCESS.
---)MapStatusstatusMapClientsclientsMapQuitQuitQuitquitGeneratedPagestatusserverstatusGeneratedPageclientsclientsGeneratedPagequitserverquitFileAuthclients"Slightysensitive"FileAuthquit"Adminoperations"Inthisexampleallthreespecialpages/functionsareactive.
Theserverstatuspagecanbeobtainedbygoingtohttp://yourserver.
com/Statusorhttp://yourserver.
com/statusbecausewehavemadethepageavailableas"status"andprovidingamappingfor"Status".
Theclientspageissimilar-ithasaDOS8.
3nameandamappingfor"Clients".
Clientsisalsomarkedasbeinginthe"Slightlysensitive"realmsoitrequiresauserIDandpasswordtoview.
Thequitfunctionisalsoavailablethroughtwonamesanditisextremelydangeroussoitismarkedasbelongingtothe"Adminoperations"real.
Presumablyyourrealmssetupfilehaslessusersauthorizedto"Adminoperations"thanto"Slightlysensitive".
DirectoryIndexDirectiveIfauserusesaURLthatturnsouttobeadirectorytheservermayeithergeneratealistoffilesinthedirectory,itmayrefuseaccesstothelistoffilesinthedirectory,oritmayserveadefaultfilethatexistsinthedirectory.
Thisdirectiveletsyouspecifythatafileshouldbeservedandwhichfilethatis.
Theformatis:DirectoryIndexfilename.
extHTTPServIftheuserusesaURLthatendsinthedirectorywherethisissetthenwhateverfilespecifiedonthisdirectorywillbeservedtothem.
Thisisthemechanismthatletsfilessuchas"index.
html"or"default.
html"beservedwhenyoufirstnavigatetoawebsiteanddonotspecifyafilenameintheURL.
Ifyouusethisdirectivetheuserwillnotbeabletogenerateadirectorylistforthedirectory,evenifthatisexplicitlyallowed.
IndexAllowedDirectiveTheIndexAlloweddirectiveallowsyoutospecifyifHTTPServshouldgenerateafilelistornotifauserspecifiesaURLthatresolvestoadirectory.
TheformatisIndexAllowedyes|noYesandnoareusedtoexplicitlyallowordenyadirectorylisttobegeneratedforagivendirectory.
Ifnodirectiveisprovidedthenthedefaultis"no"unlessthatisoverriddeninthemTCPconfigurationfileusingtheHTTPSERV_DIR_INDEXESconfigurationoption.
SamplefilesforexposingthespecialfunctionsLet'sassumethefollowing:Specialfunctionsliveinadirectorycalled"proc"thatisasubdirectorydirectlyunderyourHTTPDOCSdirectory.
Allfunctionsareenabled.
Theclientspage,cacheandquitfunctionsareprotectedbyHTTPBasicAuthentication.
Whenausergoestothatdirectoryadefaultfilewillbeservedtothemtomakethingseasier.
Whenausernavigatestotheprocdirectorywewantthemtoseesomethinglikethis:HTTPServHereisasimpleHTMLfilewewillcalldefault.
htmthatwillbeservedtotheuserwhentheygoto/proconyourserver:Thisisaspecialdirectoryforgeneratedcontents.
TryStatustogetserverstatusClientstogetalistofclientsQuittoforcetheservertoshutdownremotelyWanttocacheafileTrythis:Showcachedfiles:Clearcachedfiles:AndhereistheHTACCESSfileforthe/procdirectory.
Itdoesthefollowing:HTTPServTellsHTTPServtoservedefault.
htmbydefaultwhennofilenameinthedirectoryisspecified.
Definesthefour"pseudofilenames"thatrepresentthefourserverfunctions.
Declaresthreeofthefunctionstobeprotectedbythe"ServerFunctions"realmforHTTPBasicAuthentication.
directoryIndexdefault.
htmindexAllowednoGeneratedPagestatusserverstatusGeneratedPagequitserverquitGeneratedPageclientsclientsGeneratedPagecachecachecmdsFileAuthquit"ServerFunctions"FileAuthclients"ServerFunctions"FileAuthcache"ServerFunctions"Remember,DOSfilenamesarenotcasesensitive.
TheHTMLfileisusing"Status"forareference,whichrefersto"status"ontheGeneratedPagedirectiveintheHTACCESSfile.
Andtherereallyisnofilein/proccalled"status"-itisapseudofilenamethatresultsinastatuspagebeinggenerated.
IRCjrIRCjrIntroductionThisisafairlysimpleIRCclientthatIhavebeenworkingonsincethesummerof2008.
Originallyitstartedasabarebonesprogramthatletyouconnecttoonechannelononeserver.
Allmessagescameoutonthesamescreenandsendingprivatemessagestootheruserswasahassle.
But,itworked!
Thingshavechangedquiteabitsincethen.
Theprogramhasgrowninsizesincethoseearlyversionsbuttherearealotofimprovementsthatmaketheprogrammucheasiertouse.
IRCjrnowsupportsmultipleopenchannelsandprivateconversations,ClienttoClientProtocol(CTCP)messages,etc.
Thisversionaddsthefollowingfeatures:mIRCcolorcodesupportPASScommandsupportloggingtoadifferentfileforeachopensessionlargersupportedbackscrollbuffersizes132columnsupport(ifyourvideocardsupportsit)improvedTCP/IPlostpacketandretransmitsupportmanysmallbugfixesEnjoy!
Specialhardwareorsoftwarerequirements:NoneSetupIRCnetworksrequireyoutospecifyanicknamethatotherpeoplewillknowyouby,ausernamewhichistheuserIDthatyouuseonyourlocalmachine,andarealname.
Thenicknameisthemostimportantofthese,asyournicknamewillbeusedthemost.
Theusernameandrealnamecannotbeverifiedortrustedandmostpeopleprobablydon'tprovideaccurateinformationforthemanyway.
Thenickname,username,andrealnamearesetbyaddinglinestothemTCPconfigurationfile.
Theparameternamesare:IRCJR_NICKYournicknameforIRCIRCJR_USERYourusernameonthismachineIRCJR_NAMEYournameinreallifeHereisanexamplethatshowshowtousethese:IRCjr#IRCjrparametersfornickname,username,andrealname#ircjr_nickZoidbergircjr_userJzoidbergircjr_nameJohnZoidbergTheofficialIRCprotocolspecificationstatesthatnicknamesareamaximumof9characterslong.
ThatisroutinelyignoredandyouwillfindthatyourfavoriteIRCserverssupportmuchlongernicknames.
IRCjrallowsyoutouseupto40charactersforanicknamebutifyourserverdoesnotsupportnicknamesthatlongitmaytruncatethenicknameorgiveyouanerrormessage.
SomeIRCserversarepickyabouttheusernameandrealnameandwantyoutousesomethingplausibleortheywillrejectyourconnection.
Forexample,ifyoupickasinglewordforyourrealnameitispossiblethattheserverwillassumethatyouarea"bot"andrejectyourconnection.
Ifyouarehavingtroubleconnectingtoaserverchecktheerrormessagescarefullyandseeifitiscomplainingaboutthesefields.
StartingIRCjrIfyourpacketdriverisloaded,themTCPenvironmentvariableisset,andyouhaverunDHCPtogetanetworkaddressthenyouarereadytorunIRCjr.
(Ifyouneedhelpwithanyofthose,pleaseseeSETUP.
TXT.
)Thecommandlineargumentsare:ircjr[-port][]Theservernameisalwaysrequired.
Thechannelisoptional-youcanusethe/joincommandtojoinachannelonceyouareconnectedtotheIRCserver.
Besurethatthepacketdriverisloadedfirst.
WhentheprogramfirststartsitisgoingtoinitializetheTCP/IPstackandtrytofindtheIPaddressofyourIRCserver.
ItisgoingtousetheDNSsystemtodothis.
IfyouhavenotsetupyourTCP/IPenvironmentvariablescorrectlyyouwillnotbeabletoconnecttoyourIRCserver.
(IfyouknowthenumericalIPaddressofyourserveryoucanuseitdirectlytoavoidtheDNSlookup.
)IfallgoeswellyouwillgetaconnectiontotheIRCserver.
Ifyouspecifiedachannelonthecommandlineyouwillbesignedontothatchannelautomaticallybytheprogram.
Atanytimeduringtheconnectionprocessyoucanhitthe[ESC]keytoquit.
Theoptional-portcanbeusedtoconnecttoIRCserversrunningonnon-standardports.
Herearesomeexamples:ircjrirc.
slashnet.
org#vcconnectstomyfavoritechannelonmyfavoriteIRCnetwork.
ircjr-port2000irc.
privateserver.
netshowshowtousethe-portoptiontoconnecttoaserverwithanon-standardIRCport.
IRCjrUsingIRCjrBasicknowledgeofIRCisassumed.
Butjustincase.
.
.
IRCstandsfor"InternetRelayChat"anditisasystemthatallowsclientstoconnecttoacommonserverandchatwitheachother.
Serversallowforthecreationandmanagementofdifferent"channels"thatclientscanjoin.
Thechannelsareusuallynamedafteratopicofinterest.
Usersmayalsochatdirectlywitheachotheroutoftheviewofothers.
Serverscanbeconnectedtootherservers,allowingforIRCnetworksthatspantheglobe.
Eachnetworkhasitsownpoliciesregardinguserbehavior,andevenwithinachanneltheremightbe"operators"whoenforcepoliciesonthatchannel.
Operatorshavetheabilitytoremovepeoplefromchannels,sobepolitetothem.
;-0ScreenlayoutTheIRCjrscreenissplitintotwoareas-theuserinputareaandthedialogarea.
Thedialogareashowstherunningconversationinachanneloraprivatechatsession.
TheuserinputareaiswhereyoucancomposeyourcommentsbeforesendingthemtotheotherusersorwhereyoucanenterIRCcommands.
Astatuslineseparatesthetwoareasofthescreen.
Thestatuslinetellsyouwhichsessionyouareviewing,whichsessionsareactive,andalsohasindicatorsforthevarioustogglesettings.
Duringnormalusagethetextthatyouenterwillbesenttotheotherusersaspartoftheconversation.
Thetextthatyouenterwillbeinterleavedintheconversationwithtextfromotherusersintheorderthattheserverreceivesit.
SendingIRCcommandsItispossibletosendIRCcommandstotheIRCserver.
IRCcommandsmeantfortheserverstartwitha'/'characteratthestartoftheline.
IRCcommandsareusedformanydifferentreasons;herearesomeofthecommonones:/joinJoinanIRCchannel(eg:/join#vc)/msgSendaprivatemsgtoanotheruser(eg:/msgLeelaHello!
)/querySameas/msg,butopenanewsessiontodoit/namesSeewhoisinthechannel(eg:/names#vc)/partLeaveachannel(eg:/part#boring)/nickChangeyournickname(eg:/nicknewnickname)/listListthechannelsonaserver/quitDisconnectfromtheserverandendIRCjrAhintonthe/listcommand-onalargeserverorservernetworkthelistofopenchannelscanbehundredsorthousandsoflineslong.
Youcan'tseealloftheoutputonthescreenorinyourbackscrollbuffer,butyoucanusetheLOGtoggletosavethelisttoafileandreaditlater.
Somelesscommonbutstillfuncommandsare:IRCjr/infoGetserverinformation/motdReadthemessageofthedayontheserver/whoisGetinformationaboutaparticularnickname/awayMarkyourselfasaway(orback)IRCjrprocessesthecommandsthatitunderstandsandpassesunfamiliaronesstraighttotheserver.
ThisletsyoutrytouseanyIRCcommandevenifIRCjrdoesnotrecognizeit.
SendingCTCPcommandsBesidescommandsfortheserverthereare"ClientToClientProtocol"(CTCP)commandsyoucanusetointeractdirectlywithotherIRCclients.
Theyare:/meSendan"Action"command/ctcpversionFindoutwhatclientauserisrunning/ctcppingPingaclienttoseeiftheyareactive/ctcptimeFindthelocaltimeforanotheruser/ctcpuserinfoGettheusernameforanicknameThe/meCTCPcommandisprettysimpletouse:/meducksandruns!
SendsamessagethatyouareduckingandrunningTheotherCTCPcommandsrequireyoutoprovideatarget(anicknameorevenachannelname).
Forexample:/ctcpversiontwinkie(findwhatIRCclientuser"twinkie"has)/ctcptimeotherguy(findoutwhattimeotherguythinksitis)IRCjrHotkeysBesidestheIRCcommandstherearespecialkeycombinationsthatmakeIRCjrperformtricks:ALT-BTogglethenewmessagebeeperALT-HDisplaythehelpwindowALT-CClosecurrentsession/windowALT-LTogglesessionloggingonandoffALT-SShowTCP/IPstatisticsALT-TToggletimestampsonincomingmessagesALT-XExitIRCjrPgUpGobackintimethroughthebackscrollbufferPgDnGoforwardintimethroughthebackscrollbufferAlt0-9Switchtosessions0thru9(ifapplicable).
(Session0isalwaysthe"Server"session.
Channelsandprivatechatsusesessions1-9.
)IRCjrSession/WindowhandlingEachopenchannelandprivatechathasitsownvirtualsession.
Themainwindowonlydisplaysonesessionatatime,sotoflipbetweenthevirtualsessionsyouuseAltandanumberkey.
Whenyoufirststartyouareinasessionreservedforservermessages.
Thiswindowisknownasthe"Server"session.
YoucangettoitatanytimebyhittingAlt-0.
Itcannotbeclosed.
Whenyoujoinanewchannelanewvirtualsessioniscreatedandyouareautomaticallyswitchedtothatnewsession.
Thesamethinghappensifsomebodysendsyouaprivatemessageorifyousendsomebodyaprivatemessage.
Thenameofthecurrentsessionisshownonthestatusindicatorline.
Alsoonthestatusindicatorlinethereisasequenceofdigitsthatshowyouhowmanysessionsareopenandwhatstatetheyarein:Normaldigit:asessionwithnorecentactivityBrightdigit:thesessioncurrentlybeingdisplayedReversedigit:asessionthathasnewactivityinitYoucanflipdirectlytoanysessionbyhittingAltandthenumberthatrepresentsthesession.
Youcanhaveupto10sessionsincludingtheserversession.
AfterthattryingtocreateanewsessionwillfailandwhatevermessagesthataresenttothatchannelwillbeputontheServersession.
Ifanewsessionisrequiredanditcan'tbecreatedbecauseyouhaverunoutofmemorythosemessageswillgototheServersessiontoo.
Youshouldprobablycloseasessiontomakeroomforthenewsession;sendingmessageswillbedifficultfromtheserversession.
SessionscanbeclosedbyhittingAlt-Cwhileinthesession.
IfitisasessionforachannelanIRC/PARTcommandwillbesentautomatically.
LoggingsessionsPreviousversionsofIRCjrloggedallmessagestoasinglefileandyoucouldnotcontrolloggingonapersessionbasis.
Thoseflawshavebeenfixedinthisversion.
Ifyouturnloggingoninasessionanewfilewiththenameofthesessionandtheextension"irc"willbecreated.
Ifthefilealreadyexistsitwillbeappendedtosothatyoudonotloseyourpreviouslog.
Ifthesessionnameislongerthaneightcharactersthefilenamewillonlyusethefirsteightcharacters-thisisalimitationofDOS.
Bydefaultthecurrentdirectoryiswherethelogfilewillbecreatedoropened.
YoucanspecifyadirectorytouseforlogsbyaddingaconfigurationparametertothemTCPconfigurationfile.
(Howtodothatisdescribedlateron.
)Whenyouturnloggingoffthefileisclosed.
YoumayresumeloggingagainatanytimebyusingAlt-L.
Anindicatoronthestatuslinetellsyouifloggingisonoroffforthesessionthatiscurrentlyopen.
IRCjrdoesnottrytodetectwhenyouconnecttochannelswiththesamenameondifferentserversandturnIRCjrloggingon.
Thesamelogfilenamewillbeusedinthatcase.
IRCjrdoeswritetheservernameandfullchannelnameeachtimeitstartsloggingsothisshouldnotbealargeproblem.
Usingattributes(bold,reverse,etc)andmIRCcolorcodesIRCisgenerallyaplaintextservicewithnottoomanyextras.
Youcanhighlightyourmessagesinafewdifferentwaysbyusingafewspecialkeys:Bold:Youcanselectpartsofyourmessagestoappearinboldbyturningboldonwhereyouwantittostartandturningboldoffwhenyouaredone.
ToturnboldonpressCtrl-B-aspecial"block"characterwillappeartosignalthatyouhaveinsertedaspecialattributecommand.
Afterturningboldon,typewhatyouwanttoappearinboldandthenpressCtrl-Btoturnboldingoff.
(TheCtrl-Bbehaveslikeanon/offtoggle.
)YourIRCjrtextdisplayreallyisnotsetuptodisplayatrueboldfacefont.
IRCjrsimulatesboldingbymakingthetextbrighter.
(Trueboldingwouldshowathickerfont.
)Reversevideo:Youcanselectpartsofyourmessagestoappearinreversevideobyturningitonandoffinthesamewaythatboldisused.
ToturnreversevideoonpressCtrl-RandtoturnitoffafteryouaredoneusingitpressCtrl-Ragain.
(Ctrl-Rworkslikeanon/offtoggle.
)Italics:Youcanselectpartsofyourmessagestoappearinitalicsbyturningitalicsonandoffinthesamewaythatboldisused.
ToturnitalicsonpressCtrl-IandtoturnitoffafteryouaredonepressCtrl-Iagain.
(Ctrl-Iworkslikeanon/offtoggle.
)IRCjrcansendtheitalicscode,butitcannotdisplayitalics.
WhensomebodysendsitalicstoIRCjritinsertsthestring""wheretheitalicsattributestartsand""whenitstops.
Underline:Youcanselectpartsofyourmessagestoappearunderlinedbyturningunderliningonandoffaroundthepartsofthetextthatyouwantunderlined.
ToturnunderliningonpressCtrl-UandtoturnitoffwhenyouaredonewithitpressCtrl-Uagain.
(Ctrl-Uworkslikeanon/offtoggle.
)IRCjrcansendtheunderlinecodebutunlessyouarerunningonanIBMMonochromeDisplayoraHerculesadapteritcannotshowunderlinedtext.
(Thisisahardwarelimitation-CGA,EGAandVGAcardscannotshowunderlinedcharactersintextmode.
)WhensomethingsendstheunderlineattributetoIRCjritinsertsthestring""wheretheattributestartsand""whentheattributestops.
mIRCcolorcodesIfyoureallywanttogetfancyyoucaninsertcolorcodesintoyourtext.
IRCjrThereare16differentcolorsyoucanuseandyoucanspecifyboththeforegroundandbackgroundcolor.
TospecifyacolorcodestartbypressingCtrl-K.
Whenyoudoapop-upcolorchartwiththecolorcodenumberswillshowup.
Tospecifytheforegroundcolorenterthenumberofthecoloronthechart.
Ifyouwanttospecifyabackgroundcolorthenaddacommaandthenumberofthebackgroundcolor.
Whenyouaredone,juststarttypingyourmessageandthepop-upcolorchartwilldisappear.
Thebackgroundcolorisoptionalanddoesnothavetobeused.
ToturncoloroffjustenteraCtrl-Kbyitself.
Forexample,thefollowingsequenceofkeyswillgiveyoutheword"Hello"writteninredonayellowbackground:4,8HelloWhilethissequencewilljustgiveyoutheword"Red"withthedefaultbackgroundcolor:4RedSomepeoplefinecolorcodesannoying,sodon'tgooverboard.
Reset(turnalloff)TodisableanyattributesthatmighthavebeensetuseCtrl-O.
Thespecial"box"characterwillbeshownwheretheCtrl-Owasinserted.
Afterthatpointthetextyousendshouldbenormalwithnobold,reverse,italics,underliningorcolor.
SelectingyourdisplaymodeandsizeIRCjruseswhateverthecurrentdisplaymodeisonyouractivescreen.
Soifyouwanttouseaparticularnumberofrowsandcolumns,setupthedisplaymodefirstusingyourfavoriteutilityandthenstartIRCjr.
CGAandMDAusersdonothaveanychoices-only80x25isavailable.
EGAuserscanuse80x25or80x43textmode.
VGAuserscanuse80x25,80x43or80x50textmode.
SVGAusersmaybeabletousea132columnscreeniftheirhardwaresupportsit.
(DOSBoxwithSVGA_S3emulationhasa132x43modewhichisbeautiful;usemode54togetit.
Othercardswillvary.
)IfyouhaveamonochromedisplayandacolordisplayonthesamemachinechoosethedisplayyouwanttouseusingtheDOSMODEcommandfirst.
IRCjrwilldetectthecurrentactivedisplayanduseit.
OptionalConfigurationParametersYouonlyneedthethreeconfigurationparametersexplainedearliertostartusingIRCjr.
ButthereareotherconfigurationparametersyoucanusetoalterIRCjr'sbehavior,customizingittoyourneeds.
HereisthelistofIRCjroptionalconfigurationparametersyoucanuse:IRCJR_PASSSpecifyaconnectionpasswordIRCJR_CONNECT_TIMEOUTSetthetimeoutperiodforthesocketconnectIRCJR_REGISTER_TIMEOUTSetthetimeoutfortheregistrationprocessIRCJR_BACKSCROLLSet#ofbackscrolllinesforeachchannelIRCJR_BACKSCROLL_CHATSet#ofbackscrolllinesforeachchatsessionIRCJR_BACKSCROLL_SERVERSet#ofbackscrolllinesfortheserversessionIRCJR_COLOR_SCHEMEOverridethedefaultcolorschemeIRCJR_TIMESTAMPSTurntimestampsonatprogramstartIRCJR_LOGGING_DEFAULTTurnonloggingatprogramstartIRCJR_LOG_DIRSpecifyadirectoryforlogfilesIRCJR_NICK_UPDATESSpecifywherenicknameupdatesgotoIRCJR_QUIT_UPDATESSpecifywherequitnotificationsgotoAndnowforthedetailsonhowtousethese.
.
.
IRCJR_PASSIRCJR_PASSallowsyoutosenda"connectionpassword"duringtheconnectionandregistrationprocess.
Connectionpasswordscanbeusedtoauthenticateregisterednicknamesonmanyservers.
Keepinmindthatconnectionpasswordsarenotverysecure;theyaretransmittedintheclear.
IRCJR_CONNECT_TIMEOUTIRCJR_CONNECT_TIMEOUTcontrolshowlongIRCjrwillwaitforaTCP/IPsocketconnectiontoanIRCserver.
Thedefaultis30seconds,whichshouldbelongenoughforalmostanything.
Butifyourconnectionispoorandyouneedmoretimeyoucansetittosomethinglonger.
IRCJR_REGISTER_TIMEOUTIRCJR_REGISTER_TIMEOUTcontrolshowlongIRCjrwillwaitforaservertorecognizetheclientaftertheTCP/IPsocketiscreated.
Thedefaultis30secondswhichisusuallylongenough,butonabusyserveryoumightneedtoallowformoretime.
IRCJR_BACKSCROLL,IRCJR_BACKSCROLL_CHAT,IRCJR_BACKSCROLL_SERVERTheIRCJR_BACKSCROLL_*settingsareusedtotellIRCjrhowmuchmemorytoreserveforbackscrollbuffers.
Thebackscrollbufferallowsyoutoseelinesthathavescrolledoffofthecurrentscreen.
Thebackscrollbuffersareagreatfeaturebuttheyrequiremorememory.
Thedefaultbackscrollbuffersettingsare:Serversession:50linesChannels:150linesPrivatechats:75linesThesearereasonableformostusers.
Withthesesettings:IRCjrJustconnectingtoaserverrequires~164KBConnectingandjoiningachannelrequires~191KBConnecting,joiningachannelandhavingoneprivatechatrequires206KBThisisabitmorethanintheoriginalIRCjrbutstillmanageable.
Onan512KBsystemyoucanbeonninedifferentchannelswithagenerousamountofbackscrollineverychannel.
Youcansetthebackscrollbufferstobelarger,butyouarelimitedbyhowmuchRAMyouhaveavailable.
WhenIRCjrrunsoutofmemoryyouwillnotbeabletoopennewsessionstochatinnewchannelsorreceivemessagesfromprivateusers.
Itwillputprivatemessagesintheserverwindow,whichisuglybutwillwork.
Youwillprobablybehappierifyouclosesomeidlesessionstogetsomememoryback,orreducethenumberofbackscrolllinesbyusingthesesettings.
(Ifyouarereallytightonmemoryyoucandisableaclassofbackscrollbuffersbysettingthemto0.
)IRCJR_COLOR_SCHEMEIRCJR_COLOR_SCHEMEonlyhasonesettingatthemoment-CGA_MONO.
ThisisusefulformachinesthathaveCGAcardsbutuseanLCDormonochromemonitorwherethedifferentshadesofgrey,greenorambermightbedifficulttodistinguish.
Settingthiswillgiveyouahighcontrastcolorscheme.
IRC_TIMESTAMPSIRC_TIMESTAMPSisusedtoturntimestampsonwhentheprogramfirststarts.
Thedefaultistostartwithouttimestampsturnedon.
WhiletheprogramisrunningyoucanalwaysturnthetimestampsonbyusingALT-T(atogglesetting),butifyouusuallydothatthenyoucanusethissettingtomakethatthedefault.
IRCJR_LOGGING_DEFAULTIRCJR_LOGGING_DEFAULTallowsyoutospecifythedefaultfortheloggingstate.
NormallytheprogramdoesnotlogthecontentsofsessionsunlessyouturnloggingonusingAlt-L.
Ifyouseethis"on"theloggingwillbestartedbydefaultassoonastheprogramstarts.
IRCJR_LOG_DIRIRCJR_LOG_DIRallowsyoutospecifyadirectorypathwherelogfileswillbewrittento.
BydefaultlogfilesarewrittentowhateverthecurrentdirectoryiswhenIRCjrstarts.
IfyouwanttospecifyadirectoryenterithereinstandardDOSformatwithadriveletterandbackslashesasthepathdelimiter.
(Afullorrelativepathcanbespecified.
Thepathmustendinabackslash.
)Logfilesarealwaysappendedtoandneverdeletedoroverwritten.
IRCJR_NICK_UPDATESIRCJR_NICK_UPDATESallowsyoutotellIRCjrwheretosendnicknameupdatesgeneratedbyotherusers.
Fouroptionsareavailable:noneNonicknameupdateswillbeshownanywhereIRCjrserverNicknameupdateswillbeshownontheserversessioncurrentNicknameupdateswillbeshownonthecurrentopensessionallNicknameupdateswillbeshownonallsessionsPreviousversionsofIRCjrusedtheequivalentof"all"whichcouldgetannoyingonbusychannels.
Thecurrentdefaultis"none".
IRCJR_QUIT_UPDATESIRCJR_QUIT_UPDATESallowsyoutotellIRCjrwheretosendthenotificationsthataregeneratedwhenotherusersdisconnectfromtheserveryouareusing.
ThesamefouroptionsasusedbyIRC_NICK_UDPATESareavailable.
PreviousversionsofIRCjrusedtheequivalentof"all"whichcouldgetannoyingonbusychannels.
Thecurrentdefaultis"none".
HereisanexampleofanmTCPconfigurationfilewiththeseparametersset:IRCjrDHCPVERDHCPClientversionApr262009TIMESTAMPSunApr2617:59:542009#Parametersformymachine;yourmachinewillbedifferent#packetint0x60mt576hostnameDOSBox#IRCjrparmsircjr_nickZoidbergircjr_userJzoidbergircjr_nameJohnFZoidberg#Allparametersafterthisareoptional#IRCconnectionpasswordircjr_passsecretgoeshere#Usetheseforreallyslowserversircjr_connect_timeout45ircjr_register_timeout60#Setupforlargebackscrollbuffersircjr_backscroll375ircjr_backscroll_chat150ircjr_backscroll_server100#Usethisifyouneedahighcontrastscreenircjr_color_schemecga_mono#Turntimestampsonatthestartircjr_timestampson#Turnonloggingbydefaultandlogtoaspecificdirectoryircjr_logging_defaultonircjr_log_dire:\data\irclogs\#Sendnicknameupdatesandquitnotificationstotheserversessionircjr_nick_updatesserverircjr_quit_updatesserver#DHCPgeneratedsettingswillappearhere.
.
.
Obviously,substituteinvaluesthatmakesenseforyourmachine.
"Zoidberg"isagreatnamebutitisprobablyalreadytaken.
Recentchanges2013-03-30Addoptionsforwheretosendnickupdatesandquitmessages.
2013-03-01Add132colsupport,mIRCcolorcodes,PASScommand,improvedlogging,additionalconfigurationoptions,moreCTCPcommands,miscbugfixes2012-04-29Fixesforcompatibilitywithmoreservers2011-09-15AddabilitytoeditinputbeforesendingitIRCjr2011-05-20ClientToClientProtocolsupport;Parseadditionalservermessages;Minorcosmeticandbugfixes2011-04-06Multiplesession/virtualwindowsupport;Addhighcontrastcolorschemesetting;Smallperformanceenhancements.
2010-11-27MiscTCPlibrarychangestoimprovehandlingwhenbuffersarefull;Watcomruntimeworkaround:improvecompatibilitywitholdermachinesNetcatNetcatIntroductionNetcat(nc)isautilitythatcansendandreceivedatausingaTCP/IPsocket.
Ithastheabilitytoopenaconnectiontoanothermachineortolistenforincomingconnections.
Inputcanbeenteredinteractivelythroughthekeyboardorredirectedinfromafile.
Outputcanappearonthescreenorredirectedtoafile.
Nccanbeusedtosendlargefilesorshortmessages,anditcanbecalledfromwithinbatchfilestoo.
Anystatusmessagesthatnetcatcreatesthatarenotpartofthedatareceivedfromthesocketaresenttostderr.
Thisensuresthatifyouredirectthesocketoutputtoafilethatonlythedatathatcameacrossthesocketwillbeinthatfile.
Specialhardwareorsoftwarerequirements:NoneUsingNetcatNetcatusesthefollowingsyntax:nc-target[options]nc-listen[options]Thefirstformofthecommandisusedtocreateasocketconnectiontoanothermachine,asaclientprogramnormallywould.
Thesecondformofthecommandisusedtomakencwaitforanincomingconnectionfromanothermachine,asaserverprogramnormallywould.
InterestedingettingstartedquicklySkipdowntothesectionentitled'Examples'.
Thediscussionofoptionsisfairlylong.
NetcatOptionsOptionsare:-helpShowbasichelptext-verbosePrintextrastatusmessages-binTreatstdinandstdoutasbinarystreams-telnet_nlSendandreceivenewline(NL)asTelnetnewline(CR/LF)-echoTurnonlocalechoing-wWaitsecondsfortrafficafterstdincloses-nocorcDonotCloseonremotecloseNetcat-srcportUseasthesourceportwhenconnectingUsage:First,somebackgrounddefinitions:Newlinecharacter(NL):Thisvariesdependingonthecomputerandoperatingsystembeingused.
ForMS-DOS:AnewlineiscomposedofaCR/LFpairForUnix:AnewlinecharacterisanLFForinternetprogramsusingtheTelnetNVTstandard:AnewlineiscomposedofaCR/LFpair.
Socket'closes'InthiscontextasocketisaconnectiontoanothermachineusingTCP/IP.
Thesocketisafullduplexconnection-eachsidecansendatthesametime,andeachsideistreatedasapeer.
Whenasocketconnectionis"closed"itmeansthatoneonesideoftheconnectionhassignaledthatitisdonesendingdata.
Thesocketstillexists,andthesidethatdidthecloseisstillfreetoreceivedatafromthesocket-itjustcan'tsendanymoredata.
Theothersideoftheconnectionisfreetosendmoredatatothehalfthatdidtheclose,butitshouldnotexpecttobeabletoreadanymoredatafromtheclosedhalf.
Itisonlywhenbothsideshaveclosedtheirhalfofthesocketthatthesocketconnectionisterminatedandcleanedup.
Mostprogramscommunicatingviaasocketuseaprotocoloverthesocketthatwarnsbothsideswhentheconnectionisgoingtobeclosed.
Thatallowsthemtoclosetheirhalfofthesocketandendtheapplicationwhilebeingassuredthattheothersideisgoingtocloseandexittoo.
Netcat'sdefaultbehavioristocloseandexitwhentheothersidecloses,butthiscanbeoverridden.
Netcatdefaultoperation:Withnoextraoptionsnetcatwillbehaveasfollowsafteraconnectionismade:InputwillcomefromthekeyboardandbesentoverthesocketDatareceivedonthesocketwillbewrittentothescreenPressingCtrl-Zatthekeyboardwillspecifytheendofinputandcloseyourhalfofthesocketconnection.
Itwillalsoterminatethesocketconnectionandendnetcateveniftheothersideoftheconnectionhadnotclosedtheirhalfofthesocket.
(Itisexpectedthattheothersidewillclosewhentheyseeyouclose.
)PressingtheEnterkeywillgenerateaUnixnewlinechar(LF)UnixnewlinecharactersreceivedonthesocketwillbeconvertedtoMS-DOSnewlinecharacters(CR/LF)Iftheremotesidedoesacloseontheirhalfofthesocketnetcatwillcloseyourhalfofthesocketandexit.
(Thiscanbeoverridden.
)Eachkeystrokeissentinaseparatepacket.
ThereisnolineeditingcapabilitybecausethatwouldblockNetcatthereceiptofincomingdatafromthesocket.
Therearenosurpriseshere,unlessyoucomefromanentirelyDOSuniversewherenewlinecharactersarealwaysaCR/LFpairinsteadoftheUnixstylenewlinewhichisanASCIILF.
Redirectingstdinandstdoutfrom/tofilesYoucanspecifythatstdinshouldbereadfromafileorthatstdoutshouldbewrittentoafile.
JustusethenormalDOSredirectioncharacterstodothis.
Netcatbehaviorwhenstdin/stdoutareredirectedissimilartoitsdefaultbehavior,exceptforthesechanges:Ifnetcatdetectsthatstdinisredirectedfromafileitwilltrytoreadlargechunksofthefileinasinglereadoperationandthensendthosechunksinlargepackets.
Thisismoreefficientthanthenormalbehaviorwhennetcatisreadingfromthekeyboard.
IfnetcatdetectsthatstdinisredirectedfromafileitwillcloseitshalfofthesocketwhenEOFishitonstdin.
Thiswillcausenetcattoterminatethesocketconnectionandexitwhethertheothersidehadclosedtheirhalfofthesocketornot.
(Thereisanoptiontochangethisbehavior-see"-w".
)Netcatoptions(details)-verboseVerbosemodegivesyouextrastatusmessagethattellyouwhenthelocalsideortheremotesideclosedtheirconnection.
Thesemessagesarewrittentostderrsotheywillnotaffectdatathatyouredirecttoafileonstdout.
-binMS-DOScantreatfilesaseitherBINARYorTEXT.
InBINARYmode:Allcharactersarereadandwrittenexactlywithnochanges.
TheEndofFile(EOF)isdeterminedbythefilesize,notaCtrl-Zchar.
Ifyouarereadingfromthekeyboard(andnotaredirectedfile)thenyouneedtouseAlt-Xtoclosetheconnection,asCtrl-ZwillnotbeinterpretedasEOF.
InTEXTmode:WhenwritingonstdoutUnixnewlinecharacters(LF)willbeconvertedtoMS-DOSnewlinecharacters(CR/LF).
WhenreadingfromstdinMS-DOSnewlinecharacters(CR/LF)willbeconvertedtotheUnixnewlinecharacter(LF).
ACtrl-ZwillbeinterpretedasEndofFileIfyouaretransferringbinarydata,use-bintoensurethatnetcatandMS-DOSdonotalteryourdatainanyway.
IfyouareworkingwithnormalASCIItextthenusethedefault,althoughbinarymodemightworktoo.
NetcatBinarymodeisgoingtoperformmuchbetterthanthenormaltextmodebecauseinbinarymodenoattemptismadetoprocesstheincomingandoutgoingcharacters,savingonprocessingtime.
Note:Youcanuse-binevenifyouarenotredirectingstdinandstdouttoafile.
Thebehaviorchangeisthesamewhetheryouareredirectingornot.
-telnet_nlThestandardforsendingnewlinecharactersacrosstheinternetusingtheTelnet"networkvirtualterminal"(NVT)istosendaCR/LFpair.
ThisisbecausesomemachinesuseCR,someuseLF,andsomeuseotheroddballcharacters.
IfyouareconnectingtoaservicethatusestheTelnetNVTstandardthenturnthisoptionon.
ThiswillconvertyouroutgoingnewlinecharacterstotheTelnetstandardofCR/LF.
ServiceslikeHTTP,FTP,SMTP,etc.
allusetheTelnetNVTstandardsotheywillprobablyworkbetterwiththisoption.
IncomingCR/LFpairswillbetranslatedtonormalnewlines.
Thisoptioncannotbemixedwith-bin.
Ifyouneedbinarymode,thenturningon-telnet_nlmakesnotsense.
(Slightlyfuntrick.
.
MS-DOSusesthesamenewlinecharactersastheTelnetNVTstandard.
Soyoucanprobablyuse-bininplaceof-telnet_nl.
But-binchangesotherthings,soitisprobablybestnottomesswithit.
)ThisoptiondoesnotturnnetcatintoaTelnetclient-itonlychangesthewaythatnewlinecharactersaresentandreceived.
ItwillnotdoTelnetoptionnegotiation,whichisanimportantpartoftheTelnetprotocolthatarealTelnetserverwillneed.
ButthisoptionwillhelpyouconnecttoFTP,SMTPandotherserversthatusetheTelnetNVTstandardbutnotdoTelnetoptionnegotiation.
-echoBydefaultnoechoingofcharactersisprovided.
Ifyouturnthisonanycharactersfromstdinwillbeechoedtostdout.
Iftheothersideisechoingyourcharactersandyouturnthisonyouwillseethingstwice.
Keepinmindthatbecauseweareechoingtostdoutwiththisoption,yourlocalinputwillshowupinstdoutevenwhenyouredirectstdouttoafile.
-wThedefaultistoclosethesocketconnectionandexitfromnetcatwhenEOFisdetectedonstdin.
Thiscanbeaproblemiftherewasdatainflightfromtheothersideatthetimethesocketwasclosed.
(Youwillmissthedatathatwasinflight.
Thisismorelikelytohappenwhenstdinisredirectedfromafile,asnetcatwillsenditveryquicklyandhitEOFpossiblybeforetheothersidehashadachancetodoeverything.
)Togetaroundthisthe-woptiontellsnetcathowlongtowaitfordatatocomefromtheothersideafteryoursideofthesockethitsEOFonstdin.
Thiscangivenetcatachancetoreceivethelastofthedatafromtheothersidebeforeclosingtheconnection.
isthenumberofsecondstowait.
Netcat-nocorcCorcstandsfor"CloseOnRemoteClose",so-nocorcmeansdon'tdothat.
Bydefaultifnetcatdetectsthattheothersidecloseditshalfofthesocketconnectionitwillclosethesocketandexit.
ThiswillhappenevenifEOFwasnotyetdetectedonstdin.
WiththisoptionnetcatwillignoretheclosefromtheothersideuntilEOFisdetectedonstdin.
Thisoptionprobablyisnotveryusefulformostpeople,butifyouareexperimentingwith'halfclosed'socketsitcanbeveryuseful.
-srcportBydefaultifyouareconnectingtoanothermachinenetcatwillusearandomportnumberasthesourceportonyourmachine.
Ifforsomereasonyouneedtospecifyasourceportforyourmachineyoucanusethisoption.
KeyboardHandlingBydefaultnetcatreadsinteractivelyfromthekeyboard.
Thisisnormallystraightforward,buttherearesomethingsyoushouldknow.
Inbinarymode:Ctrl-ZissentasASCII26anddoesnotmarkEOF.
(Youmustsignal'EOF'usingAlt-X.
)EnterissentasASCII13(CR).
Ctrl-EnterissentasASCII10(LF).
Allotherkeysaresentexactlyastheyareread.
Intextmode:Ctrl-ZmeansEOFforstdin,andwillcloseyourhalfofthesocket.
EnterissentasaUnixnewline(LF)Ctrl-EnterisalsosentasASCII10(LF).
(Nochangefromabove)TosendarawCRuseCtrl-M.
Intextmodewith-telnet_nlturnedontheEnterkeychangesslightly:EnterissentasatelnetNVTnewline(CR/LF)TosendarawCRuseCtrl-M.
TosendarawLFuseCtrl-JOrCtrl-Enter.
Specialkeys:Whetheryouarereadingfromthekeyboardornotthefollowingkeyswillalwaysbehonored:Alt-ETogglelocalechoingonandoffAlt-HHelpNetcatAlt-XCloseyourhalfofthesocketconnectionAlt-SShowStatusCtrl-BreakUnconditionalexitAlt-Sisreallyhandy,asitwillshowyouiftheothersidehasclosedtheirhalfoftheconnectionornot.
Ifyouaredoingalargefiletransferitcanalsoshowyouhowmanybyteshavebeensentandreceived.
EnvironmentvariablesTwoenvironmentvariablesareprovidedtohelptailornetcattoyourmemoryandperformancerequirements.
READBUFDefault8192,Range512to32768Use:Setsthesizeofthebufferusedtoreadfromstdinwhenstdinisredirectedfromafileonyourlocaldisk.
Biggernumbersgenerallyresultinhigherperformance.
Useasmallernumberifyouaretightonmemoryandneedtocutbackonwhatnetcatwhatstouse.
Ifyouarelowonmemory4KBisareasonablesettingthatwillnothurtperformancetoomuch.
Thisenvironmentvariablehasnoeffectwhenyouarereadingfromthekeyboard.
WRITEBUFDefault8192,Range512to32768Use:Setsthesizeofthebufferusedtowritetostdoutwhenstdoutisredirectedtoafileonyourlocaldisk.
Biggernumbersgenerallyresultinhigherperformance.
Useasmallernumberifyouaretightonmemoryandneedtocutbackonwhatnetcatwhatstouse.
Ifyouarelowonmemory4KBisareasonablesettingthatwillnothurtperformancetoomuch.
ForbothvariablesDOSlikesitbestifyouuseapowerof2,oratleastamultipleof512bytes.
OthernumberswillcauseextraworkforDOSandlimitperformance.
Examples(andQuickstart!
)nc-target192.
168.
2.
107Opensasocketconnectionto192.
168.
2.
10onport7.
Yourkeystrokeswillbesentanddatacomingbackwillbedisplayedonthescreen.
(OnaUnixmachineport7istheechoservice,soyoushouldseeeverythingthatyousend.
)nc-target192.
168.
2.
51234newfile.
txtListensonport2000foraconnectionfromaremotemachine.
Whentheconnectionisestablishedanyincomingdataissenttonewfile.
txt.
Whentheremotemachineclosestheconnectionnetcatexitsautomatically.
nc-listen3000-nocorc>newfile.
txtSimilartoabove,butnetcatdoesnotautomaticallyexituntilitistoldto.
(Thisisnotterriblyusefulwhenredirectingfiles,butisusefulwhenusingnetcatinteractively.
)nc-targetwww.
cnn.
com80-telnet_nl-verbose-echoConnecttotheHTTPserveratwww.
cnn.
comonport80.
AutomaticallyconvertnewlinestotelnetNVTnewlines,enableverbosestatusmessages,andstartwithlocalechoingturnedon.
(Ifyousend"GET/"withoutthequotesandpressEnter,youwillgetawebpageback!
)NetworkprintingIfyouhaveanetworkattachedprinterthatsupports"raw"printingonTCP/IPport9100thenitispossibletosendfilesfromyourDOSmachinetotheprinterforprintingusingthefollowingsteps:SendyouroutputtoaDOSfileinsteadofaprinter.
Theoutputfileneedstobeinaformattheprinterunderstands,suchasPCLforprintersthatusePrinterControlLanguageorPostScriptforprintersthatusethat.
(ThisimpliesthatyourDOSprogramhasasuitableprinterdriverforyourprinter.
)Sendtheoutputfiletotheprinterusingthenetcatcommand:nc-target9100-binSubstitutewiththeIPaddressofyourprinterandwiththefilenameyourprogramgeneratedwhenyousaid"printtofile.
"Forexample,onmyprinter:nc-target192.
168.
2.
209100-binOptionsare:-helpShowahelpmessage-countTellpinghowmanypingpacketstosend-sizeSetthesizeofthetestdataineachpacketBydefaultpingwillsendfourpacketsandeachpacketwillhavea32bytetestmessageinthem.
Thetotalpacketsizewillbe60bytes,includingtheTCP/IPheaders.
Youcantellpingtosendmorepacketsortosendbiggerpackets.
Thetestdataportionofapacketcanbeupto256bytesinsize.
Pingsendsonepacketpersecond.
Hereissomesampleoutput:mTCPPingbyMBrutman(mbbrutman@gmail.
com)(C)opyright2009-2015Version:May22015ICMPPacketpayloadis256bytes.
Packetsequencenumber0receivedin151.
30ms,ttl=45Packetsequencenumber1receivedin155.
55ms,ttl=45Packetsequencenumber2receivedin154.
70ms,ttl=45Packetsequencenumber3receivedin149.
60ms,ttl=45Packetsequencenumber4receivedin148.
75ms,ttl=45Packetssent:5,Repliesreceived:5,Replieslost:0Averagetimeforareply:151.
98ms(notcountinglostpackets)PingYoucanpressCTRL-CorCTRL-BREAKtostop.
Ifyoupinganon-existentmachineyouwilleithergetaDNSerrormessageoranARPfailure.
FunnotesNormaltimerresolutionunderDOSislimitedto55milliseconds.
ThisishowfasttheBIOStimerclicks,anditworksouttoabout18timesasecond.
Pingcanmeasuretimedownto0.
85milliseconds.
Todothisitreprogramsthehardwaretimertogenerateinterruptsfaster,andthenonlypassesthecorrectnumberofinterruptstotheBIOScode.
ThiswayBIOSkeepscorrecttrackofthetimeandeverythingelseworksasitshould,whilePingcanget1millisecondaccuracywhileitneedsit.
Thistechniqueishighlyaccurate-tryit!
Recentchanges2012-04-29Fixpacketlengthproblem2010-06-21PortedtoOpenWatcom2009-09-30Higherresolutiontiming2009-09-25InitialversionPktToolPktToolIntroductionPkttoolisasmallutilitythatcan:scanmemoryforloadedpacketdriversreadstatisticsfromaloadedpacketdrivercaptureanddisplaypacketsflowingonyournetwork(packetsniffer)ThefirsttwofunctionsareusefulwhentryingtodiagnoseproblemswithanEthernetcardonyoursystem.
Thepacketsnifferfunctionisanadvancedfunctionthatcanhelpyoudiagnoseproblemsonyournetwork.
Specialhardwareorsoftwarerequirements:NoneUsingPktToolNosetupisrequired.
UnlikemostofthemTCPprograms,pkttooldoesnotusethemTCPconfigurationfile.
Allyouneedistohaveyourpacketdriverloaded.
Pkttoolhasthreeprimarycommands,eachofwhichmayhaveoptions.
Thecommandsare:scanscanmemoryforloadedpacketdriversstatsreadstatisticsfromaloadedpacketdriverlistencaptureanddisplaypacketsflowingonyournetworkScanningforpacketdriversToscanforloadedpacketdriversusethescancommand:pkttoolscanmTCPpkttoolbyMBrutman(mbbrutman@gmail.
com)(C)opyright2008-2015Version:Apr122015Scanning:Detailsfordriveratsoftwareinterrupt:0x60Name:NE2000Entrypoint:0192:03CEVersion:11Class:1Type:54InterfaceNumber:0Functionflag:2(basicandextendedfunctions)Currentreceivemode:packetsforthisMACandbroadcastpacketsMACaddress:AC:DE:48:88:99:AAPktToolIfanypacketdriversaredetectedinformationaboutthemwillbedisplayed.
IftheTrumpetDOSTCP/IPTSRisfoundinmemoryyouwillbewarnedaboutit.
mTCPisnotcompatiblewithTrumpetbutbothcanbeusedifyouhaveeachoneassignedtoadifferentpacketdriver.
AfterthepkttoolprogramendstheDOSERRORLEVELvariablewillbesettothenumberofpacketdriversfound,or0ifnonewerefound.
DisplayingpacketdriverstatisticsTodisplaythestatisticstrackedbyeachpacketdriverusethestatscommand:pkttoolstatswhereisthesoftwareinterruptthatthepacketdriverwasloadedat.
Itisahexadecimalvaluerangingfrom0x60to0x80.
Andhereissomesampleoutput:pkttoolstats0x60mTCPpkttoolbyMBrutman(mbbrutman@gmail.
com)(C)opyright2008-2015Version:Apr122015Detailsfordriveratsoftwareinterrupt:0x60Name:NE2000Entrypoint:0192:03CEVersion:11Class:1Type:54InterfaceNumber:0Functionflag:2(basicandextendedfunctions)Currentreceivemode:packetsforthisMACandbroadcastpacketsMACaddress:AC:DE:48:88:99:AAAllstatisticsarefromwhenthepacketdriverwasloaded.
Packetsin:10PacketsreceivedPacketsout:4PacketssentBytesin:2700Bytesreceived(includesEthernetheaders)Bytesout:1210Bytessent(includesEthernetheaders)Errorsin:0ReceiveerrorsErrorsout:0SendingerrorsPacketslost:135Lostduetonohandler,outofbuffers,etc.
Listeningforpacketsonthenetwork:Themostpowerfulfeatureofpkttoolistheabilitytolistenforpacketsbeingreceivedandtogiveyouaquickideaofwhattheyare.
UndernormalcircumstancesanEthernetcardissetuptolistenonlyforpacketsthatareaddresseddirectlytoitorpacketsthataresentforbroadcasttotheentirenetwork.
Aspecialmodeknownas"promiscuousmode"canbeusedtoletthepacketdriverreceiveallpacketsonthewire,regardlessofthedestination.
Pkttoolusespromiscuousmodetoletyouseethosepackets,makingitavaluabledebuggingtool.
PktToolTorunpkttoolinlistenmodeusethefollowingsyntax:pkttoollisten[-v][-raw][-s][-outputfile]where:isthesoftwareinterruptthatthepacketdriverwasloadedat.
Itisahexadecimalvaluerangingfrom0x60to0x80.
-vmeansyouwouldliketoseesomebasicoutputthatshowseachincomingpacket.
(Thinkofitas"verbosemode".
)-rawmeansthatyouwanttoseetherawhexadecimaldataforeachincomingpacket.
-ssaystocaptureonlynbyteswhenusing-rawmode.
Soifyouhavelargepacketsandyouonlycareaboutthefirst128bytes,thisoptionwillletyouonlycapturethefirst128bytesofthoselargerpackets.
-outputfileinstructspkttooltowriteitsoutputtothespecifiedfile.
Whenstartedinlistenmode,pkttoolwillswitchyourEthernetcardintopromiscuousmodeandstartlisteningfortraffic.
Someofthetrafficonyournetworkthatyoumightseeincludes:ARPrequestsIPv4trafficIPv6trafficNetworkswitchmanagementtrafficNotallpossibletrafficwillbevisible;whatyouwillbeabletoseewilldependonyournetworkswitchesandrouters.
Usingthe-voption:Ifyouusethe-voptionyouwillseeoutputlikethisforeachincomingpacket:16:45:34.
06To:30:85:A9:68:E6:60From:00:21:9B:29:79:BELen:80T:0800IPv4:From:192.
168.
2.
100To:216.
58.
216.
132Len:66Type:(17)UDP16:45:34.
11To:00:21:9B:29:79:BEFrom:30:85:A9:68:E6:60Len:131T:0800IPv4:From:216.
58.
216.
132To:192.
168.
2.
100Len:117Type:(17)UDP16:45:34.
72To:33:33:00:00:00:0CFrom:00:21:9B:29:79:BELen:208T:86DDIPv6:From:FE80:0000:0000:0000:FD79:90D5:2FD7:832ETo:FD79:90D5:2FD7:832E:FF02:0000:0000:0000Len:154Type:(17)UDP16:45:35.
21To:FF:FF:FF:FF:FF:FFFrom:00:21:9B:29:79:BELen:60T:0806ARP:Request:192.
168.
2.
100islookingfor192.
168.
2.
129Foreachpacketyouwillseeatimestamp,thedestinationandsourceMACaddress,andtheEthernetpackettype.
(IfyouseeanEthernetpackettypethatislessthan0x0600thatisanolderstyleEthernet802.
3frameasopposedtoanewerstyleEthernetIIstyleframes.
)PktToolIfthepackettypeisARP,IPv4,orIPv6youwillgetsomeadditionalinformationfromthepacket.
Usingthe-rawoption:Ifyouusethe-rawoptionyouwillbeabletoseethedatainthepackets.
ThatdatamightcontainuserIDsandpasswordsthatarenotencrypted.
Becarefulandusethisresponsibly!
Youdonotwanttoleakapasswordbecauseyousharedacoolpackettrace.
.
.
Eachpacketwillbedisplayedasarawhexadecimaldump:00003085A968E66000219B2979BE080045000.
.
h.
`.
!
.
)y.
.
.
E.
001000425D060000801169D9C0A80264D83A.
B].
.
.
.
.
i.
.
.
.
d.
:0020D884DEFA01BB002E38D60CF00C295A1F.
.
.
.
.
.
.
.
8.
.
.
.
)Z.
0030DE33EFC27AAB07814603214340D569C4.
3.
.
z.
.
.
F.
!
C@.
i.
00409C72D85E08E3C29EA6E40948B83CF441.
r.
H.
192.
168.
2.
2000:21:9B:29:79:BE->192.
168.
2.
10030:85:A9:68:E6:60->192.
168.
2.
1Hereyoucanseethatpacketsfromfourdifferentmachineswerespottedbypkttool.
BesidestheexpectedARPandIPv4traffictherewasIPv6traffic,unidentified802.
3stylepackets,andfour"ExtensibleAuthenticationProtocoloverLAN"packets.
PkttoolscansARPtraffictotrytobuildamappingofMACaddressestoIPaddresses.
Thattableappearsattheend.
Itispossiblethatyouwillhavemanymoremachinesonyournetworkthanareidentifiedinthistable.
ThetableonlyusesARPtraffic,whichisthemostreliablewaytodetectwhichMACaddresshaswhichIPaddressassigned.
IfyourunpkttoolforalongenoughtimeyouwillhaveenoughARPtraffictobuildafairlycompletetable.
Recentchanges2015-04-10New!
SNTP(SimpleNetworkTimeProtocol)SNTP(SimpleNetworkTimeProtocol)IntroductionSNTPisasmallutilitythatletsyoufetchthecurrenttimeanddatefromanNTPserverontheinternet.
Thisisusefulifyourmachinedoesnothaveabatterybackedclock/calendarorifyouwanttoadjustforthedriftthatisinherentinmostolderclock/calendarsolutions.
Specialhardwareorsoftwarerequirements:NoneUsingSNTPUsageislikethis:sntp[options]Optionsare:-helpShowahelpmessage-portContactserveronport(default=123)-retriesNumberoftimestoretryifnoanswer(default=1)-setSetthesystemtime-timeoutSecondstowaitforaserverresponse(default=3)TheNTPserverparametercanbeanyNTPserveronthenetwork.
Irecommendusing'pool.
ntp.
org'.
Detailsonthiscollectionofserverscanbefoundathttp://www.
pool.
ntp.
org/.
BeforerunningSNTPyoushouldsetthe'TZ'environmentvariableinDOS.
ThedateandtimethatyougetfromtheNTPserverwillbeinUniversalCoordinatedTimeandneedstobeadjustedforyourlocaltimezone.
TheTZenvironmentvariabletellsthecodewhatyourlocaltimezoneisandhowtomakethatadjustment.
Herearesomeexampletimezonesettings:setTZ=EST5EDT(USEasternStandard,5houroffset,DSTisobserved)setTZ=CST6CDT(USCentralStandard,6houroffset,DSTisobserved)setTZ=UTC-1(OnehoureastofGMT,somewhereinEurope)setTZ=CET-2CDT(TwohourseastofGMT,DSTisobserved)SomeofyoumightnotethatthetimeoffsetisoppositeofwhatWindowsuses.
ThatisbecausetheprogramisusingthePOSIXstandardforsettingtheTZenvironmentvariable.
Sorry,thatisjustthewayitis.
IfyouarewestofGMTtheoffsetispositiveandifyouareeastofGMTtheoffsetisnegative.
IfyouwanttoseethefullrulesforsettingtheTZenvironmentvariableincludinghowtosetitforcomplexdaylightsavingsrules,pleaseseetheOpenWatcomdocumentation:SNTP(SimpleNetworkTimeProtocol)http://www.
openwatcom.
org/ftp/manuals/current/clib.
pdfLookforthesectionentitled"TheTZEnvironmentVariable.
"SNTPusestheUDPprotocoltocontacttheNTPserver.
UDPisnotareliablewaytosendpacketsonthenetwork,sopacketsareoftenlost.
The-retriesoptioncanbeusedtoimprovethechancesthatSNTPwillbeabletogetaresponsefromanNTPserver.
BydefaultSNTPonlytellsyouthetimethatitreceivedfromtheNTPserver.
Ifyouwantthetimetobesetonyoursystemusethe-setoption.
Examples:setTZ=CST6CDTSettimezonetoUSCentralStandardsntppool.
ntp.
orgGetthetimefrompool.
ntp.
orgsntp-retries3pool.
ntp.
orgSameasabove,butretryuptothreetimessntp-setpool.
ntp.
orgSetthesystemtimetotheNTPtimeMiscellaneousnotesSNTPisaccuratetowithinaboutonesecond.
NTPserverswillreturntimestampswithmuchhigherresolutionbutafteryoudealwithnetworkjitteranddelaysitisnotasaccurate.
CombinethatwithDOSwhichhasadefaulttimerresolutionof55msandthereisjustnopointintryingtomakeitmoreaccurate.
Onesecondisgreatformostofusonolderhardware.
Recentchanges2010-08-21InitialversionSpdtestSpdtestIntroductionThisprogramcanbeusedtotestthespeedofyourmachinewhensendingandreceivingdataonTCPsockets.
Ithasnopracticaluseotherthanforbenchmarkingsodon'tinvesttoomuchtimewithit.
ThebasicideaistosendorreceivedatausingtheTCPlibrarywithoutdoinganyextraprocessingonthedata.
Thedatawillnotbecopied,writtentodisk,ormanipulatedinanyway.
ItwillbefullyprocessedbytheTCPlibrarythough,justlikenormaldata-noshortcutslikenotcomputingthechecksumsaretaken.
Thisallowsyoutodeterminethemaximumspeedyoushouldexpectwhensendingorreceivingdata.
Actualapplicationswillbeslowerbecausetheypresumablydowork.
IusethisprogramtotestthespeedofnewversionsofthemTCPcode.
IalsouseittofigureouttherelativespeedofdifferentmachinesandEthernetcards.
Specialhardwareorsoftwarerequirements:NoneUsingSpdtestSpdtestusesthefollowingsyntax:spdtest-target[options]spdtest-listen[options]Thefirstformofthecommandtellsspdtesttocreateasocketconnectiontoanothermachine.
Thesecondformofthecommandisusedtomakespdtestwaitforanincomingconnectionfromanothermachine.
Optionsare:-helpShowbasichelptext-srcportUseasthesourceportwhenconnecting-receiveDoareceiveonlytest-sendDoasendonlytest-mbMegabytestosendduringasendtestSpdtestrequiresanothermachinetoeithersenditdataortoblastdataat.
Toensureagoodbenchmarktheothermachineshouldbefarfasterthanthemachineyouaretesting.
Forexample,Iusea200MhzLinuxmachinetotestmyslowerPCsagainst.
Theothermachineshouldberunningnetcat.
Ifspdtestisdoingasendtestthentheothermachineshouldbesettoreceiveandthrowawaythedataasquicklyaspossible.
Ifspdtestisdoingareceivetestthentheothermachineshouldbesendingafixedamountofdata,hopefullyasfastasitcan.
SpdtestTipsforgettingaccurateresults:BothmachinesshouldbeonthesamenetworkThenetworkshouldberelativelyquietThemachinesshouldbepluggedintoaswitch,notahubThetestshouldrunatleast10seconds,andpossiblyuptoaminute.
Thelongeryourunthemoreaccuratetheresultswillbe.
Timingshouldbedonewithastopwatchandontheothermachine.
SomeEthernetcardandpacketdrivercombinationsholdoffinterruptstoolong,distortingtimeonthemachinerunningspdtest.
Checktheendingmessagesfornetworkerrors.
Thetestshouldruncleanly;networkerrorsareasignofotherproblems.
TelnetTelnetIntroductionThisisasmalltelnetclientlikeothertelnetclientsthatyouhaveprobablyusedbefore.
Besidescommunicatingwithatelnetserverusingthetelnetprotocolitalsoemulatesastandard'ANSI'terminalandhasuploadinganddownloadingcapabilityusingXmodemandYmodemBatch.
Thisparticulartelnetclientfeaturesexcellentscreenupdatingperformanceandasmallmemoryfootprint.
Specialhardwareorsoftwarerequirements:NoneUsingTelnetTelnetusesthefollowingsyntax:telnet[options][port]whereisthenameornumericalIPaddressofthetelnetserveryouwishtoconnecttoand[port]isanoptionalporttoconnecttouse.
Bydefaulttheportissetto23,whichisthestandardtelnetserverport.
Optionsare:-helpShowbasichelptext-debug_ansiCreatetelnet.
logwithsomeextradebuginfo-debug_telnetCreatetelnet.
logwithsomeextradebuginfo-sessiontypeForcetelnetmodeorrawmodeUndernormaloperationifyouconnecttoport23onaserveryouwillbeoperatingintelnetmode.
Thismeansthatthetelnetclientwillexpecttoreceivetelnetoptionsfromtheserver,andwillreplyandtrytonegotiateoptionsettings.
Ifyouconnecttoanyportbesidesport23youwillbeoperatinginrawmode,wherethetelnetclientwillnotrespondtotelnetoptionsanditwillnottrytonegotiateoptionsettings.
Ifyouneedtoconnecttoarealtelnetserveronanon-standardportthenusethe-sessiontypeoptiontoforcethetelnetintotelnetmode,eventhoughyouarenotconnectingtothestandardtelnetport.
Youprobablywillneverneedtospecifyrawmodebutitisthereifyouneedit.
Forexample:telnetbbs.
retroarchive.
orgconnectstoamachinecalled'bbs.
retroarchive.
org'usingthestandardtelnetport(23).
Itexpectstofindatelnetserveratthatportanditwillnegotiatetelnetoptionswiththatserver.
Telnettelnetexample.
com5500connectstoamachinecalledexample.
comonport5500.
Thisisnotthestandardtelnetportsonotelnetoptionsnegotiationwillbedone.
Ifthatmachinereallywererunningatelnetserveratthatportyoucouldforcetelnetmodeusing:telnet-sessiontypetelnetexample.
com5500Tomakethescreenperformancetolerableonoldermachinestelnetwilltakeincomingdataandrenderthecurrentscreenonavirtualbufferbeforetryingtorepainttherealscreen.
Thisapproachusesalittlebitmorememorybutitdramaticallyimprovestheperformanceofthescreenhandling,especiallywhenscrollinglargeamountsofdata.
Youwillnoticethatthescreenwillpauseandstopupdatingwhilethemachineisgettingfloodedwithincomingdata-thisisnormalanditiskeepingyoufromdyingaslowandagonizingdeathwhilethedisplayadapterscrolls.
Aniceside-effectofthevirtualbufferapproachisthatyougetbackscrollcapabilityforfree-ifsomethingdoesscrollpastthescreenyoucanhitPageUpandPageDowntobrowsearound.
Thefollowingspecialkeysarerecognizedwhiletelnetisrunning:PgUporPgDnGoupanddownthroughthebackscrollbufferAlt-HShowacombinedhelpandstatusscreenAlt-BTogglesendingDELcharswhentheBackspacekeyisusedonandoffAlt-ETogglelocalechoingonandoffAlt-NTogglebetweensending[Enter]asCR/NUL,CR/LF,CRorLFAlt-WToggleautomaticwrappingaroundtherightmarginonandoffAlt-RRefreshthescreenfromourlocalvirtualbuffer.
(ShouldnotbeneededunlessIhaveascreendrawingproblem)Alt-DDownloadafileusingXmodemorYmodemBatchAlt-UUploadafileusingXmodemorYmodemBatchAlt-FDroptoDOStorunsomecommands(makeitquick!
)Alt-XExittheprogram(Ctrl-Breakdoesthistoo)Telnetwillwaitfortheservertoclosetheconnectionsothatyoudon'tloseanylastbytesthatwerebeingsent.
IfthisistakingtoolonghitAlt-XagainandmTCPTelnetwillexitimmediately.
Whenyouuseoneofthetoggleoptionsasinglebeepmeansitwasturnedoff,whileabeepfollowedquicklybyahigherpitchedbeepmeansitwasturnedon.
Thefollowingspecialkeysaresenttotheservertohandle:Cursorkeys(Up,Down,LeftRight)HomeInsertBack-Tab(shiftTab)TelnetTelnetprotocolfeaturesandlimitationsThisisn'tafullycomplianttelnetclientimplementation.
Ithasthefollowinglimitations:SGA(ServerGoAhead)mustbeenabledonbothsidesoftheconnection.
Mostserversexpectthisbehavior,asaTCP/IPsocketisafullduplexconnection.
Thisclientwillnotdolocallineediting.
ThisclientdoesnotsupportthetelnetDataMarkcommand.
Thisisnotabigissue,butitmeansthatyoudon'thaveaneasywaytotelltheservertosquelchafloodofoutputifithappens.
AtEthernetspeedsthisshouldnotbeabigproblem.
Itdoesproperlysupportthefollowingtelnetoptions:Binarytransfer(usedduringfiletransfers)Echoing-itwillrequestorlettheserveroffertodoechoing.
Youcanalsoturnonlocalechoing.
Terminaltype-itwillsendtheterminaltypeifaskedforitWindowsize-itwillsendthewindowsizeinrowsandcolumnsifaskedOtheroptionssuchaspassingtheenvironmentvariablesarenotsupported,butthatisnotabigdealconsideringthatyouareconnectingfromaDOSmachine.
(Ifyouhaveaburningdesireforamissingoptionletmeknow.
)UploadingandDownloadingfilesInyeolddaysonewoulduseaterminalemulationprogramwithamodemtogainaccesstoaBBSormulti-usertimesharingsystem.
IfyouwantedtodownloadafileyouusedsomethinglikeXmodem,Kermit,orZmodem.
Downloadingwasslowandagonizing,whichmadetherewardforgettingagoodfilethatmuchmoreprecious.
NowpeopleuseHTTPandFTPtotransferfilesoverbroadband.
Itjustworks.
It'snotinteresting.
Mostpeopledon'tevenknowthatFTPorHTTPexists-theyarejust"gettingafile.
"InordertogiveyouatasteofwhatitwasliketotransferfilesbackintheolddaysIhavefinallyaddedXmodemandYmodemtotelnet!
ManytelnetBBSessupportuploadinganddownloadingthroughtelnetconnectionsandUnixsystemshavesupporteditusingthesx/sbandrx/rbcommandsforyears.
ItisnotasfastasFTPbutyoucandoitrightfromtelnetwithoutquittingtorunanotherprogram.
Onfastermachinesthespeeddifferenceisnotnoticeable.
Protocols:Hereareyouroptionsforuploadinganddownloading:Xmodem:ThisistheclassicprotocoldesignedbyWardChristensenin1977.
Itsendsyourfileinchunksof128bytes;ifyourfilesizeisnotamultipleof128bytesitwillbepaddedtothenext128bytemultiple.
Xmodemdoesnotpreservefilesizesortimestamps.
Youmayonlytransferonefileatatime.
ThedataisprotectedwithaonebytechecksumwhichisprobablycompletelyinadequateforunprotecteddatalinksbutisnotnecessaryovertelnetasTCP/IPdoesitsownerrordetectionandcorrection.
XmodemCRC:ThisisaslightimprovementonXmodem.
Insteadofprotectingyourdatawitha1byteTelnetchecksumitusesa2byteCRC.
ItcanbeusedwithXmodempacketsthatare128bytesinlength(thestandard)or1KBinlength(anextension).
Xmodem1K:ThisismajorperformanceimprovementonstandardXmodem.
Bysending1KBatatimeinsteadof128bytesthroughputisdramaticallyimproved.
ThespeedofXmodemislimitedbyhowquicklythereceivingsidecantellthesendingside"goahead,Igotthatlastpacket"or"thatlastpacketlookedbogus,pleaseresend.
"Xmodem1Kreducesthatoverheadbyafactorofeight,resultinginmuchless"deadair"onthewire.
Xmodem1KisalmostalwaysusedwiththeCRCoption.
YmodemBatch:YmodemisanimprovementoverXmodeminseveralways.
Itsendsthefilename,filesizeandtimestamptotheremotesideinaspecialheaderpacketsothatyoudon'thavetore-enterthenameorworryaboutthefilesizeandtimestampbeingaltered.
Ymodemisabatchprotocolsoitcanbesetuptosendmultiplefilesatatime.
YmodemusestheCRCoption;normally1KBpacketsareusedbut128bytepacketsmightbeseenneartheendofafiletransfer.
Todownloadafile(orfiles)givetheserverthecommandtostartsendingthefile(s)andthenpressAlt-D.
Youwillneedtoselecttheprotocoltouse-besurethismatcheswhattheothersideisgoingtouse.
Ifyouhaveamismatchthefiletransferwillprobablyfail.
IfyouchooseoneoftheXmodemvariantsyouwillhavetoenterthefilenametosavethefiletoandthesavedfilesizewillberoundeduptothenext128bytesize.
Thefiletimestampwillalsobesettothecurrenttime,asXmodemdoesnotpreservethefiletimestamp.
IfyoudownloadusingYmodemBatchjustselecttheprotocolandthetransferwillstart.
Thefilenameisautomaticallyreceived,thefilesizewillbeexact,andtheoriginalfiletimestampfromtheserversizewillbepreserved.
(Almost-IfyourunusingDOSBoxthefiletimestampisnotpreservedbecauseofalimitationinDOSBox.
)Ifyoutrytodownloadafilethatalreadyexistsonyoursystemyouwillbepromptedtoseeifyoureallywanttowriteovertheexistingfile.
Ifthefilecannotbeoverwrittenforsomereasonthenthetransferisaborted.
Thiscanhappenifthefilenamehappenstobethesameasadirectoryonyourlocalmachine.
TouploadafilegivetheserverthecommandtostartreceivingthefileandthenpressAlt-U.
Selectaprotocoltouse,andenterthenameofthefiletosend.
WhenuploadinganddownloadingusetheESCkeytoabortthefiletransfer.
XmodemandYmodemtransfersarenormallycanceledbysendingaspecialcharacter(Ctrl-X)atleasttwotimes.
mTCPTelnetwilldothisforyou,butifyouneedtocancelafiletransfermanuallyjusthitCtrl-Xafewtimesandbepatient.
(YoumightneedtodothisifyoustartedthefiletransferontheothersideandchangedyourmindbeforestartingitonthemTCPTelnetside.
)Allfileoperationshappeninthecurrentdirectory.
Seethesectionon"ShellingtoDOS"fordetailsonhowtochangedirectoriesandmanagefiles.
Limitationsonfiletransfers:WhenreceivingusingYmodemyoucantelltheothersidetosendmorethanonefileatatime.
ButwhensendingyoucanonlysetupmTCPTelnettosendjustonefileatatime.
Filenamesmustbein8.
3format.
Thesendingandreceivingofpathsisnotsupported.
TelnetThereisnoYmodemG.
YmodemGsupportonothersystemsisoftenimplementedwrong,ordoesnotexistatall.
Itisjustnotworththehassle.
NotesforLinux/Unix:Ifyouhavelrzszpackageinstalledthenyouhavethefollowingcommandsavailable:rx-receiveontheserversideusingXmodemrb-receiveontheserversideusingYmodemBatchsx-sendfromtheserversideusingXmodemsb-sendfromtheserversideusingYmodemBatchAllofthesecommandshaveabadhabit-theywritetostderrwhichinturnappearsonstdout.
Andthatcanmessupyourtransfer.
Togetreliabletransfersfromthesecommandspipetheoutputofstderrtoafileor/dev/nul.
Forexample:sxdosfile.
exe2>stderr.
txtThatwillsendthefiledosfile.
exefromLinuxtothemTCPTelnetclient,pipingtheoutputonstderrtoafilecalledstderr.
txt.
(Thisassumesyouareusingbashforyourshell.
Ifyouuseadifferentshellfigureouthowtopipestderrusingthatshell.
)Thesendcommands(sxandsb)mightnotuse1KBpacketsizesorCRCbydefault.
NotusingCRCisnotanissueovertelnet,butnotusing1KBpacketscanslowyoudownquiteabit.
Usethe"-k"optiontosetupfor1KBpackets.
(AndusingCRCneverhurtseither.
)AnotherneattrickistoenablearawTTYsessionbeforeyoustartyourfiletransfer.
Thiswillpreventtheterminaldriverfrominterpretingcharactersandinjectingorremovingextracharactersfromthedatastreamwhileyourtransferisinprogress.
Toenablerawmodeuse"sttyraw",andtoreturnthingstonormaluse"sttysane".
ThissamplesequenceillustratesthesafestwaytotransferafileusingUnix:sttyraw;sxmyfile2>stderr.
txt;sttysaneThatsequenceputstheTTYinrawmodeandstartsafiletransferusingXmodemwhilepipingtheextraneousoutputtoafilecalledstderr.
txt.
Afterthetransfertheterminalwillbeputbackintosanemode.
sttyraw;sb-kmyfile2>stderr.
txt;sttysaneThissequenceissimilar,exceptthatYmodemBatchwith1KBblocksisused.
Thisshouldbemuchfasterthanthestandardblocktransfersize,whichis128bytes.
NotesforSynchronet:SynchronetBBSisgreat,butithasabadhabit.
WhenusingYmodembatchitwillappendextrabytestoyourfiletoinsertanadvertisementforSynchronet.
Thiskindofdefeatsthepurposeofpreservingtheoriginalfilesize.
WhileIappreciatetheeffortthatgoesintomaintainingSynchronet,thisisbadbehavior.
TelnetShellingtoDOSSometimesyoumayneedtosuspendtelnetandexecuteDOScommandswhilestillconnectedtoaserver.
Youmightneedtodothismanagefilesthatyouhavejusttransferred.
TheAlt-F(File)keyintelnetallowsyoutodothis.
WhenyouusethisfunctiontelnetwillbesuspendedandyouwillbedroppedataDOSprompt.
Youcanexecutecommandshere;Iwouldlimitittojustafewsecondsandonlyusingsimplecommands.
Forexample,ifyouneedtodeleteapartiallydownloadedfile,changedirectories,orcheckadirectoryforfilesthisfunctionisideal.
Donotdoanythingthatmightalterthescreenmode;thescreencontentswillberestoredbuttelnetisnotexpectingthemodetochange.
WhileyouareattheDOSshelltelnetisnotprocessinganyincomingEthernetpackets.
Ifyoureceivesomethingfromtheothersystemtheconnectionwilltimeoutandyouwillbedisconnected!
Keepingthatinmind,donotusethisfunctionifyouareexpectinginputfromtheotherside.
WhenyouaresittingataUnixcommandpromptitisprobablysafe;doingitwhileadirectorylistingiscomingdownisdefinitelynotsafe.
Usethe"exit"commandattheDOSprompttoreturntotelnet.
ANSIEmulationNotesFullblownANSIterminalemulationisacomplicatedmess.
AllofthedifferentvariationsofANSIemulationovertheyearshavenothelpedanythingeither.
Toputitpolitely,I'vedonethebestIcanandyoumightstillseescreenrenderingproblems.
Thatbeingsaid,I'vetriedtodoareasonablegoodjobofinterpretingANSIescapesequencesandrenderingthemproperly.
TheANSIemulationdoesnotdependonANSI.
SYSoranyotherconsoledevicedriver-itisallinternaltotheprogram.
Iusedafewsourcestodeterminetherequiredsetofescapesequences,includingtheLinuxTERMCAPentriesforafewANSI-liketerminals,includingthegenericANSIterminaldefinitionandafewrelatedPCflavors.
TheemulationisgoodenoughformetowritethisdocumentationusingVI,browseintextmodewithLynx,runthe'screen'programtogetafewvirtualterminals,usethe'info'commandtobrowsetheterminfowriteup,andrunsomeofthemorecomplicated'system-config-*'commandsprovidedwithFedora.
Hereareafewnotestoimproveyourexperience:Unicode:Thistelnetclientdoesn'thaveUnicodesupportinit,sosendingathreebytesequencetoitandhopingthatyouwillgetaUnicodecharacterwillnotwork.
TheeasiestwaytosuppressthebogusUnicodecharactersistosetyourLANGenvironmentvariablesothatitdoesn'ttriggerUnicodesupport.
Forexample,onmyrecentLinuxboxesLANGlookslikethis:echo$LANGen_US.
UTF-8Setittoen_USinsteadlikethis:exportLANG=en_USTelnetCodepages:ThestandardcodepagebuiltintothemonochromecardortheCGAcardiscodepage437.
Noothercodepagesarepossibleifyouareusingthesetwovideocards.
SetLynxtousecodepage437toavoidgettingweirdcharacters.
EGAandVGAusersmaybeabletogetothercodepagesloadedintomemoryusingcountry.
sysandotherDOSconfigurationcommands.
Ihavenotexperimentedwiththisyet,butintheoryyoushouldbeabletouseothercodepageswithtelnetbydoingthat.
(Ifyoutrythisoutpleaseletmeknowhowitworks!
)TerminalTypes:Bydefaultifthetelnetserveraskstypetypeofterminalisconnectingthiscodewillreportbackas'ANSI'.
Thishappensduringtelnetoptionnegotiation.
Ifyouwanttoexperimentwithotherterminaltypessupportedbyyoursystemthenyoucanchangethestringthatgetsreported.
Seethesectionentitled'AdvancedSetup'forinstructionsonhowtodothis.
IfyoujustwanttomakeatemporarychangemostUnixsystemshaveaTERMvariableintheenvironmentthatyoucanalter.
Dependingonyoursystemtheremaybeseveralsuitableterminaltypestoexplore.
OlderLinuxsystemshaveover20variantsofANSIterminalstochoosefrom.
NewerLinuxsystemsmightjusthave'ANSI'and'PCANSI'tochoosefrom.
Lookin/usr/share/terminfo/forpossibletermcapdefinitionstoplaywith.
IfyouwanttomakeacustomtermcapforthisprogramcontactmeandI'lltellyouexactlywhatIimplemented.
MonochromeAdapterUsers:Themonochromeadapterdoesnotdisplaycolor,butitdoeshavetheabilitytounderlinecharactersproperly.
Ifyouareonatruemonochromedisplayadapter(MDA)thenyoushouldsetyourterminaltypeto'pcansi-mono',orsomethingsimilarthattellstheserverthatyouhaveaterminalwithtrueunderliningcapability.
ThestandardANSIsettingwillwork,butwillnotenableunderlining.
Specialnote:TelnetBBSesandMUDsNoteverythingoutthereclaimingtobeatelnetserverisactuallyrunningacomplianttelnetserverthatdoestelnetoptionnegotiation.
AlotoftelnetBBBesandmulti-userdungeonsfallintothiscategory.
Ifyouarehavingtroubletryingtoconnecttosomethingthatisnotastandardtelnetserver,tryusingthe"-sessiontyperaw"option.
YouwillstillgetANSIemulationbutallofthetelnetprotocolnegotiationcodewillbedisabled.
Thisisdoneautomaticallywhenyouconnecttoanythingotherthanport23.
Assumingthatworks,youmightneedtoturnonlocalechoingusingAlt-E.
[Enter]keyhandlingThetelnetstandardspellsoutthata"newline"characteriscomprisedofaCR(carriagereturn)followedbyaLF(linefeed).
Butitisnotclearwhatitmeanswhenauserpresses"Enter"ataterminal;thatistraditionallyjustaCRthatgetssenttotheserver.
Thismakesthestandardambiguous.
TelnetAftertwoyearsofstrugglingwiththeambiguityIthinkIhavefoundsomethingthatworksformosttelnetservers.
Bydefaultpressingthe"Enter"keywillsendaCR/NULpair.
Ifyouneedsomethingdifferentforanon-standardtelnetserveryoucanuseAlt-Ntotogglebetweenthefollowingoptions:CR/NUL,CR,LF,CR/LF.
Thehelpscreenwillshowyouthecurrentsetting.
RegardlessofthissettingyoucanalwayssendaCRbypressingCtrl-MandsendaLFbypressingCTRL-J.
AdvancedsetupTherearesomeoptionsthatyoucanspecifyintheMTCPCFGfiletooverridedefaultbehavior,suchastheinitialstateoftoggles.
Belowisthelist:TELNET_VIRTBUFFER_PAGESTelnetmakesscreenaccessfastbywritingtoavirtualscreenbufferinmemory,andthenupdatingtherealscreenasneeded.
isthenumberofvirtualscreenpagestostoreinmemory.
Validvaluesarefrom1to8.
TELNET_CONNECT_TIMEOUTisthenumberofsecondstowaitforaconnectiontotheTelnetserver.
Thedefaultis10seconds.
TELNET_AUTOWRAPSetto0tospecifynoautowrapor1toturnautowrapon.
Thedefaultistoturnautowrapon.
TELNET_SENDBSASDELSetto1tosendaDELcharacter(ASCII127)whentheBackspacekeyishitinsteadofsendingaBackspacecharacter(ASCII8).
ThedefaultistosendDEL.
TELNET_TERMTYPEReportasyourterminaltypeduringTelnetoptionnegotiation.
Thedefaulttermtypeis'ANSI'.
TELNET_SEND_NEWLINEChoosewhichcharacterswillbesentwhenyoupressyourEnterkey.
ThevalidvaluesforTELNET_SEND_NEWLINEare"CR/LF","CR","LF","CR/NUL",or"AUTO".
ThedefaultisAUTO,whichusesCR/NULunlesstelnetbinarymodeisenabled.
IfbinarymodeisactivethenjustaCRwillbesent.
(Youdon'thaveanydirectcontroloverbinarymodesodon'tworryaboutit.
)Seethesectionon[Enter]keyhandlingabovefordetails.
)Examples:TELNET_SEND_NEWLINEAUTODefault:useCR/NULorjustCRautomaticallyTELNET_SEND_NEWLINECR/LFSendbothCRandLFatalltimesTelnetTELNET_SEND_NEWLINECRSendjustaCRTELNET_SEND_NEWLINELFSendjustanLFTELNET_SEND_NEWLINECR/NULSendCR/NULRecentchanges2015-01-23Add132columnsupport;makeTelnetwaitfortheservertoclosetheconnectionsothelastbytesbeingsentarenotlost.
Codecleanupchangestoreducesize.
2013-03-15Addscrollregionsupport;AddDECOriginMode;addafewmoreCSIandESCsequences;consolidatescreenupdatingcode.
2012-04-29Fix[Enter]handling;AddXmodemandYmodemfiletransfer2011-09-11Fixtelnetoptionsbug2011-05-18AddAlt-Ntotogglebetweensending[Enter]asCR/LF,CRorLF2010-11-27MiscTCPlibrarychangestoimprovehandlingwhenbuffersarefull.
Watcomruntimeworkaround:improvecompatibilitywitholdermachines2010-06-21PortedtoOpenWatcom.
Note:TheCGAsnowcodehasbeenremovedtemporarily.
2010-04-22MaintenancereleasefortheunderlyingTCPlibrary.
TCPchecksumsshouldbecomputedcorrectlyallofthetimenow,andaremuchfaster.
2010-03-21Fixabuginvolvingserverswithhighnumberedtelnetoptions.
2009-12-27Addlocalechoingtoggle;Bugfix:[Enter]keyshouldsendCR/LF,notjustCR;Bugfix:Monochromedisplayswerefreezing;Bugfix:Monochromedisplayswerenotunderlining;Add-sessiontypecommandlineoptionandimplementrawmode2009-12-12AddsupportforcursorpositionreportingAdvancedTopicsDebuggingproblemsDebuggingproblemsIntroductionWelcometothewonderfulworldofDOSnetworking!
Ifyouarereadingthisyouareeitherboredoryouhaveaproblem.
Hopefullythiswillhelpyougetpastyourproblem.
Keepinmindthereisawidevarietyofhardwareoutthereincludingemulatorsonmodernmachineswhicharetechnicallynotevenhardware!
Thisguidewillgiveyousomepointersonhowtogetpastproblemsbutitisgoingtotakesomework.
Thisguideisbrokenupintotwoparts-[1]debugginghardwareandpacketdriverproblemsand[2]debuggingmTCPproblems.
BesidesthisguidecheckouttheinstructionsforthePKTTOOL.
EXE.
PKTTOOLcantalktoaloadedpacketdriverandgetstatisticsfromit,allowingyoutoseeifthepacketdriverisseeinganypackets"onthewire.
"Thereisalsoapacketsniffertoolthatwillletyoulookatthetrafficonyournetwork.
(Hint:ifyouneverseeanytraffic,thenthereissomethingwrong!
)HardwareandpacketdriverproblemsNote:SomeofthismightnotapplytoPCIcards.
ParallelportdevicesliketheXircomPE3seriesrequiretheparallelporttobecorrectlyconfigured.
Seriallineusers(SLIPorPPP)needtoensurethattheirCOMportsaresetupcorrectly.
Dowhatmakessenseforyourspecificsetup.
mTCPwillnotworkifyourEthernetcardisnotsetupcorrectly.
Hereisapartiallistofthingsthatcantripyouup:I/OportsLikeanyPChardware,yourEthernetcardneedstobesetuptouseI/Oports.
TheI/Oportscannotbesharedwithothercards,eitheronpurposeorbyaccident.
Ifthereisaconflictwithanothercardyouwillgetflakyoperationormaybeevenrandomcrashes.
IfyourpacketdriverloadsandreportsthecorrectMACaddressforyourEthernetcardyouprobablyhavetheI/Oportsetcorrectly.
(Youmightstillhaveconflictswithothercardsthough.
)AMACaddressisauniqueidentifierthatis48bitslongusuallywritteninhexadecimalnotationwithacolonseparatingeachbyte.
Forexample,02:31:BE:D1:2F:08.
TheMACaddresscanusuallybefoundprintedonastickeronthecard.
AMACaddressthatisall00s(00:00:00:00:00:00)orallFFs(FF:FF:FF:FF:FF:FF)isprobablynotcorrectandindicatesthatthepacketdriverisnottalkingtothecard.
IftheMACaddressreportedbythepacketdriverdoesnotmatchtheMACaddressprintedonthecardthenitispossiblethatithasbeenchangedonthecard,butitismorelikelythatyouhavethewrongI/Oportaddress.
DebuggingproblemsHardwareInterrupts(IRQ)YourEthernetcardprobablyneedsahardwareinterruptassignedtoitsothatitcantellthepacketdriverwhenanewpackethasarrivedonthewire.
TheIRQhastobesetonthecardsothatitisnotsharedwithanyotherhardwareinyoursystem,includingdevicesthatmightbeonyourmotherboard.
PCandXTclasssystemsgenerallyhaveveryfewinterruptsavailable.
IRQ0,1,and6areusuallyalwaysusedorunavailable.
IRQ2,3,4,5,and7maybeavailabledependingonwhatelseyouhaveinyoursystem.
ATclasssystemshavemorechoicesforinterrupts.
UnlikeanXTclasssystem,IRQ2isnotavailableonanATclasssystem.
IftheIRQisnotsetcorrectlythenyourcardmaybeabletosendpacketsbuteachtimeitreceivesapacketitwillnotbeabletotellthepacketdriveraboutit.
Thiswilllooklikeyourcardisneverreceivingpackets.
SharedMemoryAllEthernetcardsusesomememorytostoreincomingandoutgoingpackets.
SimpleEthernetcardskeepthatmemoryonthecardinaprivateareathattherestofthecomputercannotsee.
Bettercardsexposethismemorytothecomputerwhichimprovesperformancebutrequiresyoutofindamemoryrangethatdoesnotconflictwithothercardsormotherboardsettings.
TheNE1000cardisanexampleofacardthatdoesnotusesharedmemory.
(TheNE1000justneedsI/OportsandanIRQ.
)TheWesternDigital8003seriesisanexampleofcardthatdoesrequiredsharedmemory.
Itmightneedtoshow8KBor32KB(dependingonthecard)tothesystem,requiringthatmuchspacefreeinyourmemorymap.
CardsthatusesharedmemorywillgenerallyneedspaceintheareareservedforexpansioncardswhichrangesfromC000:0000toF000:0000.
Besuretopickarangethatdoesnotconflictwithotherdevices.
CablingselectionBesidesthebasicresourceallocationsettingsabovetheremaybeothersettingsthatyouhavetomakeonthecard.
Onegoodexampleissettingthecabletype-somecardsmakeyousetjumperstochoosebetweentheAUIport,Thinnetconnector,orRJ45connector.
Ifthisissetwrongthecardwillappeartoworknormallybutwillnotbeabletosendorreceivedataonthewire.
BadcablingornetworkconnectionEvenwithaproperlyconfiguredcardyoucanstillencounterproblems.
Believeitornot,cablesgobad.
Ifyoususpectacablingproblemfindanothercablethatyouknowworksandusethatinstead.
Cablesarecheapsothereisnoreasontowrestlewithapotentiallybadone.
MostEthernetcards,hubsandswitcheshaveindicatorlightsthattellyouifagoodconnectionhasbeenmade.
Examineyourindicatorlightsandensurethatyourhardwarethinksthereisaconnection.
Useaknowngoodportonyourswitchorhubifyouevengetahintofaproblemwiththeportyouareusing.
SomecablemodemsareconfiguredtoonlyhandoutalimitednumberofaddressesandwillrefusetohandoutDebuggingproblemsmore.
Youmayneedtoresetthecablemodemtoclearitslistofclients.
Switchesandhubsaregenerallyreliablebutsometimescyclingthepower(turningthemoffthenon)clearsupproblems.
OlderEthernetcardsposespecialchallenges.
BeforemodernEthernetstandardizedonCAT5cablingtherewasThickNetandThinNetcabling.
ThickNet(theoriginalEthernet)wasoftensupportedbyusingtheAUIportonacardwithanexternaltransceiver,whileThinNetwasoftendirectlyconnectedtothecard.
Thecardwouldhavetobeconfiguredtouseoneportortheotherportandchoosingthewrongportwillmakeitlooklikeyouhavebadcabling.
Evenoncardsthatlookliketheysupporttwistedpairwiring(CAT5)thesignalingmightnotbecorrect,andthusnotworkonmodernswitchesandhubs.
ForexampleolderWD8003seriescardshavebothanAUIportforanexternaltransceiverandanRJ45jackwhichacceptsaCAT5cable,butitactuallyusesLattisnetwhichisnotcompatiblewithEthernetsignaling.
Itiscloseenoughtomakeahuborswitchlightuptheport,butnotcloseenoughtoenabledatatransfer.
PacketdriverFirst,ensureyouhavetherightpacketdriverforyourcard!
PacketdriversareveryspecifictomodelsofEthernetcards.
Ialwaystrytolookforthepacketdriverfromthemanufacturerthatwasshippedwiththecard.
IfIcan'tfindthatImightuseapacketdriverfromacardinthesamechipsetfamily.
AgoodsourceforpacketdriversforoldercardsistheCrynwrpacketdrivercollectionathttp://www.
crynwr.
com/.
ThoseguysdefinedthepacketdriverspecificationanddidalotoftheearlyworktomakepacketdriversavailableforISAcards.
Sourcecodefortheirworkisavailable,whichisanaddedbonus.
IfyourEthernetcardissetupcorrectlyyoushouldknowtheI/Oportandothersettingstopasstothepacketdriveronthecommandline.
Packetdriverscandetectsomeconfigurationproblemsormismatchesbutnotallofthem,sobesureyouhavethesettingsthatmatchyourcard.
ThePKTTOOL.
EXEprogrammightprovidesomeinsightastohowthepacketdriverisbehaving.
SeethedirectionsforitinPROGRAMS/PKTTOOL.
TXT.
CollectingmTCPtracesIwouldratherhaveyoubelievethatmTCPisperfect,butweknowthatnothingeveris.
Butwecanstrive.
.
.
Ingeneral,themTCPcodeistoocomplexforacasualusertotrytodebug.
IfIreallydohaveaprobleminthecodewearegoingtoneedtotakeatracesothatIcanseewhatisgoingwrong.
EvenifmTCPisactingnormallyyoumightstillbehavingproblemsrelatedtoyournetworkorsetup.
TomakedebuggingandfixingproblemseasierIhaveincludedsometracingfeaturesinthelibrary.
ToenabletracingyouneedtosettwoDOSenvironmentvariablesbeforerunninganmTCPprogram.
TheLOGFILEvariablesetsthenameofatextfilewheretraceoutputwillbewrittento.
TheDEBUGGINGvariablesetsthedesiredleveloftracingtobeused.
Forexample:setDEBUGGING=127setLOGFILE=logfile.
txtDebuggingproblemsThosetwolinesspecificloglevel127(tobeexplainednext)andthatlogfile.
txtshouldholdthetrace.
TracingcanbeslowsomTCPletsyouchoosehowverboseyouwantthetracingtobe.
ThenumberusedontheDEBUGGINGenvironmentvariablecontrolsthis.
HerearetheusefulvaluesforDEBUGGINGthatyoucanuse:1Warningsonly3Warningsandapplicationmessages127Fulltracingexceptforpacketcontents255FulltracingwithsomepacketcontentsThebiggerthenumbertheslowerthemachinewillget.
Tracescanalsogetquitelarge.
OnslowermachinestracingwillcauseanoticeableoverheadbecauseoftheextradiskI/O.
Thenumberisactuallybasedonabitmask,soifyouwanttobeselectiveyoucanturnonspecifictypesoftracemessages.
Thebitpositionsare:0x0001Warnings0x0002General-usedbyapplications0x0004ARP-usedbyARP0x0008IP-usedbytheIP/ICMPlayer0x0010UDP-usedbyUDP0x0020TCP-usedbyTCP0x0040DNS-usedbyDNS0x0080PacketdumpingNowthatyouknowthebitvariablesyoumightalsofinditusefultoknowthatsettingtheDEBUGGINGvariablecanalsobedoneusingahexadecimalvalue.
Forexample:setDEBUGGING=0x7FTurnsonalltracingexceptforpacketdumping,andisequivalenttothe"127"levelshowninthepreviousexample.
Withthedebugtraceturnedonitispossiblethatyouwillhaveacrashandnotseeallofthedebugmessages.
Thisisbecausethedebugmessagesarebufferedanddependingonthetimingthebuffermaynotbefullyflushedatthetimeofthecrash.
Ifyouwanttobeabsolutelysurethatalltracemessagesareflushedandvisiblethereisabittoflipthatwillaggressivelyflushthebuffersaftereachtracepointiswritten:0x8000TurnonaggressivebufferflushingSoforexample,ifyouwantfullpackettracingwithnormaltracefilebufferbehavioruse:setDEBUGGING=0xFFAndifyouareparanoidandyouwanttomakesurethatyouseeeverytracemessage,fliptheextrabitanduse:setDEBUGGING=0x80FFDebuggingproblemsIfyouhaveatracethatyouwouldlikemetoreadsenditalongwithabriefexplanationofwhatyouweredoingandwhatyournetworksetuplookslike.
IhavebeenabletohelpafewpeoplegetupandrunningthiswayandIhavefixedcountlessofmyownbugswithit.
PPPSetupPPPSetupIntroductionWhilemTCPisdesignedforEthernetcardsitispossibletouseitwithPPP(Point-to-PointProtocol)connections.
ThischapterdescribeshowtosetupmTCPandaLinuxhosttouseaPPPconnectionovertheserialport.
SLIPconnectionsaresimilarbutarecoveredinthenextchapter.
PrerequisitesItisassumedthatyouarefamiliarwithmTCPconfigurationandthatyouhavesomeknowledgeofLinuxsystemadministration.
Itispossibletouseotheroperatingsystemsbymappingthenetworkingconceptspresentedheretothoseotheroperatingsystems.
Aknowngoodconnectionbetweenthemachines.
Thisisusuallydonewithanullmodemcable.
YouneedtoverifythislinkworkswithterminalemulationsoftwarebeforeyoustartwithPPP-itmakesdebuggingmucheasierifyoustartwithaknowngoodsetup.
TheDOSPPPpacketdriver.
Downloadaknownworkingversionfromhere:http://www.
ibiblio.
org/pub/micro/pc-stuff/freedos/files/net/dosppp/dosppp06.
zipOtherPPPdriversarepossible;IusedDOSPPPasanexample.
OnekeypointisthatwhateverPPPdriveryouuseshouldemulateanEthernetcardformTCP.
mTCPisexpectingtouseapacketdriverthatisdesignedforEthernet;thatisknownasa"class1"packetdriver.
mTCPdoesnotworkwithotherclassesofpacketdrivers,includingserial(class6)andTokenRing(class3).
DOSPPPgetsaroundthislimitationbytellingmTCPthatitisanEthernetcardeventhoughitisactuallyusingtheserialport.
NetworksetupfortheexamplesprovidedhereMyhouseisconnectedtotheoutsideworldwithacablemodemthatgivesmeadynamicallyallocatedaddressontheglobalinternet.
Thatisconnectedtoahomerouter,whichthenfeedsthemachinesinthehouse.
Therouterdoesnetworkaddresstranslation(NAT)toprovideprivateaddresseswithinthehouse.
CableModemRouterMachines96.
x.
x.
x192.
168.
2.
1192.
168.
2.
xNormallyIuseEthernetconnectionsonmyDOSmachinessotheylooklikeanyotherPCinthehouseandcanconnecttotherouterdirectly.
ToaddaDOSmachineusingPPPoneofthemachinesinthehousehastoconvertfromEthernettoPPP.
IuseanolderLinuxmachinetodothis.
Hereiswhatthenetworkdiagramisgoingtolooklike:PPPSetupCableModemRouterLinux96.
x.
x.
x192.
168.
2.
1192.
168.
2.
10|192.
168.
2.
17DOS(192.
168.
2.
18)TheLinuxmachinehasanEthernetcardanditisassignedaddress192.
168.
2.
10.
Thatisastaticassignment;itneverchanges.
TheDHCPserverintherouteristoldnottogiveoutanyaddressesbelow192.
168.
2.
100sotherewillnotbeaconflict.
ToenablePPPtheLinuxmachinewilltakeonasecondnetworkaddress.
Thatnetworkaddressmustbechosencarefully.
Hereistheprocess:Pickanumberthatisdivisibleby4.
Nomachineinyourhouseshouldhaveamachinewiththatnumberorthenextthreenumbersafterit.
YourLinuxmachinewillhavethatnumber+1YourDOSmachinewillhavethatnumber+2Theothertwonumberswillbereservedandunused.
Donotstartwith0or252.
Forexample,thefollowingaddresseswouldbevalidinthisscheme:LinuxDOSReserved192.
168.
2.
5192.
168.
2.
6192.
168.
2.
4and192.
168.
2.
7192.
168.
2.
17192.
168.
2.
18192.
168.
2.
16and192.
168.
2.
19192.
168.
2.
161192.
168.
2.
162192.
168.
2.
160and192.
168.
2.
163Otheroptionsareavailable,butthoserequireadvancedroutingtricks.
Justfindablockoffouraddressesdivisiblebyfourthatarenotinuse,followtherulesabove,andyouwillbefine.
(I'lltellyouthehardwaythataddsnewsubnetforabeerortwo.
)EstablishthePPPconnectiontotheLinuxmachineOntheLinuxsideyouwillbeusingthePPPdaemon.
Theimportantparameterstospecifyare:theserialportthatwillbeusedthespeedoftheport"local"tosettheflowcontrol"lock"toensurethatotherprogramsdonotinterferewiththeport"passive"or"silent"totellPPPDtowaitforaconnectioninsteadoftimingout.
(Passiveandsilentareslightlydifferent,butbothshouldwork.
)"proxyarp"tomakeyourmachinelookasthoughitisvisibleonthenetwork.
AreasonableMTUsize.
576shouldworkfine.
IPaddressesfortheLinuxsideandtheremotesideBeforeyoufireupthePPPdaemonensurethatnothingelseisusingthatserialport.
Ifyouhavea"getty"processrunningonthatporttoallownormalloginsyouwillneedtodisableit.
TheserialporthastobeclearforPPP.
(Usethepscommandtolookforagettyprocessthatmightbeusingit.
)Forexample,onmyLinuxsystemIusethefollowingcommandline:PPPSetuppppdttyS19600locallockpassiveproxyarpdefaultroutemtu576192.
168.
2.
17:192.
168.
2.
18(Allofthatshouldbeonthesameline.
)InthissetupI'llberunningat9600bpsovermysecondserialport.
TheLinuxmachinewillgetanewnetworkinterfacecalledppp0withaddress192.
168.
2.
17anditwillbetalkingtotheDOSPCwhichwillhaveanaddressof192.
168.
2.
18.
IfsuccessfultheLinuxmachinewillreturnsilentlytothecommandlinebutthePPPdaemonwillberunninginthebackgroundwaitingforanewconnectionfromtheDOSmachine.
Youcanverifythisusingthepscommand.
OntheDOSmachineweneedtorunEPPPDtocompletetheconnection.
Hereweneedtospecifytheserialportandthespeedtouse.
IusethiscommandonmyDOSmachine:EPPPDcom29600localEPPPDisthePPPdriverwithEthernetemulation.
ThisisnecessaryformTCPbecausemTCPiswrittenwithEthernetinmindandcannotuseaseriallinkdirectly.
MyDOSmachinewillbeusingthesecondserialportat9600bpsusingflowcontrolsuitablefordirectlyconnectedmachines.
AfterafewsecondsofdelayEPPPDrespondswith:Installedpacketdriverhandleratvector0x60Nowyouhavealivelinkbetweenthetwomachines.
IfyougobacktotheLinuxmachineandrun"ifconfig"youwillbeabletoseethenewnetworkinterface:ppp0Linkencap:Point-to-PointProtocolinetaddr:192.
168.
2.
17P-t-P:192.
168.
2.
18Mask:255.
255.
255.
255UPPOINTOPOINTRUNNINGNOARPMULTICASTMTU:576Metric:1RXpackets:11errors:0dropped:0overruns:0frame:0TXpackets:13errors:0dropped:0overruns:0carrier:0collisions:0txqueuelen:3RXbytes:170(170.
0b)TXbytes:158(158.
0b)EPPPDwillalsocreateabatchfilecalledIP-UP.
BATwhichsetsenvironmentvariablessuitableforWATTCPprograms.
mTCPwon'tusethoseenvironmentvariablesbutsomeoftheirvaluesareusefultoustoconfiguremTCP.
ConfiguringmTCPforPPPmTCPconfigurationisdoneasnormal,butwithafewchanges:6.
YouneedtosettheMTCPSLIPenvironmentvariabletosomething.
Theactualvaluedoesnotmatter;itjustneedstoexist.
AttheDOScommandlinethiscommandwilldothetrick:PPPSetupSETMTCPSLIP=true7.
YoushouldensurethatyourMTUsettinginthemTCPconfigurationfilematcheswhatyoutoldthePPPdaemononLinux.
Irecommendusingavalueof576.
8.
YouneedtosetuptheIPaddressesstaticallybecauseyouwillnotbeusingDHCPinthissetup.
InparticularyouneedtosettheIPADDR,NETMASK,andGATEWAYvariables:IPADDR:ThisissecondIPaddressyouusedonthePPPdaemonlineinLinux.
Inthisexampleitis192.
168.
2.
18.
NETMASK:Linuxusesanetmaskof255.
255.
255.
255tosignifyapoint-to-pointlink.
mTCPisthinking"Ethernet"soitwantsanetmaskthatreflectstheaddressingschememoreclosely.
Ifyoufollowedtherulesaboveanetmaskof255.
255.
255.
252iscorrectformTCP.
IfyoudidnotpickyouraddressesaspertherulesaboveyoumightbeabletopingtheLinuxmachine,butnotothermachines.
Followthoserulescarefully!
GATEWAY:IfyouplantosendpacketspastyourLinuxmachinetoothermachinestheLinuxmachinewillhavetoserveasyourgateway.
PutitsPPP0addresshere.
Inthisexampleitis192.
168.
2.
17.
IfthesearesetcorrectlyyoushouldbeabletorunPINGontheDOSmachineandgetaresponsebackfromtheLinuxmachine.
At9600bpsona386classmachinethetimeforastandard32bytePINGpacketshouldbearound150ms.
[Themathisprettystraightforward-at9600bpsyougetaboutonebytepermillisecond.
Thestandardpayloadforpingis32bytesandyouneedanIPheader,anICMPheader,andfourmorebytesforthepingidentificationnumberandsequencenumber.
Thetotalbytessentisthatoverhead(28bytes)plusthepingpayloadbytes(32default)foratotalof60bytes.
PPPaddsatleastanother8bytesofframingoverheadtothat,sothetotalbeingsentperpacketiscloserto68bytes.
68bytesat9600bpstakes70.
8mstosendandyouneedtowaitfortheresponsewhichisthesamesize.
Sotheminimumpossibletimewithnoadditionaloverheadis141ms.
]IfyoupingfromLinuxtoDOSyoumightnotgetaresponse;remembermTCPonlyresponsewhenanmTCPapplicationisrunning.
IfyouwanttotrytopingfromLinuxrunsomethingsimpleonthemTCPmachine.
Netcatin"listen"modewilldothetrick:nc-listen2000ThatwillenableyoutotestPINGfromLinuxtoDOS.
Nowyouhavebasicconnectivitybetweenthetwomachines.
Telnet,FTP,IRCjrandotherapplicationswillworkifthetargetmachineisyourLinuxmachine.
NextweneedtoenablesomeadvancedroutingtogobeyondyourLinuxmachinetoothermachinesonyournetworkandtheoutsideworld.
RoutingbeyondtheLinuxmachinePPPSetupThe"proxyarp"optiononthepppdcommandshouldmakeyourmachinelooklikeitisonthenetwork.
IfaremotemachinetriestofindthehardwareaddressofyourDOSmachinerunningmTCPtheLinuxmachinewillsubstituteit'sownhardwareaddress.
Ineffect,itisyourproxyonthenetwork.
ThisisnotsufficientforgettingtomachinespastyourLinuxmachinethough.
YourLinuxmachinestillconsidersthePPPlinktobeaseparatenetwork.
AllweneedtodoistotellLinuxtoroutepacketsfromonenetworktotheother.
Thisisdonebyturningon"IPforwarding.
"echo1>/proc/sys/net/ipv4/ip_forwardDothatasroot.
Afterthat,whenLinuxseesapacketfromanoutsidenetworkitwillrouteittotheDOSmachinerunningmTCP.
Afterthat,youshouldbeabletopingothermachinesonyourhomenetwork.
IfyousetupyournameserverinmTCPyoushouldbeabletogettotheoutsideworldaswell.
Andothermachineswillbeabletopingyourmachine.
AdvancedoptionsWhathasbeenpresentedaboveisthebareminimumtogetaDOSmachinerunningmTCPonalocalhomenetwork.
Yourhomenetworkmightnotlooklikethis,requiringmorework.
Someotheroptionsinclude:RunningIPmasquerading(NAT)ontheLinuxmachine.
RunningthePPPnetworkonadifferentsubnetandhavingLinuxroutingtothatsubnet.
Thisrequiresadvancedroutingonothermachinesinyournetworkifyouareusingnon-routablenetworkslike192.
168.
x.
x.
Allofthisisleftasanexercisetotheinterestedreader.
.
.
SLIPsetupSLIPsetupIntroductionWhilemTCPisdesignedforEthernetcardsitispossibletouseitwithSLIP(SerialLineInternetProtocol)connections.
ThischapterdescribeshowtosetupmTCPandaLinuxhosttouseaSLIPconnectionovertheserialport.
PPPconnectionsaresimilarbutarecoveredinthepreviouschapter.
PrerequisitesItisassumedthatyouarefamiliarwithmTCPconfigurationandthatyouhavesomeknowledgeofLinuxsystemadministration.
Itispossibletouseotheroperatingsystemsbymappingthenetworkingconceptspresentedheretothoseotheroperatingsystems.
Aknowngoodconnectionbetweenthemachines.
Thisisusuallydonewithanullmodemcable.
YouneedtoverifythislinkworkswithterminalemulationsoftwarebeforeyoustartwithSLIP-itmakesdebuggingmucheasierifyoustartwithaknowngoodsetup.
The"EtherSlip"packetdriver.
Downloadaknownworkingversionfromhere:http://crynwr.
com/drivers/pktd11.
zip(ThefilenameinthezipisETHERSL.
COM.
InstructionsareinINSTALL.
DOC.
)OtherSLIPdriversarepossible;IusedEtherSlipasanexample.
OnekeypointisthatwhateverSLIPdriveryouuseshouldemulateanEthernetcardformTCP.
mTCPisexpectingtouseapacketdriverthatisdesignedforEthernet;thatisknownasa"class1"packetdriver.
mTCPdoesnotworkwithotherclassesofpacketdrivers,includingserial(class6)andTokenRing(class3).
EtherSlipgetsaroundthislimitationbytellingmTCPthatitisanEthernetcardeventhoughitisactuallyusingtheserialport.
NetworksetupfortheexamplesprovidedhereMyhouseisconnectedtotheoutsideworldwithacablemodemthatgivesmeadynamicallyallocatedaddressontheglobalinternet.
Thatisconnectedtoahomerouter,whichthenfeedsthemachinesinthehouse.
Therouterdoesnetworkaddresstranslation(NAT)toprovideprivateaddresseswithinthehouse.
CableModemRouterMachines96.
x.
x.
x192.
168.
2.
1192.
168.
2.
xNormallyIuseEthernetconnectionsonmyDOSmachinessotheylooklikeanyotherPCinthehouseandcanconnecttotherouterdirectly.
ToaddaDOSmachineusingSLIPoneofthemachinesinthehousehastoserveasagatewaybetweenEthernetSLIPsetupandSLIP.
IuseanolderLinuxmachinetodothis.
Hereiswhatthenetworkdiagramisgoingtolooklike:CableModemRouterLinux96.
x.
x.
x192.
168.
2.
1192.
168.
2.
10|192.
168.
2.
121DOS(192.
168.
2.
122)TheLinuxmachinehasanEthernetcardanditisassignedaddress192.
168.
2.
10.
Thatisastaticassignment;itneverchanges.
TheDHCPserverintherouteristoldnottogiveoutanyaddressesbelow192.
168.
2.
100sotherewillnotbeaconflict.
(InthiscasemyDOSmachinewithaddress192.
168.
2.
122mightcauseaconflict,butIdon'thavethatmanyDHCPclientsinmyhouse.
)ToenableSLIPtheLinuxmachinewilltakeonasecondnetworkaddress.
Thatnetworkaddressmustbechosencarefully.
Hereistheprocess:Pickanumberthatisdivisibleby4.
Nomachineinyourhouseshouldhaveamachinewiththatnumberorthenextthreenumbersafterit.
YourLinuxmachinewillhavethatnumber+1YourDOSmachinewillhavethatnumber+2Theothertwonumberswillbereservedandunused.
Donotstartwith0or252.
Forexample,thefollowingaddresseswouldbevalidinthisscheme:LinuxDOSReserved192.
168.
2.
5192.
168.
2.
6192.
168.
2.
4and192.
168.
2.
7192.
168.
2.
17192.
168.
2.
18192.
168.
2.
16and192.
168.
2.
19192.
168.
2.
161192.
168.
2.
162192.
168.
2.
160and192.
168.
2.
163Otheroptionsareavailable,butthoserequireadvancedroutingtricks.
Justfindablockoffouraddressesdivisiblebyfourthatarenotinuse,followtherulesabove,andyouwillbefine.
(I'lltellyouthehardwaythataddsnewsubnetforabeerortwo.
)EstablishtheSLIPconnectiontotheLinuxmachineOntheLinuxsideyouwillbeusingtheSLIPdaemon(slattach).
Theimportantparameterstospecifyare:theprotocoltouse(slip,compressedslip,etc.
)theserialporttousethespeedtouseHereisanexample:slattach-pslip-s9600/dev/ttyS1ThatsaystouseplainSLIP(notcompressed)at9600bpsoverthesecondserialportonthemachine.
Ihadadevilofatimetryingtogetmyserialporttowork.
ItlookedasthoughitwasreceivingpacketsfromtheDOSmachinejustfine,butitwasnotabletosendpacketsbecausethehandshakingontheserialportwireswasnotcorrect.
Icouldseethisusingifconfig-packetswerebeingreceivedontheseriallineinterfacebutnotsent.
SLIPsetupSobesidestheparametersaboveIusedthefollowing:"-L"tospecifyalocal("3wire")connection"-m"tonotinitializethelineAndbeforerunningslattachIhadtousesttytosetupthespeedandhandshakingfortheport.
HerearethefullcommandsthatIused:stty-F/dev/ttyS1-clocal-crtscts9600slattach-pslip-L-m-s9600/dev/ttyS1Thesttycommandsetsupthesecondserialporttonotdoflowcontrolorlookforacarrierdetectsignal.
Thespeedwillbesetto9600bps.
Yourresultswillprobablyvaryfrommine.
.
.
slattachcreatesanetworkinterfacebutnothingelse.
NextwehavetotellLinuxwhatIPaddresstouseforthatinterface.
Theifconfigcommandisusedforthat:ifconfigsl0192.
168.
2.
121pointopoint192.
168.
2.
122mtu576upHereIamusing192.
168.
2.
121fortheIPaddressontheLinuxsideandtheDOSsideisgoingtouse192.
168.
2.
122.
(Thespellingof"pointopoint"isdeliberatelymissinga"t"-thatisthecorrectsyntax.
)TheMTUsizefortheconnectionis576,whichisasafevalue.
OntheDOSmachineweneedtorunourSLIPdrivertocompletetheconnection.
UsingEtherSlipasanexample:ethersl0x6030x2f89600ThattellsEtherSlip(ethersl)toinstallusingsoftwareinterrupt0x60onCOM2(IRQ3andport0x2f8)at9600bps.
EtherSlipdoesn'tletyoujustnameaCOMporttouse-itwantsyoutospecifythehardwareinterruptandI/OportaddressoftheCOMportyouaregoingtousedirectly.
Herearethecommonportassignments:COM1:IRQ4,Port0x3F8COM2:IRQ3,Port0x2F8Yourhardwaremayvary.
.
.
butyoutestedthisportwithastraightterminalemulatorfirst,rightIfEtherSlipissuccessfulitwillprintoutsomestatusinformation,includingthe"MAC"addressofthesimulatedEthernetcard.
ConfiguringmTCPmTCPconfigurationisdoneasnormal,butwithafewchanges:1.
YouneedtosettheMTCPSLIPenvironmentvariabletosomething.
Theactualvaluedoesnotmatter;itjustneedstoexist.
AttheDOScommandlinethiscommandwilldothetrick:SLIPsetupSETMTCPSLIP=true2.
YoushouldensurethatyourMTUsettinginthemTCPconfigurationfilematcheswhatyoutoldtheSLIPdaemononLinux.
Irecommendusingavalueof576.
3.
YouneedtosetuptheIPaddressesstaticallybecauseyouwillnotbeusingDHCPinthissetup.
InparticularyouneedtosettheIPADDR,NETMASK,andGATEWAYvariables:IPADDR:ThisissecondIPaddressyouusedontheifconfigcommandinLinux.
Inthisexampleitis192.
168.
2.
121.
NETMASK:Linuxusesanetmaskof255.
255.
255.
255tosignifyapoint-to-pointlink.
mTCPisthinking"Ethernet"soitwantsanetmaskthatreflectstheaddressingschememoreclosely.
Ifyoufollowedtherulesaboveanetmaskof255.
255.
255.
252iscorrectformTCP.
IfyoudidnotpickyouraddressesaspertherulesaboveyoumightbeabletopingtheLinuxmachine,butnotothermachines.
Followthoserulescarefully!
GATEWAY:IfyouplantosendpacketspastyourLinuxmachinetoothermachinestheLinuxmachinewillhavetoserveasyourgateway.
PutitsSL0addresshere.
Inthisexampleitis192.
168.
2.
121.
IfthesearesetcorrectlyyoushouldbeabletorunPINGontheDOSmachineandgetaresponsebackfromtheLinuxmachine.
At9600bpsona386classmachinethetimeforastandard32bytePINGpacketshouldbearound150ms.
IfyoupingfromLinuxtoDOSyoumightnotgetaresponse;remembermTCPonlyresponsewhenanmTCPapplicationisrunning.
IfyouwanttotrytopingfromLinuxrunsomethingsimpleonthemTCPmachine.
Netcatin"listen"modewilldothetrick:nc-listen2000ThatwillenableyoutotestPINGfromLinuxtoDOS.
Nowyouhavebasicconnectivitybetweenthetwomachines.
Telnet,FTP,IRCjrandotherapplicationswillworkifthetargetmachineisyourLinuxmachine.
NextweneedtoenablesomeadvancedroutingtogobeyondyourLinuxmachinetoothermachinesonyournetworkandtheoutsideworld.
RoutingbeyondtheLinuxmachineSofaryouhavea"pointtopoint"connectionbetweenthetwomachinesandtheDOSmachinecannotseepasttheLinuxmachine.
InthissectionwearegoingtodoafewstepstogiveyourDOSmachineconnectivitytotherestoftheworld.
Thefirststepistoturnon"proxyARP"whichisatrickthattellstheLinuxmachinetoanswerARPrequestsfromothermachinesonbehalfofyourDOSmachine,whichisnotdirectlyconnectedtothenetwork.
The"arp-s"commandisusedtosetthisup:arp-s192.
168.
2.
12200:90:27:FC:28:82pubSLIPsetupHerewearetellingtheLinuxmachinethatifitshouldseeanARPrequestforIPaddress192.
168.
2.
122(theIPaddressoftheDOSmachine)thatitshouldanswerwithitsownMACaddress,whichis"00:90:27:FC:28:82".
YouneedtouseyourownMACaddressonyourmachine-usethe"ifconfig"commandtofindoutwhatitisforyourEthernetcard.
Forexample,onmymachine:ifconfigeth0respondswith:eth0Linkencap:EthernetHWaddr00:90:27:FC:28:82inetaddr:192.
168.
2.
10Bcast:192.
168.
2.
255Mask:255.
255.
255.
0inet6addr:fe80::290:27ff:fefc:2882/64Scope:LinkUPBROADCASTRUNNINGMULTICASTMTU:1500Metric:1RXpackets:12914errors:0dropped:0overruns:0frame:0TXpackets:15950errors:0dropped:0overruns:0carrier:0collisions:0txqueuelen:1000RXbytes:1386899(1.
3Mb)TXbytes:1687851(1.
6Mb)whereHWaddristheMACaddressofthisparticularethernetcard.
AfterdoingthisothermachineswillbeabletopingtheDOSmachine.
ThisisnotsufficientforgettingtomachinespastyourLinuxmachinethough.
YourLinuxmachinestillconsiderstheSLIPlinktobeaseparatenetwork.
AllweneedtodoistotellLinuxtoroutepacketsfromonenetworktotheother.
Thisisdonebyturningon"IPforwarding.
"echo1>/proc/sys/net/ipv4/ip_forwardDothatasroot.
Afterthat,whenLinuxseesapacketfromanoutsidenetworkitwillrouteittotheDOSmachinerunningmTCP.
Afterthat,youshouldbeabletopingothermachinesonyourhomenetwork.
IfyousetupyournameserverinmTCPyoushouldbeabletogettotheoutsideworldaswell.
Andothermachineswillbeabletopingyourmachine.
AdvancedoptionsWhathasbeenpresentedaboveisthebareminimumtogetaDOSmachinerunningmTCPonalocalhomenetwork.
Yourhomenetworkmightnotlooklikethis,requiringmorework.
Someotheroptionsinclude:RunningIPmasquerading(NAT)ontheLinuxmachine.
RunningtheSLIPnetworkonadifferentsubnetandhavingLinuxroutingtothatsubnet.
Thisrequiresadvancedroutingonothermachinesinyournetworkifyouareusingnon-routablenetworkslike192.
168.
x.
x.
Allofthisisleftasanexercisetotheinterestedreader.
DOSIdle/PowercontrolforlaptopsandVirtualMachinesDOSIdle/PowercontrolforlaptopsandVirtualMachinesIntroductionPartofthemTCPdesignrequirestheapplicationprogrammertoperiodicallycheckfornewpacketsthathavearrivedsothattheymaybeprocessed.
Thatcheckissupposedtobedonewhentheapplicationisnotactivelyworkingonsomethingelse;itisacoreparttheidleloopinaneventdrivenprogram.
OnoldclassichardwarerunningDOSsuchastheIBMPCorPCjrthispollingbehaviordoesnoharm.
ButitdoeskeeptheCPUbusyandthatcanshowupwhenusingmTCPapplicationsinavirtualenvironmentsuchasVirtualBoxorVMWare.
Asideeffectishigherpowerusagewhichisanimportantconsiderationforlaptopusers.
HowmTCPminimizesCPUusageStartingwiththe2012-04-29versionmTCPapplicationswilltrytominimizeunnecessaryCPUusage.
Whenintheidleloopeachapplicationwillcheckforpacketsandworktodoandifnothingisfoundtheywilltryto"sleep"forashortperiod.
Themechanismstodothisare:CallingtheDOS"idle"interrupt0x28.
TraditionallythisallowsTSRprogramstocomeactivewhileDOSiswaitingforakeystrokebutitisalsoageneralpurposewayforDOStosignalthatthemachineisgenerallyidle.
Callingint0x2Ffunction0x1680.
Thisisthe"VMyieldtimeslice"signal.
Thefirstmethod(int0x28)iscontroversial;manypeoplewillclaimthatitisnotneeded.
IthasexistedsinceDOS2.
xanditisdocumentedasbeingusedbyDOStosignaltoTSRsthatthereisidletime.
Afterdoingalotofresearchandtestingthereisnoreasonwhyanapplicationshouldnotuseittoo,especiallyiftheapplicationdoesnotuseDOSforkeyboardinput(thusdeprivingDOStheabilitytocallint0x28itself.
)IfpowersavingisenabledinmTCP(whichisthedefault)thecallstoint0x28willalwaysbemadeduringidleloops.
Thesecondmethod(int0x2f0x1680)iswelldocumentedandshouldworkinotherenvironmentssuchasDOSboxesinWindows,OS/2,andothervirtualenvironments.
I'vetesteditinWindowsXPwhenusingSwsVpkt.
WhenmTCPfirststartsupitwilluseint0x2ffunction0x1680toseeifthefunctionissupported.
IfitissupportedmTCPwilluseitduringidleloops.
NotesonspecificpowersavingprogramsPOWERThestandardpowermanagementutilityforMSDOSandPCDOSisPOWER.
EXEwhichisinstalledasadevicedriverandcontrolledfromthecommandline.
DOSIdle/PowercontrolforlaptopsandVirtualMachinesWhilePOWERseemstoworktoreduceCPUconsumptionattheDOScommandline,itdoesnothelpwiththemTCPidleloop.
Soitdoesnotharmanything,butitdoesn'thelpeither.
POWERworkscorrectlyonrealhardwareandinVMWare.
ButthecurrentversionofVirtualBoxseemstohaveabugthatcausestheFTPclienttohangupandfreezewhenPOWERisloaded.
IfyouseeweirdbehaviorlikethisunderVirtualBoxgetridofPOWERanduseadifferentutility.
FDAPMFDAPMisanopensourcereplacementforPOWERthatshipswithFreeDOSandcanbedownloadedseparately.
TheFDAPMpowercontrolutilitydetectsthecallstoint0x28toseewhenDOSisidle.
ThishasaverynoticeableeffectwhenrunningmTCPapplicationswithFDAPMloaded;insteadofmakingaprocessorfullybusytheprocessorwillidleatalowCPUutilization.
HereisthecommandlineIusetoenableFDAPM:fdapmapmdosIfyourunthatFDAPMwilldetectcallstoint0x28andtrytoadjustyourhardwaretosavepower.
FormoreinformationonFDAPMgoto:http://help.
fdos.
org/en/hhstndrd/base/fdapm.
htmDOSIDLEDOSIDLEisanolderpowermanagementutilitythatcanreplacePOWER.
I'venotexperimentedalotwithit,butitworkssowellthatitforcedmTCPtosavepowerevenwhenyouhavetoldmTCPnottotrytosavepower!
DOSIDLEcanbefoundathttp://maribu.
home.
xs4all.
nl/zeurkous/download/mirror/dosidle.
html.
DisablingpowercontrolIntheunlikelyeventthatyouneedtodisablethepowercontrolcallsinthemTCPidleloopyoucansetanenvironmentvariable.
Thenameofthevariableis"MTCPSLEEP"andanexampleofhowtosetittodisablepowercontrolisshown:setMTCPSLEEP=0IfyoudothismTCPwillnotattempttocallint0x28orint0x2ffunction0x1680whileitisinanidleloop.
主机参考最新消息:JustHost怎么样?JustHost服务器好不好?JustHost好不好?JustHost是一家成立于2006年的俄罗斯服务器提供商,支持支付宝付款,服务器价格便宜,200Mbps大带宽不限流量,支持免费更换5次IP,支持控制面板自由切换机房,目前JustHost有俄罗斯5个机房可以自由切换选择,最重要的还是价格真的特别便宜,最低只需要87卢布/月,约8.5元/月起!just...
VoLLcloud LLC是一家成立于2020年12月互联网服务提供商企业,于2021年1月份投入云计算应用服务,为广大用户群体提供云服务平台,已经多个数据中心部署云计算中心,其中包括亚洲、美国、欧洲等地区,拥有自己的研发和技术服务团队。现七夕将至,VoLLcloud LLC 推出亚洲地区(香港)所有产品7折优惠,该产品为CMI线路,去程三网163,回程三网CMI线路,默认赠送 2G DDoS/C...
官方网站:点击访问王小玉网络官网活动方案:买美国云服务器就选MF.0220.CN 实力 强 强 强!!!杭州王小玉网络 旗下 魔方资源池 “我亏本你引流活动 ” mf.0220.CNCPU型号内存硬盘美国CERA机房 E5 2696v2 2核心8G30G总硬盘1个独立IP19.9元/月 续费同价mf.0220.CN 购买湖北100G防御 E5 2690v2 4核心4G...
.htaccess为你推荐
linux虚拟主机如何安装LINUX虚拟机注册国际域名哪里的国际域名注册便宜?免费国外空间哪些免费的国外空间最好?速度快.功能大?域名服务域名系统主要是什么?域名购买在网上购买域名 会受骗吗php虚拟空间怎样修改php虚拟空间单个文件上传大小限制天津虚拟主机天津APP开发的比较专业的公司有哪些?域名解析域名解析是什么意思啊?域名服务器什么是服务器和域名已备案域名什么是微信已备案域名
台湾vps 沈阳虚拟主机 重庆域名注册 免费申请网站域名 cloudstack 美国便宜货网站 外国域名 淘宝双十一2018 轻博 长沙服务器 铁通流量查询 湖南服务器托管 e蜗 北京双线 华为云盘 linode支付宝 登陆qq空间 大化网 web服务器 hosts文件修改 更多