The windows socket

445 views

Published on

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
445
On SlideShare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
6
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

The windows socket

  1. 1. The Windows Socket Programming TutorialWelcome to the Windows socket programming tutorial. Here youll find out how to program your owninternet applications. The guide assumes no prior knowledge of programming with Windows Sockets,although you need a working knowledge of C. The tutorial starts off very simple and will eventually build upto an advanced level so you can understand how to program your own code for hacking applications.Please feel free to report any bugs, typos etc. There was one that crept into the pop client in part two of thetutorial, but this has been fixed (cheers Bone Digger).Theres also the potential for a buffer overflow in the program (cheers mnemonix). I havent bothered to fixthat as there are lots of areas in all the programs which need better error trapping (virtually non-existent onpurpose to keep the code easier to follow and understand). I will be putting a fully debugged and errortrapped program example in the final part of the tutorial to show how to develop all of the frameworksillustrated into robust code. As this is going to be a custom firewall, it will need it ;)Ive had quite a few requests for C tutorials since I started this guide. There are plenty of beginners tutorialsout on the web. Ive downloaded and reviewed quite a few rather than write my own. If you havent used Cbefore, I would recommend the following guide :-Coronado Enterprises C Tutor version 2This is an excellent beginners guide and covers virtually everything you will need to know to understand thesocket programming tutorial. Its also freeware. Ive included it on the menu under downloads. File size is192kB. I did not write the C tutorial, but if you have any questions about it, Id be more than happy to answerthem as Im recommending it.If you dont have a C compiler for windows, you can download the Windows port of the Linux GCCcompiler package. You will also need the RSXNTDJ package to allow you to program apps for Windows.Both of these packages (along with many other useful tools) are freely available fromhttp://www.delorie.comPart One of the Socket tutorial describes in more detail what you will need and how to set up the compiler. The Rota
  2. 2. Internet Programming with Windows - A Tutorial Part 1 By Gandalf Gandalf@dhamma.org.uk (c) Feb 2000ContentsIntroductionWhat You Will NeedCompiler CommentsThe InternetProtocolsThe Windows TCP/IP StackOur First Program Using TCP/IP - WHOIS.CConclusion and What’s NextIntroductionI decided to write this tutorial mainly as a means of getting my headaround programming Internet applications under the Microsoft WindowsOS. This is a topic that is not always easy to understand. There aremany web sites, references and books on the subject, but it takes alot of hard work to plough through them all to sift the good stufffrom the junk.Let me say one thing from the start. I dont like Windows, never haveand I suspect I never will. Ive been a Unix and Linux user (Minixbefore Linux came out) now for longer than I care to remember. Linuxis probably the best and easiest OS to use for developing Internetapplications. There are lots of applications and programs availablefreely for Linux, most with freely available source code. WheneverIve wanted to develop a specific tool under Linux, Ive done whatprobably most Linux users do...download pieces of code and patch inwhatever else is needed to perform the required task. It’s pretty easyto do without necessarily understanding the underlying principles.Yeah, things go wrong, but a bit of tweaking usually gets you there inthe end.So why did I decide to do this under Windows?Good question.I started to use Windows more and more since Win95 came out as myprofession called for me to keep up with understanding Windows as wellas Unix. When I found myself having to develop Windows applications, Iimmediately started using Visual Basic so I could code easily ratherthan have to learn Windows programming with C++. Ive been a Cprogrammer for about 15 years, but mainly on Unix. Ive never used C++much before, and until recently, I thought it was a pre-requisite forprogramming under Windows (fool I hear you say).
  3. 3. The main problem Ive got with programming under Windows is that mostfreely available source code is written to use the GUI. It alwaysseems that 90% of the code goes towards "making things pretty" etc. Toa non-Windows guru, this can be very daunting, as its almostimpossible for a person not used to C++ to decipher what the hell isgoing on.It came to head recently when I wanted to write an application toallow me to retrieve multiple emails from multiple POP servers intoone big email spool. I wanted to be able to be read the spool via asingle mail editor, and have the editor fill my reply email headersautomatically.So I decided to get to grips with both C programming for Windows andalso accessing the functions within the winsock.dll. After that, Idecided to dig deeper and delve into coding direct without using theWinsock dll.Anyway, enough of the ramble. This tutorial should grow on a weeklybasis (itll take me a week or so to write each section as I deciphermy own notes I wrote whilst exploring this) and will cover Internetprogramming using mainly C routines for Windows.The plan is to start simply by accessing the Winsock dll for allinitial programs. At each stage, a brief explanation and usefulworking source code will be presented to explain various concepts. Allprograms have been written as command line programs. No GUI, so thecode is easier to understand.The tutorial will build up to a much more advanced level, resulting inthe development of a complete new Winsock dll with a lot more callableroutines that the hacker and phreaker will like!Some assembly language programming will be required for later stagesof the tutorial, but Ill be releasing these routines as a dll foranyone who doesnt want to learn assembly, but still wants to accessthe routines.All of the way through the tutorial, explanations of the underlyingconcepts of internet programming will hopefully be built up to anadvanced level. For example, from the outset various Internetprotocols will be described very briefly. Further on in the tutorial,each of the protocols will be explored to a byte level.What You Will NeedA basic understanding of C.A C compiler for windows.Suitable Windows libraries (mainly Winsock and ICMP).Windows 95/98 or NT.The desire to learn.For those who have never programmed in C before (and Im not talkingabout for windows), then you will need to download one of the many Cprogrammers tutorials/guides/references that are freely available onthe net. Ignore any that are windows related, as I will be including abrief chapter on using C to program Windows apps. If you can
  4. 4. understand Basic or any other programming language, C shouldnt bemuch of a problem.C compilers are available free for download. For learning basic C thenI would recommend Borlands TurboC. They have released version 1 (Ibelieve) for free download, although it wont be suitable for Windowsapps.I use the free GCC package with RSXNTDJ (also free) for developingWindows apps. These are downloadable from www.delorie.com. The mainreason I use this is that it is a port of the Linux GCC package, soIm familiar with it.Alternatively, you can buy, beg, steal or borrow a commercial copy ofwhatever compiler you want.Windows libraries can be downloaded from Microsoft’s SDK pages(although I couldnt find a one for ICMP). For the GCC package youdont even need the libraries as you can convert the equivalent dllsinto .a libraries using the makelib tool supplied.All the routines presented in this tutorial have been tested under NT4Service Pack 5. I make no guarantees they will work with other win32OSs although they should. If you run into problems, then email me andIll try to come up with a solution.Compiler CommentsUnfortunately I will have to restrict comments in this section to theuse of GCCW32 and RSXNTDJ as I don’t have access to any other win 32compilers. If anyone wants to give feedback on using other compilers,then please email me and I’ll include it in the updates (along withyour email address so you can get the why doesn’t this work questions)With these packages, you can’t use the standard Lib’s that come withthe Microsoft SDK, however there is a MAKELIB utility program that canconvert MS DLL’s into a .a library.According to the specs, the header files included with RSXNTDJ statethat WINSOCK is supported up to and including version 2.0, however, Icould not get programs to compile with NT4.0 SP5’s wsock32.dll after Iconverted it using MAKELIB. You can set up RSXNTDJ and GCCW32 to usethe MS SDK headers, but as the SDK is a hefty download I have nottried this. I will eventually get round to trying it and will updatethis section.Until then, I am using an older version of Winsock that was left undermy system32 directory after an update and had been renamed aswsock32n.dll. This appears to be version 1.1, but works OK.You will need to convert both wsock32n.dll and icmp.dll into .alibraries using the MAKELIB utility.Unfortunately, the help file that comes with RSXNTDJ is wrong, sohere’s the protocol:-
  5. 5. Copy wsock32.dll and icmp.dll into your rsxntdj/lib directory, thenfrom a command prompt type the following: -makelib wsock32n.dll –o libwsock.aAnd also: -makelib icmp.dll –o libicmp.aIn your makefile for gccw32, reference these as –lwsock and –licmpE.g. for the first program that we will compile (whois.c), themakefile looks like this: -PROJECT = whoisOBJS = whois.oLIBS = -lwsockinclude ....rsxntmak.gnu(Make sure the path for rsxntmak.gnu is correct for your system)The InternetI thought a very brief introduction to the Internet and some basicterminology might be a good idea to jog people’s memory on certainpoints, and maybe clear up a few misconceptions. This is general, thefollowing sections will relate specifically as to how Windows handlesInternet access. It all starts very basic, but by the end of thetutorial it will get pretty hairy.There are billions of computers connected to the Internet, some viadial up when needed, and others, which have a permanent "live"connection.To connect to the computer you want to talk to, you need some way ofidentifying this computer. It will have a unique "name" and also an IPaddress, which is a 32-bit number.The "name" will never change unless the user decides to connect to theinternet via a different dial up account, but the IP address may do,especially for most dial up ISP’s"Names" are specified by a convention called DNS, which stands forDomain Name Service. RFC’s 1032, 1033, 1034 and 1035 cover DNS forthose who want to delve deeper.OK ... let’s take a practical example.Let’s take my account I use to post to PHUK as an example.The unique "name" is gandalf.freeuk.comThe IP number changes every time I dial up the account.So how are these all related?
  6. 6. We’ll start with the name. A DNS name has the following format: -subdomain.subdomain.domainThere can be many of the subdomain bits. In my case, com is thedomain, freeuk is a subdomain and gandalf is the subdomain withinfreeuk.The IP AddressWe will discuss the IP protocol later on in this section, but for now,it is sufficient to say that IP stands for Internet Protocol and theIP address is the basis for identifying all computers on the internet(and indeed often on private networks). An IP address consists of fouroctets that define a unique address e.g. 176.116.32.6When I connect to freeuk.com and successfully login, their serverassigns an IP address to my computer. This is different every time Ilogin. It is a dynamic IP address, i.e. it only relates to my computerfor the duration of my connection to the Internet.Some ISP’s issue static IP’s, where even if you aren’t connected thesame IP address is reserved for your computer.The handling of DNS name and equivalent IP address is done by theISP’s Nameservers.Part Two of the tutorial will dig deeper into IP address classes andsubnets etc.ProtocolsThere are quite a few protocols that need to be understood to get togrips with writing your own Internet applications. For this part ofthe tutorial, we don’t need to know the protocols in depth. But I’llbriefly describe some of them here. Part Two of the tutorial willdiscuss all the protocols to a byte by byte level for those who reallywant to know how things work.PPPWhen you use dial up networking to connect to your ISP, Windows usesthe PPP protocol to talk to the ISP’s computer. PPP stands for Pointto Point Protocol. It handles negotiation of baud rates etc and alsogets an IP address from the ISP.IPThe Internet Protocol is responsible for transporting data packetsacross the Internet and is primarily used by the routers to give themenough information to get the data packets to their destination.Sometimes IP may fragment data into smaller chunks, where each chunkmay arrive at the destination in any order and by different networkroutes. It is the responsibility of IP to reassemble everything backinto the correct order.
  7. 7. TCPIP by itself is not a very reliable protocol as it sends info out anddoesn’t ever check to see if it gets to the destination. This isusually the job for TCP, which stands for Transmission ControlProtocol. Any Internet application that requires reliable datatransfer (e.g. HTTP, POP, SMTP etc) uses TCP to handshake the datatransfer. TCP runs on top of IPUDPUDP is also a transmission protocol called the User Datagram Protocol.Unlike TCP it doesn’t use handshaking, so it is much faster but not asreliable. It is often used for streaming audio or video over theInternet. Like TCP, UDP runs on top of IPICMPICMP stands for Internet Control Message Protocol. It is closelyrelated to IP (in fact it is usually encapsulated within the IP datapackets). It is used by programs such as PING etc to check if parts ofthe Internet are up and running. It is not often used for much else(from the Windows user perspective), but it is used extensively by allof the routers on the Internet.That’s all we’ll say about protocols at the moment until part two ofthe tutorial. We’ll present a few programs at the end of thistutorial, which will demonstrate the use of windows socket programmingusing TCP/IP and also ICMP.The Windows TCP/IP StackThe Windows TCP/IP stack (the Winsock dll) takes all the hard work outof programming Internet applications. It handles lower level accessfor protocols such as TCP, UDP and IP. A separate dll (icmp.dll)handles the ICMP protocol.We will introduce all gently to programming via the various Windowsdll’s.This just about reaches the end of the first part of the tutorial. Heysays all, where’s the code and examples?Okay, the first part of the tutorial (the download you are readingnow) is a basic introduction as to why I decided to write thistutorial. It hopefully gives a basic explanation of various protocolsthat will be explored in continuing parts of the tutorial. Withoutthese, people who want to learn from scratch will be out of theirdepth.So, I can’t leave this without giving a bit of code for all to try.The following program provides a template for TCP/IP access using C.
  8. 8. Yes, if you want to do other things, you will have to understand therelevant RFC’s and will also need to use a few more routines from theWinsock dll.What we have presented so far should give you a basic framework toallow you to layout your own programs.Don’t worry if you don’t want to, the second tutorial is all aboutimplementing routines from the Winsock dll. It has plenty of examplescovering TCP/UDP and ICMP.Our First Program Using TCP/IP - WHOIS.CWhois will be familiar to Linux users. If you want to find outinformation about a certain DNS name, you can run a whois query tofind out information on network address numbers, administrativecontact details and valid name server’s etc. Official whois serversexist all over the world. A couple of the most useful ones arewhois.internic.net (for com, net, org and edu domains) andwhois.nic.uk (for co.uk, org.uk, ltd.uk, net.uk etc).The program accepts one or two command line arguments: -Whois domainname whois.server and saves any query results to a filecalled whoislog.txt.So, for example, if I wanted to query whois.internic.net aboutfreeuk.com, I would use: -Whois freeuk.com whois.internic.netIf the second argument is missing, the program automatically useswhois.internic.net.Here is the output for a query on freeuk.com: -Whois Session Started Sat Feb 26 23:52:33 2000.Connecting to whois.internic.netDomain names in the .com, .net, and .org domains can now be registeredwith many different competing registrars. Go tohttp://www.internic.netfor detailed information.Domain Name: FREEUK.COMRegistrar: NETWORK SOLUTIONS, INC.Whois Server: whois.networksolutions.comReferral URL: www.networksolutions.comName Server: NS0.FREEUK.NETName Server: NS1.FREEUK.NETName Server: NS2.CLARA.NETUpdated Date: 15-sep-1999
  9. 9. >>> Last update of whois database: Sat, 26 Feb 00 02:54:30 EST <<<The Registry database contains ONLY .COM, .NET, .ORG, .EDU domains andRegistrars.So what happens if I want to query my own freeuk account:-Whois gandalf.freeuk.comResult:-Whois Session Started Sun Feb 27 17:33:41 2000.Connecting to whois.internic.netDomain names in the .com, .net, and .org domains can now be registeredwith many different competing registrars. Go tohttp://www.internic.netfor detailed information.No match for "GANDALF.FREEUK.COM".>>> Last update of whois database: Sun, 27 Feb 00 02:36:32 EST <<<The Registry database contains ONLY .COM, .NET, .ORG, .EDU domains andRegistrars.So why didn’t it find my account?Well Internic only handles registered domains and not subdomains. Wewill find out in part two of the tutorial how to query freeuk to findout details on subdomain accounts.Anyway, here is the program listing. There is a download section atthe end of this tutorial with links to download the source, libraries,makefile etc for this and all subsequent programs in this tutorial./* * whois.c * * (c) Feb 2000 by Gandalf * */#include <stdio.h>#include <stdlib.h>#include <time.h>#include <windows.h>#include <winsock.h>#define WIN32_LEAN_AND_MEAN /* define win 32 only */void handle_error(void); /* Error handler routine */void write_file(char *buf); /* Write details to log file */int main (int argc, char **argv){ WORD wVersionRequested; /* socket dll version info */
  10. 10. WSADATA wsaData; /* data for socket libinitialisation */ SOCKET sock; /* socket details */ const int BUF_LEN=10000; /* Buffer size for transfers */ struct sockaddr_in address; /* socket address stuff */ struct hostent * host; /* host stuff */ int err; /* error trapping */ float socklib_ver; /* socket dll version */ char File_Buf[BUF_LEN]; /* file buffer */ char DomainName[100]; /* domain name from user */ char HostName[100]; /* host name from user */ time_t now; /* for date and time */ if (argc < 2) /* check we have command lineoptions */ { printf("nUseage: whois domainname [whois.server]n"); exit(0); } strcat(DomainName, argv[1]); /* get domain name from command line */ strcat(DomainName, "rn"); /* add crlf as whois servers expect it*/ if (argc == 3) strcat(HostName, argv[2]); /* get host name from command line */ else strcat(HostName, "whois.internic.net"); wVersionRequested = MAKEWORD( 1, 1 ); /* * We need to call the WSAStartup routine BEFORE we try to use anyof * the Winsock dll calls. */ if ( WSAStartup( wVersionRequested, &wsaData ) != 0 ) handle_error(); /* Check socket DLL supports 1.1 or higher */ socklib_ver = HIBYTE( wsaData.wVersion ) / 10.0; socklib_ver += LOBYTE( wsaData.wVersion ); if ( socklib_ver < 1.1 ) { printf ("nError: socket library must support 1.1 orgreater.n"); WSACleanup(); /* clean up before exit */ exit(0); } /* write current date and time to log file and screen */ time(&now); sprintf(File_Buf, "Whois Session Started %.24s.nn", ctime(&now)); write_file(File_Buf); /* * Open a socket. The AF_INET parameter tells windows we want to use
  11. 11. the * internet. Other parameters for different networking can be chosene.g. * for netbios, IPX etc. The SOCK_STREAM parameter lets windows knowwe want * to use TCP rather than UDP, and the final parameter will alwaysbe * zero for what we want to do and tells windows to use whatever * default communication protocol has been established (eg PPP andIP) */ if ( (sock = socket(AF_INET, SOCK_STREAM, 0)) == INVALID_SOCKET ) handle_error(); /* We now need to initialise a couple of variables in the address * structure. Once again, to tell windows we are using theinternet, * and also what port we want to use when connecting to a remote * computer. In this case it is port 43 which is the standard portfor * whois. The htons routine is used to convert the way Intel chips * store data in memory, which is different compared to many othercomputers. * The standard is based on Motorola format. */ address.sin_family=AF_INET; /* internet */ address.sin_port = htons(43); /* port 43 for whois */ /* write to the log file and screen */ sprintf(File_Buf,"Connecting to %sn", HostName); write_file(File_Buf); /* * host is a pointer to a structure of the predefined type hostent.We * need to call gethostbyname with the DNS name we want to use toreturn * a pointer to a hostent structure. This is so we can resolve anIP * address from our ISPs nameserver. */ if ( (host=gethostbyname(HostName)) == NULL ) handle_error(); /* we then initialise the address structure with the resolved IPaddress */ address.sin_addr.s_addr=*((unsigned long *) host->h_addr); /* Now were ready to actually connect to the whois server itself*/ if ( (connect(sock,(struct sockaddr *) &address, sizeof(address)))!= 0) handle_error(); /*
  12. 12. * We should be connected to the whois server at this point * so we need to send the domain name and wait for the response.The send * and recv routines are always used with TCP. These enablehandshaking * compared to the sendto and recvfrom routines which are used forUDP * protocol, ie without handshaking. */ strcpy(File_Buf, DomainName); err=send(sock,File_Buf,strlen(File_Buf),0); /* send domain name */ err=recv(sock,File_Buf,BUF_LEN,0); /* discard firstresponse */ err=recv(sock,File_Buf,BUF_LEN,0); /* get query resultsback */ write_file(File_Buf); /* Always call WSACleanup before exiting */ WSACleanup(); /* clean up before exit */ exit(0); } void handle_error(void) { /* * Errors are handled by calling the WSAGetLastError routine which * will return the last error as one of the following. As wedevelop * this tutorial, we will go into much more detail on what theymean * and what caused them. */ switch ( WSAGetLastError() ) { case WSANOTINITIALISED : printf("Unable to initialise socket.n"); break; case WSAEAFNOSUPPORT : printf("The specified address family is not supported.n"); break; case WSAEADDRNOTAVAIL : printf("Specified address is not available from the localmachine.n"); break; case WSAECONNREFUSED : printf("The attempt to connect was forcefully rejected.n"); break; case WSAEDESTADDRREQ : printf("address destination address is required.n"); break; case WSAEFAULT : printf("The namelen argument is incorrect.n"); break; case WSAEINVAL : printf("The socket is not already bound to an address.n"); break; case WSAEISCONN : printf("The socket is already connected.n");
  13. 13. break; case WSAEADDRINUSE : printf("The specified address is already in use.n"); break; case WSAEMFILE : printf("No more file descriptors are available.n"); break; case WSAENOBUFS : printf("No buffer space available. The socket cannot becreated.n"); break; case WSAEPROTONOSUPPORT : printf("The specified protocol is not supported.n"); break; case WSAEPROTOTYPE : printf("The specified protocol is the wrong type for thissocket.n"); break; case WSAENETUNREACH : printf("The network cant be reached from this host at thistime.n"); break; case WSAENOTSOCK : printf("The descriptor is not a socket.n"); break; case WSAETIMEDOUT : printf("Attempt timed out without establishing aconnection.n"); break; case WSAESOCKTNOSUPPORT : printf("Socket type is not supported in this addressfamily.n"); break; case WSAENETDOWN : printf("Network subsystem failure.n"); break; case WSAHOST_NOT_FOUND : printf("Authoritative Answer Host not found.n"); break; case WSATRY_AGAIN : printf("Non-Authoritative Host not found or SERVERFAIL.n"); break; case WSANO_RECOVERY : printf("Non recoverable errors, FORMERR, REFUSED,NOTIMP.n"); break; case WSANO_DATA : printf("Valid name, no data record of requested type.n"); break; case WSAEINPROGRESS : printf("address blocking Windows Sockets operation is inprogress.n"); break; case WSAEINTR : printf("The (blocking) call was canceled viaWSACancelBlockingCall().n"); break; default : printf("Unknown error.n"); break; }
  14. 14. WSACleanup(); exit(0);}void write_file(char *buf){ /* writes results to a log file and also to the screen */ FILE *fp=fopen("whoislog.txt","a+"); fprintf(fp,"%sn",buf); fclose(fp); printf("%sn",buf);}So...that was our first program using TCP/IP. It is a basic templatefor virtually any program you will want to do using TCP/IP. All youneed to do is change any of the relevant details such as domain name,port, data to send depending on what type of server you are trying toconnect to. For example, if you wanted to connect to a POP server,then you would change the domain name to the name of the POP server(e.g. relay.freeuk.net). You would also change the port number to 110,and once a valid connection has been established, change the send andrecv part of the program to negotiate collection of your email. Forvirtually all recognised data transfer protocols such as POP/SMTP etc,there is an RFC that covers the required send and receive stringformats. For POP it is RFC1725 and for SMTP it is RFC1869. These arefreely available on the web.Conclusion and What’s NextOkay...Nothing difficult so far.We have discussed a few protocols, and we have introduced a simpleprogram that can be compiled and used under windows to do a domainname enquiry.The basic framework won’t change for the next tutorial.Part Two of the tutorial will illustrate further programs that accessthe Winsock dll. We will also introduce accessing the ICMP dll.Anyway, enough for now. Check back in a couple of weeks for part twoof the tutorial.Send any feedback, errors, typos and wants to gandalf@dhamma.org.uk. The Rota BlueCrab Ltd
  15. 15. Internet Programming with Windows - A Tutorial Part 2 By Gandalf Gandalf@dhamma.org.uk (c) Mar 2000ContentsDisclaimerIntroductionRFCsSimple POP Email ClientSending Emails by SMTPUsing UDP/IPConclusion and Whats NextDisclaimerSome of the programs presented in this tutorial may be illegal to useunless you have permission from the owner of the server you attempt toconnect to and also to the recipient of any emails you send. If indoubt, dont do it. You can of course use these freely on your ownnetwork if you own one. If you want to try anything out, then considersetting up a Linux Box to act as a server so you can experiment inpeace without any fear of reprisal. Everything presented in thistutorial should be treated as a theoretical discussion of what ispossible. The author will not be held responsible for actions ofanyone using material from this tutorial for illegal purposes.IntroductionHopefully weve all survived part one of the tutorial. Part two isgoing to start off pretty much where part one left off. We will startby putting together a more advanced program using TCP/IP that willallow you to retrieve emails from a POP account into a mail spoolfile. We will also develop a program to allow you to send emails viasmtp. This will include falsifying header information. The programsare going to be fairly rudimentary, but will provide a nice frameworkfor those who would like to develop their own email client.RFCsIve mentioned RFCs briefly in part one of the tutorial. We are nowgoing to use information from various RFCs in some detail.So what are RFCs ?
  16. 16. Every protocol that exists on the net, whether its for handling mail,news, web site access or anything else you care to consider, there isan RFC for it.RFC stands for Request for Comments, and the whole of the internet andits associated protocols are based on them. If you want to develop orunderstand any Internet application, you need to read the associatedRFCs.You can find a list of all RFCs used so far in this tutorial athttp://www.exegesis.org.uk/gandalf/winsock/rfc/index.htmThe RFCs themselves are also downloadable or readable from links onthe index page.I will eventually be putting ALL rfcs online over a period of time,with a search facility.OK, on with the tutorial, lets start with a bit of programming.Simple POP Email ClientLets continue where we left off in the first part of the tutuorial bydeveloping another TCP/IP program. We will put together a basicframework to allow you to connect to, and negotiate downloading POPmail from your POP server. As usual, we will be presenting a piece ofcode that is functional rather then exhaustively error trapped to makeit easier to understand. There are comments in the code to suggestareas that would need to be changed if you wanted to develop a robustPOP client capable of handling attachments etc, but this will do toget you started. Later parts of the tutorial will be using this codeto develop a full multiple POP account client with SMTP posting.The program uses a log file called poplog.txt to store whats sent toand received back from the pop server so you can check for errors etc.It saves all mails to a text mail spool called mailbox.txt completewith headers.Heres the code:-/* * popclnt1.c * * * A very basic pop client that retrieves mail from an account into * a multi pop retrieval client in later parts of the tutorial withall * the extra error handling thats needed. Use this as a framework to * develop your own pop client. This program doesnt delete any mails * from the pop mail server, so you can try it out without beingafraid * of losing any emails! */#include <stdio.h>
  17. 17. #include <stdlib.h>#include <time.h>#include <windows.h>#include <winsock.h>#define WIN32_LEAN_AND_MEANvoid handle_error(void);void pop_error(void);void write_file(int file, char *p);int main (int argc, char *argv[]){ const long BUF_LEN=60000; /* 60000 char buffer. In real life we would have to allow for a much * larger buffer than this to allow retrieval of long messages which * might have attachments. We will be doing this in one of the later * parts of the tutorial by using synchronised data flow with asmaller * buffer that downloads mails in smaller chunks. */ const char POP_ERR_MSG[]="-ERR"; /* POP Server errorresponse */ const int LOG_FILE=1; /* write to log file */ const int MAIL_FILE=2; /* write to mail file */ const int SCREEN=4; /* display on screen */ WORD wVersionRequested; /* socket dll version info*/ WSADATA wsaData; /* socket libinitialisation */ SOCKET sock; /* socket details */ struct sockaddr_in address; /* socket address stuff */ struct hostent * host; /* host stuff */ int err; /* error trapping */ float socklib_ver; /* socket dll version */ char * File_Buf; /* file buffer */ char * Rec_Buf; /* recieve buffer */ /* Fill in to suit your own account, increase array sizes if needed*/ char hostname[20] = "pop.wherever.net"; /* hostname for pop server*/ char username[20] = "username"; /* username */ char password[20] = "password"; /* password */ int i,j; /* general counters */ char tempbuf[20] = ""; /* temp string buffer forparsing */ int num_flag=0; /* string parse flag */ time_t now; /* from time.h */ /* allocate dynamic storage from the heap */ File_Buf = malloc(BUF_LEN * sizeof(char) + 1); Rec_Buf = malloc(BUF_LEN * sizeof(char) + 1); wVersionRequested = MAKEWORD( 1, 1 );
  18. 18. if ( WSAStartup( wVersionRequested, &wsaData ) != 0 ) handle_error(); /* Check socket DLL supports 1.1 or higher */ socklib_ver = HIBYTE( wsaData.wVersion ) / 10.0; socklib_ver += LOBYTE( wsaData.wVersion ); if ( socklib_ver { printf ("Error: socket library must support 1.1 or greatern"); WSACleanup(); return 0; } /* get date and time to write to log file */ time(&now); sprintf(File_Buf,"Pop Client Session started %.24s.nn",ctime(&now)); write_file(LOG_FILE | SCREEN, File_Buf); /* open a socket based on TCP/IP */ if ( (sock = socket(AF_INET, SOCK_STREAM, 0)) == INVALID_SOCKET ) handle_error(); address.sin_family=AF_INET; /* internet */ address.sin_port = htons(110); /* pop port */ sprintf(File_Buf,"Connecting to %sn", hostname); write_file(LOG_FILE | SCREEN, File_Buf); /* DNS on hostname */ if ( (host=gethostbyname(hostname)) == NULL ) handle_error(); /* IP address for hostname */ address.sin_addr.s_addr=*((unsigned long *) host->h_addr); /* try to connect to pop server */ if ( (connect(sock,(struct sockaddr *) &address, sizeof(address)))!= 0) handle_error(); sprintf(File_Buf, "Connected to %sn", hostname); write_file(LOG_FILE | SCREEN, File_Buf); err=recv(sock,Rec_Buf,BUF_LEN,0); /* get response fromserver */ sprintf(File_Buf,"received: %s", Rec_Buf); /* should start +OK */ write_file(LOG_FILE, File_Buf); if ( strstr(Rec_Buf,POP_ERR_MSG) != NULL ) /* check for errors */ pop_error(); strcpy(Rec_Buf,"USER "); strcat(Rec_Buf, username);
  19. 19. strcat(Rec_Buf, "rn"); err=send(sock,Rec_Buf,strlen(Rec_Buf),0); /* send username */ sprintf(File_Buf,"sent: %s",Rec_Buf); write_file(LOG_FILE, File_Buf); err=recv(sock,Rec_Buf,BUF_LEN,0); /* should recieve +OK*/ sprintf(File_Buf,"received: %s", Rec_Buf); write_file(LOG_FILE, File_Buf); if ( strstr(Rec_Buf,POP_ERR_MSG) != NULL ) /* check for errors */ pop_error(); strcpy(Rec_Buf,"PASS "); strcat(Rec_Buf, password); strcat(Rec_Buf, "rn"); err=send(sock,Rec_Buf,strlen(Rec_Buf),0); /* send password */ sprintf(File_Buf,"sent: %s",Rec_Buf); write_file(LOG_FILE, File_Buf); err=recv(sock,Rec_Buf,BUF_LEN,0); /* should recieve +OK*/ sprintf(File_Buf,"received: %s",Rec_Buf); write_file(LOG_FILE, File_Buf); if ( strstr(Rec_Buf,POP_ERR_MSG) != NULL ) /* check for errors */ pop_error(); strcpy(Rec_Buf,"STATrn"); /* send stat command */ err=send(sock,Rec_Buf,strlen(Rec_Buf),0); sprintf(File_Buf,"sent: %s", Rec_Buf); write_file(LOG_FILE, File_Buf); /* * should recieve +OK x y where x = number of messages * and y is total octets. Note the buffers we have allocated * would not be sufficient for a real pop client. They * should be dynamically allocated here after checking the * size of the waiting emails. */ err=recv(sock,Rec_Buf,BUF_LEN,0); sprintf(File_Buf,"received: %s", Rec_Buf); write_file(LOG_FILE, File_Buf); if ( strstr(Rec_Buf,POP_ERR_MSG) != NULL ) /* check for errors */ pop_error(); /* * Now we need to work out how many emails we have to retrieve * and set up a loop to get them all. */ i = j = 0; while (i { if (Rec_Buf[i] > 0 && Rec_Buf[i] { while (Rec_Buf[i] != ) /* space is end ofnumber */ { tempbuf[j] = Rec_Buf[i];
  20. 20. j++; i++; } num_flag=1; tempbuf[j] = 0; } i++; } i = atoi(tempbuf); /* number of emails */ printf("There are %d message(s) waitingrn", i); /* * At this point we should really be checking the length of eachemail * on the POP server and then either allocate dynamic memory, orbetter * still, try synchronised access which we will be doing in a later * part of the tutorial. Until then, lets keep it simple. If you do * have an email larger than the buffer, it wont do anything else * other than crash the program! */ for( j=1; j<=i; j++) { sprintf(Rec_Buf, "RETR %drn", j); /* add number */ printf("Retrieving message number %dn", j); err=send(sock,Rec_Buf,strlen(Rec_Buf),0); sprintf(File_Buf,"sent: %s ",Rec_Buf); write_file(LOG_FILE, File_Buf); err=recv(sock,Rec_Buf,BUF_LEN,0); /* +OK message willfollow */ sprintf(File_Buf,"received: %s ",Rec_Buf); write_file(LOG_FILE, File_Buf); if ( strstr(Rec_Buf,POP_ERR_MSG) != NULL ) /* check for errors */ pop_error(); err=recv(sock,Rec_Buf,BUF_LEN,0); /* retrieve the mail*/ sprintf(File_Buf,"%s",Rec_Buf); write_file(MAIL_FILE, File_Buf); } printf ("All donenn"); /* send quit command then clean up */ strcpy(Rec_Buf,"QUITrn"); err=send(sock,Rec_Buf,strlen(Rec_Buf),0); sprintf(File_Buf,"sent: %s", Rec_Buf); write_file(LOG_FILE, File_Buf); /* deallocate buffer memory */ free(File_Buf); free(Rec_Buf);
  21. 21. WSACleanup(); return 0;}void handle_error(void){ /* * Errors are handled by calling the WSAGetLastError routine which * will return the last error as one of the following. As we develop * this tutorial, we will go into much more detail on what they mean * and what caused them. */ switch ( WSAGetLastError() ) { case WSANOTINITIALISED : printf("Unable to initialise socket.n"); break; case WSAEAFNOSUPPORT : printf("The specified address family is not supported.n"); break; case WSAEADDRNOTAVAIL : printf("Specified address is not available from the localmachine.n"); break; case WSAECONNREFUSED : printf("The attempt to connect was forcefully rejected.n"); break; case WSAEDESTADDRREQ : printf("address destination address is required.n"); break; case WSAEFAULT : printf("The namelen argument is incorrect.n"); break; case WSAEINVAL : printf("The socket is not already bound to an address.n"); break; case WSAEISCONN : printf("The socket is already connected.n"); break; case WSAEADDRINUSE : printf("The specified address is already in use.n"); break; case WSAEMFILE : printf("No more file descriptors are available.n"); break; case WSAENOBUFS : printf("No buffer space available. The socket cannot becreated.n"); break; case WSAEPROTONOSUPPORT : printf("The specified protocol is not supported.n"); break; case WSAEPROTOTYPE : printf("The specified protocol is the wrong type for thissocket.n"); break; case WSAENETUNREACH : printf("The network cant be reached from this host at thistime.n");
  22. 22. break; case WSAENOTSOCK : printf("The descriptor is not a socket.n"); break; case WSAETIMEDOUT : printf("Attempt timed out without establishing aconnection.n"); break; case WSAESOCKTNOSUPPORT : printf("Socket type is not supported in this addressfamily.n"); break; case WSAENETDOWN : printf("Network subsystem failure.n"); break; case WSAHOST_NOT_FOUND : printf("Authoritative Answer Host not found.n"); break; case WSATRY_AGAIN : printf("Non-Authoritative Host not found or SERVERFAIL.n"); break; case WSANO_RECOVERY : printf("Non recoverable errors, FORMERR, REFUSED, NOTIMP.n"); break; case WSANO_DATA : printf("Valid name, no data record of requested type.n"); break; case WSAEINPROGRESS : printf("address blocking Windows Sockets operation is inprogress.n"); break; case WSAEINTR : printf("The (blocking) call was canceled viaWSACancelBlockingCall().n"); break; default : printf("Unknown error.n"); break; } WSACleanup(); exit(0);}void pop_error(void){ printf("POP Error, Check the Log File for Detailsrnrn"); WSACleanup(); exit(0);}void write_file(int file_type, char *p){ const int LOG_FILE=1; /* write to log file*/ const int MAIL_FILE=2; /* write to mail file*/ const int SCREEN=4; /* display on screen*/
  23. 23. if( (file_type & LOG_FILE) != 0 ) /* add to logs */ { FILE *fp=fopen("poplog.txt","a+"); fprintf(fp,"%sn",p); fclose(fp); } if( (file_type & MAIL_FILE) != 0 ) /* add to mailbox */ { FILE *fp=fopen("mailbox.txt","a+"); fprintf(fp,"%sn",p); fclose(fp); } if ( (file_type & SCREEN) != 0 ) /* screen */ { printf("%sn",p); }}Log File Example after connecting to a POP Server:-Pop Client Session started Tue Mar 28 22:27:06 2000.Connecting to pop.freeuk.netConnected to pop.freeuk.netreceived: +OK CPOP v2.3 Ready for Actionsent: USER xxxxxxxxreceived: +OKxxxxxxxxsent: PASS xxxxxxxxreceived: +OKxxxxxxxxsent: STATreceived: +OK 1 7165sent: RETR 1received: +OK1sent: QUITSending Emails with SMTP
  24. 24. Now that weve seen how to retrieve emails from a POP server, welltake a look at how to send them with SMTP. Once again using TCP/IP. Asfor the POP client, the program is a basic framework for you todevelop further. This will be our last TCP/IP example for a while.Hopefully, the three programs we have presented so far will allow youto develop your own TCP/IP applications by reading the relevant RFCsto allow you to establish and use the required protocol.Most email programs available for windows wont allow you to modifycertain headers and often put in additional header fields you mightnot want to use. With this program, you can set up the "From:" fieldif you dont want your real email address to be seen. It istheoretically possible to use it to log onto SMTP servers where youdont have an account and send emails from their server. Many SMTPservers do not check user details, although a large number of UK ISPsdo check you are using one of their Dial Up Accounts before lettingyou use SMTP to protect themselves from email spammers. You might ofcourse be logged in their log files if you arent careful!Anyway, lets take an example. The following program sends an email towhoever has been specified in the RCPT TO: field, in this case, itcomes to my account. However, when I recieve it it will appear to havecome from Bill Clinton and should have been sent to President Putin.Heres the source:-/* * smtp1.c * * (c) Mar 2000 by Gandalf * * A very basic smtp program to send emails from a text file. Try itout by * sending an email to one of your mail accounts. Make your own emailheaders * up with this, or add a few that maybe your current email programdoesnt * allow. This example will send an email to whoever you specify inthe RCPT TO * field, but will appear to be intended for someone else, and ofcourse it * will also appear to come from someone different to yourself! * This is a technique often used by spammers. I dont agree withspamming, * but the technique can be useful for other purposes. */#include <stdio.h>#include <stdlib.h>#include <time.h>#include <windows.h>#include <winsock.h>#define WIN32_LEAN_AND_MEANvoid handle_error(void);void smtp_error(void);void write_file(int file, char *p);int main (int argc, char *argv[])
  25. 25. { const int BUF_LEN=5000; /* send and recieve buffers*/ const int LOG_FILE=1; /* write to log file */ const int SCREEN=4; /* display on screen */ WORD wVersionRequested; /* socket dll version info */ WSADATA wsaData; /* socket lib initialisation*/ SOCKET sock; /* socket details */ struct sockaddr_in address; /* socket address stuff */ struct hostent * host; /* host stuff */ int err; /* error trapping */ float socklib_ver; /* socket dll version */ char * File_Buf; /* file buffer */ char * Rec_Buf; /* recieve buffer */ /* Change to use your own smtp host */ char hostname[20] = "relay.where.net"; /* hostname for smtp server*/ time_t now; /* from time.h */ /* allocate dynamic storage from the heap */ File_Buf = malloc(BUF_LEN * sizeof(char) + 1); Rec_Buf = malloc(BUF_LEN * sizeof(char) + 1); wVersionRequested = MAKEWORD( 1, 1 ); if ( WSAStartup( wVersionRequested, &wsaData ) != 0 ) handle_error(); /* Check socket DLL supports 1.1 or higher */ socklib_ver = HIBYTE( wsaData.wVersion ) / 10.0; socklib_ver += LOBYTE( wsaData.wVersion ); if ( socklib_ver { printf ("Error: socket library must support 1.1 or greatern"); WSACleanup(); return 0; } /* get date and time to write to log file */ time(&now); sprintf(File_Buf,"SMTP Session started %.24s.nn", ctime(&now)); write_file(LOG_FILE | SCREEN, File_Buf); /* open a socket based on TCP/IP */ if ( (sock = socket(AF_INET, SOCK_STREAM, 0)) == INVALID_SOCKET ) handle_error(); address.sin_family=AF_INET; /* internet */ address.sin_port = htons(25); /* smtp port */ sprintf(File_Buf,"Connecting to %sn", hostname); write_file(LOG_FILE | SCREEN, File_Buf);
  26. 26. /* DNS on hostname */ if ( (host=gethostbyname(hostname)) == NULL ) handle_error(); /* IP address for hostname */ address.sin_addr.s_addr=*((unsigned long *) host->h_addr); /* Connect to smtp server */ if ( (connect(sock,(struct sockaddr *) &address, sizeof(address)))!= 0) handle_error(); sprintf(File_Buf, "Connected to %sn", hostname); write_file(LOG_FILE | SCREEN, File_Buf); err=recv(sock,Rec_Buf,BUF_LEN,0); /* get response fromserver */ sprintf(File_Buf,"received: %s", Rec_Buf); /* write to logs */ write_file(LOG_FILE | SCREEN, File_Buf); /* * OK, now we send the usual expected string to the smtp host. This * should be "HELO whatever.wewant.comrn" Some smtp hosts check * the domain out properly, but most dont. As long as it checks a * rudimentary test to see if it could be a valid domain, the smtp * host will usually accept it! */ sprintf(Rec_Buf, "HELO microsoft.comrn"); err=send(sock,Rec_Buf,strlen(Rec_Buf),0); /* send expectedresponse */ write_file(LOG_FILE | SCREEN, Rec_Buf); err=recv(sock,Rec_Buf,BUF_LEN,0); /* get response fromserver */ sprintf(File_Buf,"received: %s", Rec_Buf); /* write to logs */ write_file(LOG_FILE | SCREEN, File_Buf); sprintf(Rec_Buf, "MAIL FROM: bclinton@whitehouse.govrn"); err=send(sock,Rec_Buf,strlen(Rec_Buf),0); /* send who its from*/ write_file(LOG_FILE | SCREEN, Rec_Buf); err=recv(sock,Rec_Buf,BUF_LEN,0); /* get response fromserver */ sprintf(File_Buf,"received: %s", Rec_Buf); /* write to logs */ write_file(LOG_FILE | SCREEN, File_Buf); sprintf(Rec_Buf, "RCPT TO: gandalf@dhamma.org.ukrn"); err=send(sock,Rec_Buf,strlen(Rec_Buf),0); /* send who its to.This is */ write_file(LOG_FILE | SCREEN, Rec_Buf); /* the last requiredfield */ err=recv(sock,Rec_Buf,BUF_LEN,0); /* get response fromserver */ sprintf(File_Buf,"received: %s", Rec_Buf); /* write to logs */
  27. 27. write_file(LOG_FILE | SCREEN, File_Buf); sprintf(Rec_Buf, "DATArn"); /* Send a DATA commandwhich */ err=send(sock,Rec_Buf,strlen(Rec_Buf),0); /* tells the serverthat all */ write_file(LOG_FILE | SCREEN, Rec_Buf); /* else we send isgoing to * be our message withheaders * and the mesaagebody. */ err=recv(sock,Rec_Buf,BUF_LEN,0); /* get response fromserver */ sprintf(File_Buf,"received: %s", Rec_Buf); /* write to logs */ write_file(LOG_FILE | SCREEN, File_Buf); /* * OK. At this point we can add as many headers as we want. Checkout * the RFCs for all common headers */ sprintf(Rec_Buf, "From: Bill Clinton<bclinton@whitehouse.gov>rn"); err=send(sock,Rec_Buf,strlen(Rec_Buf),0); write_file(LOG_FILE | SCREEN, Rec_Buf); sprintf(Rec_Buf, "To: Putin <putin@kremlin.ru>rn"); err=send(sock,Rec_Buf,strlen(Rec_Buf),0); write_file(LOG_FILE | SCREEN, Rec_Buf); sprintf(Rec_Buf, "Subject: Congratulationsrn"); err=send(sock,Rec_Buf,strlen(Rec_Buf),0); write_file(LOG_FILE | SCREEN, Rec_Buf); /* Done with headers, so lets add the message body */ sprintf(Rec_Buf, "rnDear President Putinrn"); err=send(sock,Rec_Buf,strlen(Rec_Buf),0); write_file(LOG_FILE | SCREEN, Rec_Buf); sprintf(Rec_Buf, "rnCongratulations on your recent appointment "); err=send(sock,Rec_Buf,strlen(Rec_Buf),0); write_file(LOG_FILE | SCREEN, Rec_Buf); sprintf(Rec_Buf, "to President of Russiarn"); err=send(sock,Rec_Buf,strlen(Rec_Buf),0); write_file(LOG_FILE | SCREEN, Rec_Buf); sprintf(Rec_Buf, "rnI remain, your most faithful serventrn"); err=send(sock,Rec_Buf,strlen(Rec_Buf),0); write_file(LOG_FILE | SCREEN, Rec_Buf); sprintf(Rec_Buf, "rnBill"); err=send(sock,Rec_Buf,strlen(Rec_Buf),0); write_file(LOG_FILE | SCREEN, Rec_Buf); /*
  28. 28. * Once we have finished, we send a CRLF followed by a full stop and * a second CRLF to tell the smtp host we have completed themessage, which * will then get queued and sent. */ sprintf(Rec_Buf, "rn.rn"); err=send(sock,Rec_Buf,strlen(Rec_Buf),0); write_file(LOG_FILE | SCREEN, Rec_Buf); err=recv(sock,Rec_Buf,BUF_LEN,0); /* get response fromserver */ sprintf(File_Buf,"received: %s", Rec_Buf); /* write to logs */ write_file(LOG_FILE | SCREEN, File_Buf); sprintf(Rec_Buf, "QUITrn"); err=send(sock,Rec_Buf,strlen(Rec_Buf),0); /* send a quit command*/ write_file(LOG_FILE | SCREEN, Rec_Buf); err=recv(sock,Rec_Buf,BUF_LEN,0); /* get response fromserver */ sprintf(File_Buf,"received: %s", Rec_Buf); /* write to logs */ write_file(LOG_FILE | SCREEN, File_Buf); /* * Off course, if you wanted to use this as a genuine email posting * program, you would use the mail spool file we generated from our * last program, and would pick up the relevent headers to reply. * The message could be edited using a standard text editor, thenread * in by this program. Weve kept it simple though so you can seeexactly * what is happening. */ /* deallocate buffer memory */ free(File_Buf); free(Rec_Buf); WSACleanup(); return 0;}void handle_error(void){ /* Cut and paste in the same error handler as used in the POPprogram */}void smtp_error(void){ printf("SMTP Error, Check the Log File for Detailsrnrn"); WSACleanup(); exit(0);}void write_file(int file_type, char *p){ const int LOG_FILE=1; /* write to log file
  29. 29. */ const int SCREEN=4; /* display on screen*/ if( (file_type & LOG_FILE) != 0 ) /* add to logs */ { FILE *fp=fopen("poplog.txt","a+"); fprintf(fp,"%sn",p); fclose(fp); } if ( (file_type & SCREEN) != 0 ) /* screen */ { printf("%sn",p); }}Okay, lets take a look at the log file (smtplog.txt):-SMTP Session started Wed Mar 29 00:35:41 2000.Connecting to relay.freeuk.netConnected to relay.freeuk.netreceived: 220 scrabble.freeuk.net ESMTP Exim 3.12 #1 Wed, 29 Mar 200000:34:12 +0100HELO whitehouse.govreceived: 250 scrabble.freeuk.net Hello whitehouse.gov[212.126.154.153]34:12 +0100MAIL FROM: bclinton@whitehouse.govreceived: 250 <bclinton@whitehouse.gov> is syntactically correct154.153]34:12 +0100RCPT TO: gandalf@dhamma.org.ukreceived: 250 <gandalf@dhamma.org.uk> is syntactically correct154.153]34:12 +0100DATAreceived: 354 Enter message, ending with "." on a line by itself.153]34:12 +0100From: Bill Clinton <bclinton@whitehouse.gov>
  30. 30. To: Putin <putin@kremlin.ru>Subject: CongratulationsDear President PutinCongratulations on your recent appointmentto President of RussiaI remain, your most faithful serventBill.received: 250 OK id=12a5Uy-0004ku-00ul serventQUITreceived: 221 scrabble.freeuk.net closing connectionUsing UDP/IPSo far weve looked at using TCP/IP, which as I mentioned in part oneof the tutorial, is a STREAMING protocol, ie it uses handshaking. Yousend data and it is acknowledged by the other end prior to you sendingmore. This way, if packets get lost or become corrupted, the other endcan notify you to resend the packet. Were now going to take a look atUDP/IP which is a DATAGRAM protocol. You send out a packet and neverbother to check if it gets to its destination. Obviously this is aless reliable protocol, but is much faster. There arent too manyservices running over the Internet using UDP. However, well developan example to illustrate how to use it. I did have in mind using TFTPas an example, but we need to understand the UDP protocol in depth tobe able to use this. So, well take a simple one. You probably wontfind a server out there on the Internet which offers an echo service,but if you have a Linux Box, then enable port 7 in inetd.conf to trythis out.All it does is send a string via UDP/IP and receives an echo of thesame string back from the server. Heres the code :-/* * ech.c * * (c) Mar 2000 by Gandalf * * A simple program to illustrate UDP/IP. Servers dont usually * run an echo service as it can be used for DoS attacks. However, * if you have access to a Linux Box, you can enable this service * in your inetd.conf to try it. * */
  31. 31. #include <stdio.h>#include <stdlib.h>#include <windows.h>#include <winsock.h>#define WIN32_LEAN_AND_MEANvoid handle_error(void);int main (int argc, char **argv){ WORD wVersionRequested; /* socket dll version info */ WSADATA wsaData; /* data for socket libinitialisation */ SOCKET sock; /* socket details */ const int BUF_LEN=100; /* Buffer size for transfers */ struct sockaddr_in address; /* socket address stuff */ int err; /* error trapping */ float socklib_ver; /* socket dll version */ char * Buf; /* send buffer */ char * Rec_Buf; /* receive buffer */ wVersionRequested = MAKEWORD( 1, 1 ); /* * We need to call the WSAStartup routine BEFORE we try to use anyof * the Winsock dll calls. */ if ( WSAStartup( wVersionRequested, &wsaData ) != 0 ) handle_error(); /* Check socket DLL supports 1.1 or higher */ socklib_ver = HIBYTE( wsaData.wVersion ) / 10.0; socklib_ver += LOBYTE( wsaData.wVersion ); /* Find out what our maximum IP packet size is for datagrams andallocate * our buffers */ Buf = malloc(wsaData.iMaxUdpDg * sizeof(char) + 1); Rec_Buf = malloc(wsaData.iMaxUdpDg * sizeof(char) + 1); if ( socklib_ver { printf ("nError: socket library must support 1.1 or greater.n"); WSACleanup(); /* clean up before exit */ exit(0); } /* * Open a socket. The AF_INET parameter tells windows we want to usethe * internet. Other parameters for different networking can be chosene.g. * for netbios, IPX etc. The SOCK_DGRAM parameter lets windows knowwe want * to use UDP rather than TCP, and the final parameter will always
  32. 32. be * zero for what we want to do and tells windows to use whatever * default communication protocol has been established (eg PPP andIP) */ if ( (sock = socket(AF_INET, SOCK_DGRAM, 0)) == INVALID_SOCKET ) handle_error(); /* We now need to initialise a couple of variables in the address * structure. Once again, to tell windows we are using the internet, * and also what port we want to use when connecting to a remote * computer. In this case it is port 7 which is the standard portfor * echo. The htons routine is used to convert the way Intel chips * store data in memory, which is different compared to many othercomputers. * The standard is based on Motorola format. */ address.sin_family=AF_INET; /* internet */ address.sin_port = htons(7); /* port 7 for the echo server*/ /* * The last example showed using a host name, and used the winsock * dll routine gethostbyname to resolve an IP address. This example * shows how to use an IP address direct using the inet_addrroutine. */ address.sin_addr.s_addr=inet_addr("192.168.19.3"); /* Now were ready to actually connect to the echo server itself */ if ( (connect(sock,(struct sockaddr *) &address, sizeof(address)))!= 0) handle_error(); /* * We should be connected to the echo server at this point andwhatever * we send to it should be echoed back. We use sendto and recvfromwith * UDP/IP. */ strcpy(Buf, "Hi There Mr Echo!"); printf("nSent: %sn", Buf); err=sendto(sock,Buf,BUF_LEN,0,(struct sockaddr*)&address,sizeof(address)); err=sizeof(address); recvfrom(sock,Rec_Buf,BUF_LEN,0,(struct sockaddr *)&address,&err); printf("nReceived: %sn", Rec_Buf); /* deallocate buffer memory */ free(Buf); free(Rec_Buf); /* Always call WSACleanup before exiting */
  33. 33. WSACleanup(); exit(0);}void handle_error(void){ /* Cut and paste in the same error handler as used in the POPprogram */}Conclusion and Whats NextSo, we are moving a bit closer towards programming our own hackingapplications. We hopefully fully understand TCP/IP and UDP/IP by now,or at least enough to write our own programs.I fully intended to introduce ICMP at this point with our own versionsof PING and TRACEROUTE. However, after developing them, I realisedthat for the reader of this tutorial to understand how they work wouldrequire a greater knowledge of the IP protocol, so well be leavingthese examples until part three of the tutorial.We will be looking at the IP protocol in depth in the next part of thetutorial. In fact, we will be taking a very deep look at all of theprotocols. Its going to be pretty heavy going as we cant really gomuch further without getting into protocols to a bit level. So getprepared.As usual, we will be presenting a few programs to illustrate this. Wewill be developing a logging program to watch out for TCP, UDP andICMP activity on your own computer. We will also expand this furtherto allow us to monitor the protocols to the bit level.It will eventually grow into a powerful firewall by the end of thetutorial.Hope youre enjoying things so far!As usual, send any greets, complaints or whatever togandalf@dhamma.org.uk The Rota BlueCrab Ltd
  34. 34. RFCs Used in the TutorialHeres the list of RFCs I used whilst developing the Windows Socket ProgrammingTutorial. If you really want to get to grips with programming your own Internetapplications, you should read them fully. RFCs discuss internet related protocols ingreat detail.View them online by left clicking the link, or download them by right clicking the link.They are all in text format. The RFCs listed here account for about 5% of all availableRFCs. I will eventually be putting the lot online here, along with a document levelsearch facility, something which is sadly missing from most RFC repositories.
  35. 35. RFC RFC Title, Author, Date and General InformationNumber NIC name server - a datagram-based information utility. J.R. Pickens, E.J. Feinler, J.E. Mathis.756 Jul-01-1979. (Format: TXT=23491 bytes) (Status: UNKNOWN) User Datagram Protocol. J. Postel. Aug-28-1980.768 (Format: TXT=5896 bytes) (Status: STANDARD) User Datagram Protocol. J. Postel. Aug-28-1980.768 (Format: TXT=5896 bytes) (Status: STANDARD) Vulnerabilities of network control protocols: An example. E.C. Rosen. Jul-01-1981.789 (Format: TXT=25541 bytes) (Status: UNKNOWN) Internet Protocol. J. Postel. Sep-01-1981.791 (Format: TXT=97779 bytes) (Obsoletes RFC0760) (Status: STANDARD) Internet Control Message Protocol. J. Postel. Sep-01-1981.792 (Format: TXT=30404 bytes) (Obsoletes RFC0777) (Updated by RFC0950) (Status: STANDARD) Transmission Control Protocol. J. Postel. Sep-01-1981.793 (Format: TXT=177957 bytes) (Status: STANDARD) Simple Mail Transfer Protocol. J. Postel. Aug-01-1982.821 (Format: TXT=124482 bytes) (Obsoletes RFC0788) (Also STD0010) (Status: STANDARD) TCP maximum segment size and related topics. J. Postel. Nov-01-1983.879 (Format: TXT=22024 bytes) (Status: UNKNOWN) Domain names plan and schedule. J. Postel. Nov-01-1983.881 (Format: TXT=23490 bytes) (Updated by RFC0897) (Status: UNKNOWN) Standard for the transmission of IP datagrams over Ethernet networks. C. Hornig. Apr-01-1984.894 (Format: TXT=5697 bytes) (Status: STANDARD) Standard for the transmission of IP datagrams over experimental Ethernet networks. J. Postel.895 Apr-01-1984. (Format: TXT=4985 bytes) (Status: STANDARD) Congestion control in IP/TCP internetworks. J. Nagle. Jan-06-1984.896 (Format: TXT=26782 bytes) (Status: UNKNOWN)
  36. 36. Domain name system implementation schedule. J. Postel. Feb-01-1984.897 (Format: TXT=15683 bytes) (Updates RFC0881) (Updated by RFC0921) (Status: UNKNOWN) Broadcasting Internet Datagrams. J.C. Mogul. Oct-01-1984.919 (Format: TXT=16382 bytes) (Status: STANDARD) Domain name system implementation schedule - revised. J. Postel. Oct-01-1984.921 (Format: TXT=23318 bytes) (Updates RFC0897) (Status: UNKNOWN) Broadcasting Internet datagrams in the presence of subnets. J.C. Mogul. Oct-01-1984.922 (Format: TXT=24147 bytes) (Status: STANDARD) Internet Standard Subnetting Procedure. J.C. Mogul, J. Postel. Aug-01-1985.950 (Format: TXT=37985 bytes) (Updates RFC0792) (Status: STANDARD) NICNAME/WHOIS. K. Harrenstien, M.K. Stahl, E.J. Feinler. Oct-01-1985.954 (Format: TXT=7397 bytes) (Obsoletes RFC0812, RFC0813) (Status: DRAFT STANDARD) Some problems with the specification of the Military Standard Internet Protocol. D.P. Sidhu.963 Nov-01-1985. (Format: TXT=44019 bytes) (Status: UNKNOWN) Some problems with the specification of the Military Standard Transmission Control Protocol.964 D.P. Sidhu. Nov-01-1985. (Format: TXT=20972 bytes) (Status: UNKNOWN) Protocol standard for a NetBIOS service on a TCP/UDP transport: Concepts and methods. NetBIOS Working Group. Defense Advanced Research Projects Agency, Internet Activities1001 Board, End-to-End Services Task Force. Mar-01-1987. (Format: TXT=158437 bytes) (Status: STANDARD) Protocol standard for a NetBIOS service on a TCP/UDP transport: Detailed specifications. NetBIOS Working Group. Defense Advanced Research Projects Agency, Internet Activities1002 Board, End-to-End Services Task Force. Mar-01-1987. (Format: TXT=170262 bytes) (Status: STANDARD) ISO transport services on top of the TCP: Version 3. M.T. Rose, D.E. Cass. May-01-1987.1006 (Format: TXT=31935 bytes) (Obsoletes RFC0983) (Status: STANDARD) TCP and IP bake off. J. Postel. Sep-01-1987.1025 (Format: TXT=11648 bytes) (Status: UNKNOWN) Domain names - implementation and specification. P.V. Mockapetris. Nov-01-1987. (Format: TXT=125626 bytes) (Obsoletes RFC0973, RFC0882, RFC0883) (Updated by1035 RFC1101, RFC1183, RFC1348, RFC1876, RFC1982, RFC1995, RFC1996, RFC2065, RFC2181, RFC2136, RFC2137, RFC2308) (Status: STANDARD)
  37. 37. Guidelines for the use of Internet-IP addresses in the ISO Connectionless-Mode Network1069 Protocol. R.W. Callon, H.W. Braun. Feb-01-1989. (Format: TXT=24268 bytes) (Obsoletes RFC0986) (Status: UNKNOWN) ISO presentation services on top of TCP/IP based internets. M.T. Rose. Dec-01-1988.1085 (Format: TXT=64643 bytes) (Status: UNKNOWN) Standard for the transmission of IP datagrams over NetBIOS networks. L.J. McLaughlin. Feb-01-1088 1989. (Format: TXT=5749 bytes) (Status: STANDARD) DNS encoding of network names and other types. P.V. Mockapetris. Apr-01-1989.1101 (Format: TXT=28677 bytes) (Updates RFC1034, RFC1035) (Status: UNKNOWN) Host extensions for IP multicasting. S.E. Deering. Aug-01-1989.1112 (Format: TXT=39904 bytes) (Obsoletes RFC0988, RFC1054) (Updated by RFC2236) (Status: STANDARD) Administrative Domains and Routing Domains: A model for routing in the Internet. S. Hares, D.1136 Katz. Dec-01-1989. (Format: TXT=22158 bytes) (Status: INFORMATIONAL) Compressing TCP/IP headers for low-speed serial links. V. Jacobson. Feb-01-1990.1144 (Format: TXT=120959, PS=534729 bytes) (Status: PROPOSED STANDARD) Structure and identification of management information for TCP/IP-based internets. M.T. Rose,1155 K. McCloghrie. May-01-1990. (Format: TXT=40927 bytes) (Obsoletes RFC1065) (Also STD0016) (Status: STANDARD) TCP/IP tutorial. T.J. Socolofsky, C.J. Kale. Jan-01-1991.1180 (Format: TXT=65494 bytes) (Status: INFORMATIONAL) New DNS RR Definitions. C.F. Everhart, L.A. Mamakos, R. Ullmann, P.V. Mockapetris. Oct-01-1183 1990. (Format: TXT=23788 bytes) (Updates RFC1034, RFC1035) (Status: EXPERIMENTAL) Path MTU discovery. J.C. Mogul, S.E. Deering. Nov-01-1990.1191 (Format: TXT=47936 bytes) (Obsoletes RFC1063) (Status: DRAFT STANDARD) Use of OSI IS-IS for routing in TCP/IP and dual environments. R.W. Callon. Dec-01-1990.1195 (Format: TXT=187866, PS=362052 bytes) (Status: PROPOSED STANDARD) Management Information Base for Network Management of TCP/IP-based internets:MIB-II. K. McCloghrie, M.T. Rose. Mar-01-1991.1213 (Format: TXT=146080 bytes) (Obsoletes RFC1158) (Updated by RFC2011, RFC2012, RFC2013) (Status: STANDARD)
  38. 38. OSI connectionless transport services on top of UDP: Version 1. C. Shue, W. Haggerty, K.1240 Dobbins. Jun-01-1991. (Format: TXT=18140 bytes) (Status: PROPOSED STANDARD) ICMP Router Discovery Messages. S. Deering. Sep-01-1991.1256 (Format: TXT=43059 bytes) (Also RFC0792) (Status: PROPOSED STANDARD) Measurement Study of Changes in Service-Level Reachability in the Global TCP/IP Internet: Goals, Experimental Design, Implementation, and Policy Considerations. M.F. Schwartz. Nov-1273 01-1991. (Format: TXT=19949 bytes) (Status: INFORMATIONAL) A Unified Approach to Inter-Domain Routing. D. Estrin, Y. Rekhter, S. Hotz. May 1992.1322 (Format: TXT=96934 bytes) (Status: INFORMATIONAL) TCP Extensions for High Performance. V. Jacobson, R. Braden, D. Borman. May 1992.1323 (Format: TXT=84558 bytes) (Obsoletes RFC1072, RFC1185) (Status: PROPOSED STANDARD) The PPP Internet Protocol Control Protocol (IPCP). G. McGregor. May 1992.1332 (Format: TXT=17613 bytes) (Obsoletes 1172) (Status: PROPOSED STANDARD) DNS NSAP RRs. B. Manning. July 1992.1348 (Format: TXT=6871 bytes) (Obsoleted by RFC1637) (Updates RFC1034, RFC1035) (Updated by RFC1637) (Status: EXPERIMENTAL) THE TFTP PROTOCOL (REVISION 2). K. Sollins. July 1992. (Format: TXT=24599 bytes) (Obsoletes RFC0784) (Updates RFC1350, RFC1783) (Updated by1350 RFC1782, RFC1783, RFC1784, RFC1350, RFC1785, RFC2347, RFC2348, RFC2349) (Also STD0033) (Status: STANDARD) An IP Address Extension Proposal. K. Siyan. September 1992.1365 (Format: TXT=12790 bytes) (Status: INFORMATIONAL) Choosing a Common IGP for the IP Internet. P. Gross. October 1992.1371 (Format: TXT=18168 bytes) (Status: INFORMATIONAL) Suggestion for New Classes of IP Addresses. P. Robinson. October 1992.1375 (Format: TXT=16990 bytes) (Status: INFORMATIONAL) The PPP OSI Network Layer Control Protocol (OSINLCP). D. Katz. November 1992.1377 (Format: TXT=22109 bytes) (Status: PROPOSED STANDARD) An Experiment in DNS Based IP Routing. C. Huitema. December 1992.1383 (Format: TXT=32680 bytes) (Status: EXPERIMENTAL)
  39. 39. Traceroute Using an IP Option. G. Malkin. January 1993.1393 (Format: TXT=13140 bytes) (Status: EXPERIMENTAL) Correspondence between the IAB and DISA on the use of DNS. Internet Architecture Board.1401 January 1993. (Format: TXT=12528 bytes) (Status: INFORMATIONAL) Guidelines for Management of IP Address Space. E. Gerich. May 1993.1466 (Format: TXT=22262 bytes) (Obsoletes RFC1366) (Status: INFORMATIONAL) The Definitions of Managed Objects for the IP Network Control Protocol of the Point-to-Point1473 Protocol. F. Kastenholz. June 1993. (Format: TXT=20484 bytes) (Status: PROPOSED STANDARD) A Security Problem and Proposed Correction With Widely Deployed DNS Software. E. Gavron.1535 October 1993. (Format: TXT=9722 bytes) (Status: INFORMATIONAL) Common DNS Implementation Errors and Suggested Fixes. A. Kumar, J. Postel, C. Neuman, P.1536 Danzig & S. Miller. October 1993. (Format: TXT=25476 bytes) (Status: INFORMATIONAL) The PPP Internetworking Packet Exchange Control Protocol (IPXCP). W. Simpson. December1552 1993. (Format: TXT=29173 bytes) (Status: PROPOSED STANDARD) PPP LCP Extensions. W. Simpson. January 1994.1570 (Format: TXT=35719 bytes) (Updates RFC1548) (Status: PROPOSED STANDARD) Domain Name System Structure and Delegation. J. Postel. March 1994.1591 (Format: TXT=16481 bytes) (Status: INFORMATIONAL) DNS Server MIB Extensions. R. Austein & J. Saperia. May 1994.1611 (Format: TXT=58700 bytes) (Status: PROPOSED STANDARD) DNS Resolver MIB Extensions. R. Austein & J. Saperia. May 1994.1612 (Format: TXT=61382 bytes) (Status: PROPOSED STANDARD) PPP Bridging Control Protocol (BCP). F. Baker & R. Bowen. June 1994.1638 (Format: TXT=58477 bytes) (Obsoletes RFC1220) (Status: PROPOSED STANDARD) The Point-to-Point Protocol (PPP). W. Simpson, Editor. July 1994.1661 (Format: TXT=103026 bytes) (Obsoletes RFC1548) (Updated by RFC2153) (Also STD0051) (Status: STANDARD)1663 PPP Reliable Transmission. D. Rand. July 1994.
  40. 40. (Format: TXT=17281 bytes) (Status: PROPOSED STANDARD) ASSIGNED NUMBERS. J. Reynolds,J. Postel. October 1994.1700 (Format: TXT=458860 bytes) (Obsoletes RFC1340) (Also STD0002) (Status: STANDARD) DNS NSAP Resource Records. B. Manning & R. Colella. October 1994.1706 (Format: TXT=19721 bytes) (Obsoletes RFC1637) (Status: INFORMATIONAL) DNS Encoding of Geographical Location. C. Farrell, M. Schulze, S. Pleitner & D. Baldoni.1712 November 1994. (Format: TXT=13237 bytes) (Status: EXPERIMENTAL) Tools for DNS debugging. A. Romao. November 1994.1713 (Format: TXT=33500 bytes) (Also FYI0027) (Status: INFORMATIONAL) Post Office Protocol - Version 3. J. Myers & M. Rose. November 1994.1725 (Format: TXT=35058 bytes) (Obsoletes RFC1460) (Obsoleted by RFC1939, STD0053) (Status: DRAFT STANDARD) POP3 AUTHentication command. J. Myers. December 1994.1734 (Format: TXT=8499 bytes) (Status: PROPOSED STANDARD) IPv4 Option for Sender Directed Multi-Destination Delivery. C. Graff. March 1995.1770 (Format: TXT=11606 bytes) (Status: INFORMATIONAL) TFTP Option Negotiation Analysis. G. Malkin & A. Harkin. March 1995.1785 (Format: TXT=3354 bytes) (Updates RFC1350) (Status: INFORMATIONAL) Representation of IP Routing Policies in a Routing Registry (ripe-81++). T. Bates, E. Gerich, L.1786 Joncheray, J-M. Jouanigot, D. Karrenberg, M. Terpstra, & J. Yu. March 1995. (Format: TXT=133643 bytes) (Status: INFORMATIONAL) ICMP Domain Name Messages. W. Simpson. April 1995.1788 (Format: TXT=11722 bytes) (Status: EXPERIMENTAL) DNS Support for Load Balancing. T. Brisco. April 1995.1794 (Format: TXT=15494 bytes) (Status: INFORMATIONAL) Requirements for IP Version 4 Routers. F. Baker. June 1995.1812 (Format: TXT=415740 bytes) (Obsoletes RFC1716, RFC1009) (Status: PROPOSED STANDARD) IP Authentication Header. R. Atkinson. August 1995.1826 (Format: TXT=27583 bytes) (Status: PROPOSED STANDARD)1827 IP Encapsulating Security Payload (ESP). R. Atkinson. August 1995.
  41. 41. (Format: TXT=30278 bytes) (Status: PROPOSED STANDARD) IP Authentication using Keyed MD5. P. Metzger & W. Simpson. August 1995.1828 (Format: TXT=9800 bytes) (Status: PROPOSED STANDARD) Whois and Network Information Lookup Service, Whois++. J. Gargano & K. Weiss. August1834 1995. (Format: TXT=14429 bytes) (Status: INFORMATIONAL) Architecture of the WHOIS++ service. P. Deutsch, R. Schoultz, P. Faltstrom & C. Weider.1835 August 1995. (Format: TXT=80581 bytes) (Status: PROPOSED STANDARD) Security Considerations for IP Fragment Filtering. G. Ziemba, D. Reed & P. Traina. October1858 1995. (Format: TXT=20468 bytes) (Status: INFORMATIONAL) SMTP Service Extensions. J. Klensin, N. Freed, M. Rose, E. Stefferud & D. Crocker. November1869 1995. (Format: TXT=23299 bytes) (Obsoletes RFC1651) (Also STD0010) (Status: STANDARD) SMTP Service Extension for Message Size Declaration. J. Klensin, N. Freed, & K. Moore.1870 November 1995. (Format: TXT=18226 bytes) (Obsoletes RFC1653) (Also STD0010) (Status: STANDARD) A Means for Expressing Location Information in the Domain Name System. C. Davis, P. Vixie,1876 T. Goodwin & I. Dickinson. January 1996. (Format: TXT=29631 bytes) (Updates RFC1034, RFC1035) (Status: EXPERIMENTAL) Variable Length Subnet Table For IPv4. T. Pummill & B. Manning. December 1995.1878 (Format: TXT=19414 bytes) (Obsoletes RFC1860) (Status: INFORMATIONAL) SMTP Service Extension for Delivery Status Notifications. K. Moore. January 1996.1891 (Format: TXT=65192 bytes) (Status: PROPOSED STANDARD) Common DNS Operational and Configuration Errors. D. Barr. February 1996.1912 (Format: TXT=38252 bytes) (Obsoletes RFC1537) (Status: INFORMATIONAL) Architecture of the Whois++ Index Service. C. Weider, J. Fullton & S. Spero. February 1996.1913 (Format: TXT=33743 bytes) (Status: PROPOSED STANDARD) How to Interact with a Whois++ Mesh. P. Faltstrom, R. Schoultz & C. Weider. February 1996.1914 (Format: TXT=17842 bytes) (Status: PROPOSED STANDARD) Variance for The PPP Connection Control Protocol and The PPP Encryption Control Protocol. F.1915 Kastenholz. February 1996.
  42. 42. (Format: TXT=14347 bytes) (Also BCP0003) (Status: BEST CURRENT PRACTICE) Post Office Protocol - Version 3. J. Myers & M. Rose. May 1996.1939 (Format: TXT=47018 bytes) (Obsoletes RFC1725) (Updated by RFC1957) (Also STD0053) (Status: STANDARD) Some Observations on Implementations of the Post Office Protocol (POP3). R. Nelson. June1957 1996. (Format: TXT=2325 bytes) (Updates RFC1939) (Status: INFORMATIONAL) The PPP Encryption Control Protocol (ECP). G. Meyer. June 1996.1968 (Format: TXT=20781 bytes) (Status: PROPOSED STANDARD) Serial Number Arithmetic. R. Elz & R. Bush. August 1996.1982 (Format: TXT=14440 bytes) (Updates RFC1034, RFC1035) (Status: PROPOSED STANDARD) PPP Link Quality Monitoring. W. Simpson. August 1996.1989 (Format: TXT=29289 bytes) (Obsoletes RFC1333) (Status: DRAFT STANDARD) The PPP Multilink Protocol (MP). K. Sklower, B. Lloyd, G. McGregor, D. Carr & T. Coradetti.1990 August 1996. (Format: TXT=53271 bytes) (Obsoletes RFC1717) (Status: DRAFT STANDARD) PPP Challenge Handshake Authentication Protocol (CHAP). W. Simpson. August 1996.1994 (Format: TXT=24094 bytes) (Obsoletes RFC1334) (Status: DRAFT STANDARD) Incremental Zone Transfer in DNS. M. Ohta. August 1996.1995 (Format: TXT=16810 bytes) (Updates RFC1035) (Status: PROPOSED STANDARD) A Mechanism for Prompt Notification of Zone Changes (DNS NOTIFY). P. Vixie. August 1996.1996 (Format: TXT=15247 bytes) (Updates RFC1035) (Status: PROPOSED STANDARD) TCP Slow Start, Congestion Avoidance, Fast Retransmit, and Fast Recovery Algorithms. W.2001 Stevens. January 1997. (Format: TXT=12981 bytes) (Status: PROPOSED STANDARD) IP Mobility Support. C. Perkins. October 1996.2002 (Format: TXT=193103 bytes) (Updated by RFC2290) (Status: PROPOSED STANDARD) IP Encapsulation within IP. C. Perkins. October 1996.2003 (Format: TXT=30291 bytes) (Status: PROPOSED STANDARD) Minimal Encapsulation within IP. C. Perkins. October 1996.2004 (Format: TXT=12202 bytes) (Status: PROPOSED STANDARD)2005 Applicability Statement for IP Mobility Support. J. Solomon. October 1996.
  43. 43. (Format: TXT=10509 bytes) (Status: PROPOSED STANDARD) The Definitions of Managed Objects for IP Mobility Support using SMIv2. D. Cong, M. Hamlen,2006 C. Perkins. October 1996. (Format: TXT=95030 bytes) (Status: PROPOSED STANDARD) TCP Selective Acknowledgement Options. M. Mathis, J. Mahdavi, S. Floyd, A. Romanow.2018 October 1996. (Format: TXT=25671 bytes) (Status: PROPOSED STANDARD) The PPP SNA Control Protocol (SNACP). A. Fuqua. October 1996.2043 (Format: TXT=13719 bytes) (Status: PROPOSED STANDARD) INTERNET REGISTRY IP ALLOCATION GUIDELINES. K. Hubbard, M. Kosters, D. Conrad,2050 D. Karrenberg, J. Postel. November 1996. (Format: TXT=28975 bytes) (Also BCP0012) (Status: BEST CURRENT PRACTICE) A DNS RR for specifying the location of services (DNS SRV). A. Gulbrandsen, P. Vixie. October2052 1996. (Format: TXT=19257 bytes) (Status: EXPERIMENTAL) Domain Name System Security Extensions. D. Eastlake, 3rd, C. Kaufman. January 1997.2065 (Format: TXT=97718 bytes) (Updates RFC1034, RFC1035) (Status: PROPOSED STANDARD) The PPP Bandwidth Allocation Protocol (BAP) / The PPP Bandwidth Allocation Control2125 Protocol (BACP). C. Richards, K. Smith. March 1997. (Format: TXT=49213 bytes) (Status: PROPOSED STANDARD) ISO Transport Service on top of TCP (ITOT). Y. Pouffary, A. Young. March 1997.2126 (Format: TXT=51032 bytes) (Status: PROPOSED STANDARD) Dynamic Updates in the Domain Name System (DNS UPDATE). P. Vixie, Ed., S. Thomson, Y.2136 Rekhter, J. Bound. April 1997. (Format: TXT=56354 bytes) (Updates RFC1035) (Status: PROPOSED STANDARD) Secure Domain Name System Dynamic Update. D. Eastlake. April 1997.2137 (Format: TXT=24824 bytes) (Updates RFC1035) (Status: PROPOSED STANDARD) TCP Control Block Interdependence. J. Touch. April 1997.2140 (Format: TXT=26032 bytes) (Status: INFORMATIONAL) U.S. Government Internet Domain Names. Federal Networking Council. May 1997.2146 (Format: TXT=26564 bytes) (Obsoletes RFC1816) (Status: INFORMATIONAL) A Primer On Internet and TCP/IP Tools and Utilities. G. Kessler, S. Shepard. June 1997.2151 (Format: TXT=114130 bytes) (Obsoletes RFC1739) (Also FYI0030) (Status:
  44. 44. INFORMATIONAL) PPP Vendor Extensions. W. Simpson. May 1997.2153 (Format: TXT=10780 bytes) (Updates RFC1661, RFC1962) (Status: INFORMATIONAL) Using the Internet DNS to Distribute MIXER Conformant Global Address Mapping (MCGAM).2163 C. Allocchio. January 1998. (Format: TXT=58789 bytes) (Obsoletes RFC1664) (Status: PROPOSED STANDARD) Referral Whois (RWhois) Protocol V1.5. S. Williamson, M. Kosters, D. Blacka, J. Singh, K.2167 Zeilstra. June 1997. (Format: TXT=136355 bytes) (Obsoletes RFC1714) (Status: INFORMATIONAL) Resolution of Uniform Resource Identifiers using the Domain Name System. R. Danie1, M.2168 Mealling. June 1997. (Format: TXT=46528 bytes) (Status: EXPERIMENTAL) Clarifications to the DNS Specification. R. Elz, R. Bush. July 1997.2181 (Format: TXT=36989 bytes) (Updates RFC1034, RFC1035, RFC1123) (Status: PROPOSED STANDARD) Selection and Operation of Secondary DNS Servers. R. Elz, R. Bush, S. Bradner, M. Patton. July2182 1997. (Format: TXT=27456 bytes) (Also BCP0016) (Status: BEST CURRENT PRACTICE) Use of DNS Aliases for Network Services. M. Hamilton, R. Wright. October 1997.2219 (Format: TXT=17858 bytes) (Also BCP0017) (Status: BEST CURRENT PRACTICE) Key Exchange Delegation Record for the DNS. R. Atkinson. October 1997.2230 (Format: TXT=25563 bytes) (Status: INFORMATIONAL) Mobile-IPv4 Configuration Option for PPP IPCP. J. Solomon, S. Glass. February 1998.2290 (Format: TXT=39421 bytes) (Updates RFC2002) (Status: PROPOSED STANDARD) Negative Caching of DNS Queries (DNS NCACHE). M. Andrews. March 1998.2308 (Format: TXT=41428 bytes) (Obsoletes RFC1034) (Updates RFC1034, RFC1035) (Status: PROPOSED STANDARD) Domain Names and Company Name Retrieval. J. Klensin, T. Wolf, G. Oglesby. May 1998.2345 (Format: TXT=29707 bytes) (Status: EXPERIMENTAL) TFTP Option Extension. G. Malkin, A. Harkin. May 1998.2347 (Format: TXT=13060 bytes) (Obsoletes RFC1782) (Updates RFC1350) (Status: DRAFT STANDARD)2348 TFTP Blocksize Option. G. Malkin, A. Harkin. May 1998.
  45. 45. (Format: TXT=9515 bytes) (Obsoletes RFC1783) (Updates RFC1350) (Status: DRAFT STANDARD) TFTP Timeout Interval and Transfer Size Options. G. Malkin, A. Harkin. May 1998.2349 (Format: TXT=7848 bytes) (Obsoletes RFC1784) (Updates RFC1350) (Status: DRAFT STANDARD) INTERNET OFFICIAL PROTOCOL STANDARDS. J. Postel, J. Reynolds. September 1998. (Format: TXT=110969 bytes) (Obsoletes RFC2300, RFC2200, RFC2000, RFC1920, RFC1880,2400 RFC1800, RFC1780, RFC1720, RFC1610, RFC1600, RFC1540, RFC1500, RFC1410, RFC1360, RFC1280, RFC1250, RFC1200, RFC1140, RFC1130, RFC1100, RFC1083) (Also STD0001) (Status: STANDARD)

×