„˚u˚’ı˚„’„]}µ’µıZ}„}}l’UNIT I INT RODUCTIO N AND APPLICATI ON L AYE R Data C omm
unicati on - Networks N etwork Ty pes P rotocol Lay ering TCP /IP P rotocol suit e OSI Mod el Intr oducti on to S ockets - A ppli cati on Layer p rotoco ls: HTTP FTP Email protocols(S MTP - P OP3 - IMAP - M IME ) DNS S NMP 1 .1 D ata C o mmuni ca tio n When w e comm unicate, we a re sha ring informa ti on. This sharing can b e local or remot e. The term tele comm unicati on, which includes te lephony, telegraphy, and televisi on, means comm unicati on at a dist ance (t ele is Gre ek for "far" ). The word data ref ers to information presented in whatever form is agre ed upon by the parties cr eati ng and u sing t he data. Data comm u n ications are th e exch an ge of d ata betw een tw o device s via some form of tran smi ssi on mediu m su ch as aw ire cable. For dat a comm unicati on s to occur, the comm unicati ng devices must be part of a comm unicati on syst em made up of a combi nat ion of hardwa re (physi c al equipm ent) and software (progr ams). The eff ecti veness of a d ata comm unicati ons syst em depends on four fun dament al ch aracterist ics: I. Deli very: The syst em must deli ver data to the correct desti nati on. Dat a must be received b y the intended devic e or us er . 2. Accu racy: The syst e m must deli ver the data accur ately. Data that h ave been alt e red in transmi ssi on and left unc orrect ed ar e unusable. 3. T im eli n ess: Thesyst emmust deli verdataina ti melymanner.D atadeli ve redlateare useless. 4. Jitter: Jit ter ref ers to the variati on in the pac ket arrival ti me. It is the uneven del ay in the deli very of audio or v ideo packets. 1.1.1 Com p on en ts A data comm unicati ons s ystem has five componen ts 1.Message: Th e messag e is the information (data) to be comm unicated. P opular forms of information i nclude text, num bers, pictures, audio, and video. 2.S en d er: The send er i s the device that sends the data messag e. It c an be a comput er, workstation, t elephone h andset, video cam era, an d so on. 3. Receive r: The rec eiver is the device that rec eives the message. It ca n be a comput er, workstation, t elephone h andset, t elevisi on, and so on. 4. T ran sm iss ion m edium : Thetransmi ssi onmediumisthephysi calpathb ywhichamess age travels from sender to r eceive r. S ome exampl es of transmi ssi on media include twist ed-pair wire, coaxi al cable, fiber opti c cable, and radio wa ves. 5. Proto col: A protocol is a set o f rules that gov ern dat a comm unic ati ons. It rep resents an agreem ent betwe en the comm unicati ng devices. Wit hout a protocol, tw o devices may b e connected but not comm unicati ng. 1.1.2 Data Rep r esen tati on In formation today come s in differ ent forms su ch as text, numbers, i mages, audio, and video. T ext In d ata comm unicati ons , text is represented as a bit patt ern, a sequenc e of bit s (O s or 1 s). Differ ent sets of bit patt erns have been designed to represent t ext sym bols.Each set i s call ed a code, and the p rocess o f r epresenti ng sym bols i s call ed coding. Unicode, which uses 32 bit s to represent a symb ol or characte r used in any language in the world. TheAmeric anS ta ndardC odeforInformati onInterch ange (AS C II), nowconst it utesthe first 127 char acters in Unicode and is also refe rred to as B asic Lati n. Num b ers Numbers a re also repr es ented by bit patt erns. H owever, a cod e such as ASC II is not us ed to repr esent numbe rs; t he number is dir ectl y c onverted to a binary n umber to sim pli fy mathemati cal oper ati ons. Im ages Imag es ar e also repres e nted by bit patt erns. In it s simpl est form, an image is compos ed of a matrix o f pixels (p icture elem ents), whe re each pix el is a small do t. The size o f the pixel depends on t he r esolut ion. The size and the v alue of the patt e rn dep en d on the image. For an im age made of on ly black-and-white dots (e.g., a chessboard ), a I-bi t patt ern is enough to repr esent a pixel. If a n im age is not made of pure white and pure bla ck pixels, you can increas e the size o f the bi t pattern to i nclude gray s cale There are s ever al m ethods to represent color im ag es. One method is call ed R GB, so call ed because ea ch color is m a de of a combi nati on of th ree prima ry colors: r ed, g reen, and blu e. The int ensit y of each col or is measured, and a bit patt ern is assi gned to it . Another method i s call ed YCM, i n which a color is m ade of a combi nati on of three othe r pri mary colors: yellow, cyan, and mag enta. Aud io Audio refe rs to the re cor ding or broadc asti ng of sound or musi c. Audio is by nature diff erent from t ext, num bers, or i mages. Vid eo Video ref ers to the r ecor ding or broadc asti ng of a picture or movie. Video can eit her b e produced as a conti nuous enti ty (e.g., by a TV ca mera), or it c an be a com bination of im ages, each a discr ete e nti ty, arranged to conv ey the idea of moti on. 1.1.3 Data Flow / tran s m iss ion m od e C omm unicati on between two devices c an be sim p lex, half- duplex, or full-d uplex as shown in Figure 1.2. S im plex In si mpl ex mode, the co mm unicati on is unidi recti onal, as on a one-way st r eet. Only one of the two devices on a li nk can transmi t; the other can only re ceive (see Fi gure 1.2a). Keyboards and tradit iona l m onit ors are exampl es of simpl ex devices. Advantage of S im plex mode: o In simpl ex mode, the stat ion can uti li ze the enti re bandwidth of the c omm unicati on channel, so that more data can be transmi tt ed at a t im e. Disadvantage of S im plex mode: o C omm unicati on is unidi recti onal, so i t has no int er-comm unicati on betw ee n devices. Hal f-Dupl ex In half-dupl ex mode, ea ch station can both trans mi t and rec eive, but not at the s ame ti me. When one d evice is s endi ng, the other can only rec eive, and vic e vers a (se e Figure 1.2b) Walki e-talkies and C B (cit izens band) radios are both half-duplex syst ems. The half- duplex mod e is used in cases wh ere the re is no ne ed for comm unicati on in bot h directi ons at t he same tim e. Advantage of H alf-duple x mode: o In h alf-duplex mode, bot h the devices c an send an d receiv e the data and als o can uti li ze the entire bandwid th of the comm unicati on channel during t he trans mi ssi on of data. Disadvantage of Half-Du plex mode: o In h alf-duplex mode, wh en one devic e is s ending the data, then anoth er has to wait , thi s causes the delay in s ending t he data at t he rig ht ti me. Fu ll-Dup lex Infull- duplex mode(also call ed duplex),bothstationscantransmi tandrece ive sim ult aneousl y (see Figur e 1.2c).Th e ful l-duplex mode is li ke a two-way stre et with traffi c flowing in both directi ons at the same tim e. One comm on exampl e of full-duplex comm unicati on is the telephonenetwork. When twopeoplearecomm unicati ngbyatelephoneli ne,bothcantalkand li sten at the same ti me. T he full-duplex mode is u sed when comm unicati on in both directi ons is required all the tim e. Advantage of Full-duple x mode: o B oth the stations can send and re ceive the data at the same ti me. Disadvantage of Full-dup lex mode: o If there is no d edicated p ath exist s between the d e vices, then the c apacit y o f the comm unicati on channel i s di vided into t wo parts. 1 .2N ETWORKS A network is a set of dev ices (oft en r efe rred to as nodes) conn ected by co mm unicati on li nks. Anodecanb eacomput e r,printer,oranyothe r de vicecap ableofsendinga nd/or receivi ngdat a generat ed by other nod es on t he network. Distrib u ted Processi n g Most networks use dist ributed proc essi ng, in which a task is divi de d among mul ti ple comput ers. Instead o f one singl e large ma chine being responsibl e fo r all aspects of a process, sep arate comp uters (usuall y a perso nal comput er or work station) handle a subset. 1.2.1 Netwo rk Crite ria A network must be ab le to meet a ce rtain n umber of criteria. The most im portant of these ar e per formanc e, r e li abil ity, and security. Performan ce P erformanc e c an be me asured in many w ays, i ncludi ng transit ti me and response ti me. Tran sit ti me istheamountofti merequiredfora messagetotrav elfromo nedevice to another. R espon se ti me is the elapsed ti me between an inqui ry and a response. The performan ce of a network dep ends on a number o f fa ctors, including the number of use rs, the type of transmi ssi o n medium, the capabil i ti es of the conne cted hardwa re, and the efficien cy of the softw are. P er formanc e is often evaluated by two n etworking metrics: th rou gh pu t an d delay. Throughput is an actu al measur ement of ho w fast data can be transmi tt ed. Latency/dela yistim erequiredforamessagetocompl etelyarriveatthedesti nati on from source. We oft en need more throughput and less delay. However, these two criteria ar e often contradictory. If w e try to send more data to the network, we may i ncreas e throughput but we incre ase the d elay because o f tra ffic cong es ti on in t he network. R eli abil it y In addit ion to accura cy of deli very, network r eli abil it y is measured by the frequen cy of fail ure, the ti me it takes a li nk to r ecove r f rom a fail ur e, and the netwo rk's robustness in a catastroph e. S ecu rit y Network se curity iss ue s include prote cti ng data from un authorized acc ess, prote cti ng data from d amage an d developm ent, and i mpl ementing poli cies a nd procedu res for recove ry from br ea ches a nd data losses. 1.2.2 Ph ysical S tru cture s Type of Con n ecti on / Lin e con figu rati on A network is two or m ore devi ces connected t hrough li nks. A li nk is a comm unicati ons pathway that trans fers d ata from on e devic e to another. The re are two possi ble types of connecti ons: point-to- point and mul ti point . Poin t-to-Poin t Apoint-to-point connecti onprovidesad edicat edli nkbetween twodevic es.Theenti re cap acit y of the li nk is r eserv ed for transmi ssi on betw ee n those two d evices. M ost point-to-point connecti ons use an actua l length of wir e or c able to conne ct the two ends (see Figur e 1.3 a). Whenyou change televis ionchannelsbyinf rar ed remot econtrol,you ar ee stablis hingapoint-to-point connecti on betw een the r emot e control an d the televisi on's control sys tem. Mu lt ipoin t Amul ti point (alsoc all edmul ti drop)connecti onis oneinwhi chmor ethan twospecifi cd evices share a singl e li nk (s ee F igure 1.3b). In a mul ti point environment, the capa cit y of the channel isshared,eit herspati all yortemporall y.If seve raldevicesc anuse theli nks im ult aneousl y,it is a spati all y shared connec ti on. If us ers must take tu rns, it i s a ti meshared con necti on. Ph ysical T op ology Theterm physi caltopol o gyref ersto thew ayinw hichan etworkis laidout physi call y.Two or more devices conn ect t o a li nk; t wo or more li nksform a topology. The topol ogy of a network is the geometric r epres en tation of the relations hip of all the li nks and li nking devices (usu all y call ednodes )toone anot her.The rear efour basict opologi es possi ble:mesh,star,bus,andring (see Figure 1.4). Mesh T op ology In a mesh topol ogy, ev ery device has a d edica ted point-to-point li nk to every othe r devic e. The term dedi cated me ans that the li nk carri e s traffic only betw een the two devices it connec ts. The number of physi c al li nks in a fully connecte d mesh network with n nodes is given by n (n 1 ) / 2. Star T op ology In a star topol ogy, e ac h device has a d edicate d point-to-point li nk only to a central controll er, usuall y call ed a hub. The devices a re not dire c tl y li nked to one another. Disad van tages of Mesh T op ology 1.Installati on and configur ati on is difficult. 2.C abli ng cost i s more. 3.B ulk wiring is required. Advan tages of Mes h T op ology 1.Each conn ecti on can car r y it s own data load. 2.It is robust . 3.Fault is diagnosed easil y. 4.P rovides security and privacy. The controll er/hub acts a s an exchange. If one device w ants to send data to another, it sends the data to the controll er/hub , which the n relays the dat a to t he other connect ed devic e. B u s T op ology B us topol ogy is a network type in which every comput er and network device is connect ed to si ngle cable. The long singl e cable acts as a backbone to li nk all the devices in a network. When it has exactl y two endpoint s, then it i s call ed Linear B us topol ogy. It tr ansmi ts data only in one directi on. Disad vantages of Bu s Top ology 1.C ables fail s then whole network fail s. 2.If network tr affi c is heav y or nodes ar e more, the per forman ce of the network decre ases. 3.C able has a li mi ted length. 4.It is slower than the ring topol ogy. Advan tages of Bu s Topology 1.It is cost e ffe cti ve. 2.C able required is l e ast co mpared to other network topol ogy. 3.Used in small networks. 4.It is easy t o unde rstand. 5.Easy t o expand joi ning t wo cables together Disadvan tages of S tar T opology 1.C ost of installation is hi gh. 2.Expensive to use. 3.If the hub fail s, then the whole network is s topped. 4.P erformanc e is based on the hub that is it depends on i ts capa cit y A dvan tages of S tar Topology 1.Fast per forman ce with fe w nodes and low network traffi c. 2.Hub can be upgr aded e as il y. 3.Easy to t roubleshoot . 4.Easy to setup and modi fy. 5.Only that node is affe cte d which has fail ed, rest of th e nodes c an work smoo thl y Rin g T op ology In a ring topol ogy, each device has a dedicat ed point-to-point connecti on with only the two devices on eit he r side of it. A signal is passed along the ring in one directi on, from device to device, unti l it re aches it s desti na ti on. Each device in the ring incorporat es a rep eater. When a device r ec eives a signal int ended for another device, its repeat er regene rates the bits and p asses them along. Hyb rid T op ology Hybrid Topology is a combi nati on of one or more basic topol ogies. For ex ampl e if one d ep artment in an offic e use s ring topol ogy, the other departmentsuses star and bus topol ogy,thenconne cti ngthesetopol ogieswill result in Hybrid Topology. HybridTopologyinherit stheadvantagesanddisad vantagesofthetopol ogie s included. Disad van tages of Rin g T op ology 1.Troubleshooti ng is difficult i n ring topol ogy. 2.Adding or deleting t he co mput ers dist urbs the network acti vit y. 3.Failure o f one compute r disturbs the whole network Advan tages of Rin g T op ology 1.Transmi tt ing network is n ot affe cted by high traffic or by adding more nodes, as only t he nodes having t okens can transmi t data. 2.Cheap to install and expand 1.3 NET WORK T YPES Differ ent t ypes of netwo r ks: LANs MANs and W ANs. 1.3.1 L ocal Area N etwo rk Local Are a Network is a group of comput ers connected to each other in a small area such as bui ldi ng, off ice. LAN is used for conn ecti ng two or more pe rsonal comput ers throu gh a comm unicati on mediumsuch as twis ted pair, coa xial cable, etc. It is less costl y as it is buil t with inexpensive hardwa re such as hubs, network adapt ers, and eth ernet c ables. The data is transfer red at an extremely faster rat e in Local Area Network. LAN can be conn ected u sing a comm on cable or a S witch Disad vantages of Hybrid Top ology 1.C ompl ex in design. 2.C ostl y Advan tages of Hybrid Top ology 1.R eli able as Erro r detecti n g and trouble shoot ing is easy. 2.Effecti ve. 3.S calable as size c an be in creas ed e asil y. 4.Flexible. 1.3.2 Metrop oli tan Ar e a Netwo rk (MAN ) o A metropoli tan are a net work is a network that c overs a la rger geog raphi c are a by int erconnecti ng a diff ere nt LAN to form a larg er network. o It gene rall y cov ers towns and cit ies (50 km) o In MAN, va rious LANs are conne cted to each o ther through a telephone exchang e li ne. o C omm unicati on mediumused for MAN a re opti ca l fibers, cables etc. o It has a higher range th an Local Ar ea N etwork(L A N). It i s adequ ate for distr ibut ed comput ing appli cati ons. 1.3.3 Wid e Area Ne two rk (WAN) o A Wide Ar ea Network is a network that ext ends over a larg e geographic al are a such as states or countries. o A Wide Are a N etwork is qui te bigger network than the LAN. o A Wide Are a N etwork is not li mi ted to a singl e locati on, but it spans over a large geog raphic al area th rough a telephone li ne, fi bre opti c cable or sat ell it e li nks. o The int ernet is one of the biggest WAN in the world. o A Wide Are a Network is widely used in the field of B usiness, government, and edu cati o n. o WAN can b e eit her a poi nt-to-point WAN or S witched WA N. Disad van tages of L AN High S etup C ost P rivacy Violations Data S e curity Threat LAN Maint en ance Job C overs Limi ted Area Advan tages of LAN R esource S haring S oftware Applicati ons S haring. Easy and C heap C omm unicati on C entrali zed Data. Data S ecurity Inte rnet S haring Poin t-to-Poin t WA N A point-to-point WAN is a network that conn ects two comm unicati ng devices through a transmi ssi on medium (cable or air). Figure 1.9 sho ws an exampl e o f a point-to-point WAN. S w it ch ed WA N A swit ched WA N is a ne twork with m ore than tw o ends. It i s used in the backbone of a global comm unicati ons network today. Figure 1.1 0 shows an exampl e o f a switched WAN Disad van tages of Wid e Area Netwo rk : oS ecurity iss ue oNeeds Fi rew all & anti virus softwar e oHigh S etup cost oTroubleshooti ng problems Advan tages of Wid e Ar ea Net work : oLarge Geogr aphical are a oC entrali zed data oExchange messag es oS haring of softwar e and r esources oHigh bandwidth In ternetw ork Today, it is very rare to see a LAN or a WAN in isol ati on; they are connected to one another. When two or m ore netwo rks a re connect ed, they mak e an int erne twork, or int ern et. Asanexampl e,assum ethatanorganiz ati onhastwooffices,on eontheeas tcoastandtheothe r on the west coast. Each of fice h as a LAN t hat all ows all empl oye es in the offic e to comm u nicate with each oth er. To make th e comm unicati on betwe en empl oyees at dif fer ent of fices possi ble, the management le ases a p oint-to-point dedicated WAN from a servi ce p rovider, suc h as a telephone company, and connects t he two LA Ns. Now the company has an int ernetwork, or a private int ernet (wit h lowerc ase i). C omm unicati on between offices is now possibl e. Figure 1.11 shows thi s int ernet. T yp es of In tern e twork E xtran et In tran et An ext ranet is us ed for information sharing. The a cc ess to th e extran et is r estricted to only those users who hav e l ogin credenti als. An extranet is the lowest lev el of int ern etworking. It can be c ategoriz ed as MAN, WAN or oth er comput er networ ks. An e xtranet c annot have a singl e L AN, atl east it mu st have one connecti on to the extern al n etwork. An int ran et b elongs to an org anizati on which is only acc essi ble by th e organ ization 's em p loyee or membe rs. The main aim of the int ranet is to share the information and res ources among the organizati on empl oyees. An int ran et p rovides the facil it y to work in groups and for teleconfe ren ces. 1.3.4 T h e In tern et An int ernet (note the low ercas e i) is t wo or more n etworks that can comm unicate wit h ea ch other. The most notable i nternet is call ed the Inter net (upper case I) and is c ompos ed of thous ands of int erconne c ted networks. Figu re 1.1 3 shows a conc eptual (no t geographical ) view of the Inte rnet. ThefigureshowstheInte rnetassever albackbones ,providernetworks,andc ustom ernetworks. Atthetoplevel,thebackbonesarelargenetwo rksownedbysomecomm unicati oncompanies. The ba ckbone n etworks are conne cted through some compl ex switchi ng syst ems, call ed peering point s. Atthesecondlev el,there aresmalle rnetworks, cal ledprovidern etworks,th atusethese rvices of the backbon es for a f e e. The provid er netwo rks are connect ed to backbo nes and someti mes tootherprovide rn etwork s.Thecustom ernetwo rks are netwo rksatth eedg eoftheInternet that actually use the services provided by the Inte rne t. They pay fees to prov ider networks for receivi ng se rvices. B ackbones and provide r networks are also call ed Internet S ervic e P ro viders ( IS P s). The backbones ar e often ref er red to as int ernati onal IS P s; the provider networks are often ref err ed to as nati onal or regional IS P s. 1.3.5 Accessi n g the Inte rn et The Intern et t oday is an i nternetwork that all ows a ny user to become p art of it . The user, however, n eeds t o be phy sicall y connected to an ISP . The physi cal connect ion i s normall y done through a point-to-point WAN (such as a tel ephone netwo rk, a c able network, a wir eless network, or othe r types o f networks). Usin g Telephon e Netw orks Today most residences a nd small busi nesses have telephone se rvice, whi ch means they a re connected to a telephon e network. B ec ause most telephone netwo rks have already conne cted themselves to the Intern et, one opti on for reside nces and small busi ness es to connect to the Inte rnet i s to change the voice li ne betw een the r e sidence or busi ness and the telephone cent er to a point-to-point WAN. This can be done in t wo ways. o Dial-up se rvice. The first solut ion is to add a modem that converts d ata to voic e to the telephone li ne. The software inst all ed on the comput er dials the IS P and im it ates making a telephoneconne cti on. Un fortunately,thedial-upse rviceisveryslow,and w hentheli neisused foranInte rnetconn ecti on,it cannotbeusedforat elephone(voic e)conn ecti on.Itisonlyuseful for small residenc es and busi nesses wit h occasion al connecti on to t he Inte r net. o DSL S ervice. S ince t he advent o f the Int ernet , some telephone compa nies have upg raded theirtelephoneli nestoprovidehigher-spe ed Intern etservicestoresiden ceso rsmallbusi nesses. The digi tal subscriber li ne (DS L) s ervice also al lows the li ne to be used sim ult aneousl y for voice and dat a comm unicati ons. Usin g C able Netw orks Moreand moreresidentsoverthel asttwode cades havebegun using c able T Vservic esinst ead of antennas to receiv e TV broadcasti ng. The cabl e companies have be en upgrading t heir cabl e networks and conn ecti ng to the Int ernet. A r eside nce or a small busi ness c an be conne cted to the Intern et by using thi s servic e. It provides a hi gher-spe ed connecti on, b ut the spe ed va ries depending on t he number of neighbors that use the same cable. Usin g Wir eless Netw orks Wireless conne cti vit y has rec entl y become incr easingl y popular. A household or a small busi ness can us e a combi nati on of wir eless and wired conn ecti ons t o a cc ess t he Intern et. Wit h the growing wirel ess W AN ac cess, a household or a small busi ness can be conne cted to the Inte rnet t hrough a wirele ss WAN. Direct C on n ecti on to t h e In ternet A large org anizati on or a large corpo rati on can it s elf become a local IS P and be connected to the Inte rnet. This can be done if the organizati on or the corpor ati on leases a high-speed WA N from a car rier provid er a nd connects it self to a re gional IS P . For ex ampl e, a large universit y with several c ampus es c an cre ate an int e rnetwor k and then conne ct the int ernetwork to th e Inte rnet. 1.4 PROT OCOL L AYE RING In n etworking, a protoco l d efin es the ru les that b oth the sender and re ceiv er and all int ermediate devic es nee d to foll ow to be able to com m un icate eff ectivel y. A protocol provides a comm unicati on service that the process use to exchange messages. When comm unicati on is sim ple, we may need onl y one sim ple protocol. When the comm unicati on is compl ex, we may need to divi de the task between diff ere nt layers, in which c ase w e need a proto col at ea ch la yer, or p roto col layerin g . P rotocol layering is that it all ows us to s epar ate th e servi ces from the im plementation. A layer needs to be able to receive a set of se rvic es from the lower layer and to give the services to t he uppe r laye r. Any modi ficati on in one layer will not affect t he o ther layers. B asic E lem en ts of L ayered Arch itec ture S ervice: It i s a set of acti ons t hat a layer provides to t he higher layer. Protocol: It de fines a set of rules that a layer uses to ex change the informa ti on with peer e nti ty. These rules mainly concern about b oth the contents and ord er of the messages used. In terfac e: It is a way through which the message is transferred f rom one layer to another laye r. Features of Pro tocol L a yerin g 1. It de compos es the probl em of buil ding a netwo rk int o more manag eabl e components. 2. It p rovides a mor e modul ar design. 1.4.2 Prin cip les of Prot ocol L ayerin g 1. Thefirstprincipl edictate sthatifwewantbidi recti onalcomm unicati on,weneed t o make ea ch laye r so that it is able to perform t wo opposi te tasks, one in each directi on. 2. The second principl e that we need to follow in protocol layering is that the two objects under ea ch laye r at bot h si tes shoul d be identi cal. 1.5 T CP/IP PROT OCOL S UITE (INT E RNE T ARCHIT E CTURE ) The TCP /IP archit ectur e is also call ed as Int ernet archit ectu re. It is develop ed by the US Defense Advan ced R ese arch P roject Agen cy (DA RPA) for it s packet swit ched n etwork (ARPANET). TCP /IP is a protocol suite used in the Intern et t oday. It is a 5-laye r model. The layers of TCP / IP are 1. Applicati on laye r 2. Transport Lay er (TCP /U DP) 3. Network Lay er 4. Datalink Laye r 5. P hysi cal Layer 1.5.1 L ayered Ar ch itect u re To show how the layers in the TCP/IP protocol suit e are invol ved in comm unicati on betweentwohost s,weassum ethatwewanttouse thesuit einasmallint ernetmadeupofthree LANs (links), each with a li nk-layer switch. We also assum e that the li nks are conne cted by one router, as shown i n Figure 1.18 (on next page). L et us assum e that comput er A comm unicates wit h com puter B . As Figure 1.18 shows, we have fiv e comm unic ati ng devices in thi s comm unicati on: source host (comput er A ), the li nk-layer switch in li nk 1, the router, the link-layer switch in li nk 2, and the desti nation host (comput er B ). Each devic e is invol ved with a set of layers dependingontheroleofthedeviceintheint ernet.Thetwohost sareinvol vedinall fivelayers. 1.5.2 Descrip tion of Eac h L ayer After unde rstanding t he c oncept of logi cal commu nicati on, we ar e r eady to briefly discuss the duty of each lay er. A ppli cati on Layer An appli cati on layer in corporat es the fun cti on of top three OS I lay ers. An appli cati on layer is the topmost layer in the TCP /IP model. It is responsi ble for handl ing high-level protocols, iss ues of representation. This layer all ows the user to int eract with the appli cati on. When one appli cati on layer protocol wants to comm unicate with another appli cati on layer, it forw ards its data to the transp ort layer. P rotocols such as FTP , HTTP , S MTP , P OP3, etc running in the appli cati o n layer provides service to ot her program running on t op of appli cati on laye r Tran sport Layer The transport layer is re sponsi ble for the reli abil it y, flow control, and correcti on of data which is being se nt over the network. The two protocols used in the transport layer a re User Datag ram p rotoc ol and T ran sm ission con trol protocol. o UDP UDP provides c onnecti onless service an d end-to- end deli ve ry of transmi ssi on. It is an unreli able protocol as it discovers the e rrors but not specify the er ror. o T CP TCP provides a full transport layer servic es to appli cati ons. TCP is areli ableproto colasit de tectstheerro randr etrans mi tsthedamaged fr ames. Netw ork Layer The network layer is the thi rd layer of the TCP /IP model. The main responsi bil it y of the network lay er is to send the pack ets from an y network, and they ar rive at the desti nati on irrespec ti ve of the route they take. Network lay er handle the transfer of information across mul ti ple networks through router and gate w ay . IP protocol i s used in thi s layer, and it is t he most signi ficant part of the enti re TCP /IP suit e. Data Lin k Layer We hav e seen that an int ernet i s made up of s ever al l inks (LANs and WA Ns) connected by routers. W hen the next l ink t o trave l i s determi ned by the ro uter, the data- li nk layer is r espons ibl e for taking the datag r am and moving i t across the link. Ph ysical Layer The physi cal l aye r is resp onsi ble for ca rrying i ndivi dual bi ts i n a frame a cro ss t he li nk. The physi cal l aye r is the lowest level i n the TC P /IP protocol sui te. The comm unicati on betw een two devic es at t he ph ysical l ayer is st il l a logical comm unicati on becaus e there is anothe r hidden la yer, the transmi ssi on me dia, under the physical l ayer. 1.6 T HE OS I MODEL An IS O standard that cov ers all aspe cts of network comm unicati ons i s the Open S ystems Inter connecti on (OS I) model. It was first i ntroduced in t he late 197 0s. An open syst em is a s et of protocols that all ows any two dif fer ent syst ems to comm unicate reg ardless of their underlying archit ecture. Th e purpose of th e OSI model is to showhowtofacil it ateco mm unicati onbetweendif ferentsyst emswithout re quiringchangesto the logic of the underlyin g hardwa re and so ftwar e. The OS I model is not a protocol; it is a model for unde rstanding and designi ng a network a rchit ectur e that is flexibl e, robust, and int eroperabl e. The OS I model is a laye red framewo rk for the design of network syst ems that all ows comm unicati on between all types of comput ersyst ems. Itcon sis tsofsevensepa ratebu trelatedlay ers,e acho fw hichdefines apar t of the proc ess of movi ng information across a n et work (se e Figur e 1.21). 1.6.1 App li cation L ayer This is the only layer that directl y int eracts with data from the user. S oftware appli cati ons li ke web br owsers and email cli ent s rely on the appli cati on layer to ini ti ate comm unicati ons. B ut it should be made clear that cli ent software appli cati ons are not part of the appli cati on lay er; r ather the appli cati on lay er is responsi ble fo r the p rotocols and dat a manipulation that the so ftware r eli es on to pres e nt meaningful d ata to th e user. Applic ati on layer protocols include HTTP as well as S MTP (Sim ple Mail Transfer P rotocol is one of the protocols t hat enables em ail comm unicati ons). 1.6.2 Presen tation L aye r This layer is p rimarily r esponsi ble for p rep aring data so th at it can be u sed by the appli cati on layer; in other words, laye r 6 make s the data presentabl e f or appli cati ons to consum e.Thepr esentatio nlayerisresponsi ble for translation, encryption,a ndcompressi onof data. Twocomm unicati ngdevicescomm unicati ngmaybeusing differentencodingmethods, so layer 6 is responsi ble for tran slat in g incoming data int o a synt ax that th e appli c ati on laye r of the re ceivi ng device c an understand. If the devices ar e comm u nicati ng over an en crypt ed connecti on, layer 6 is responsi ble receiv er's end so t hat i t c an present t he appli cati o n layer wit h unenc rypted, readabl e data. Finally the presentation layer is also responsi ble for compr essi n g data it receives from theappli cati onlayerbefo redeli veringit tolayer5.Thishelpsim provethespeedandeffi ciency of comm unicati on by mi nim izing the amount of data that wil l be transf err e d. 1.6.3 S essi on L ayer This is the layer responsi ble for op ening and closi ng comm unicati on betwe en the tw o devices. Th e ti me b etwe en when the comm unica ti on is opened and close d is known as the sessi on. The sessi on l aye r ensur es that the sessi on stays open long enough to transfe r all the databeingexch anged,an dthenpromptl yclosesthesessi oninordertoavoid wasti ngresourc es. This l ayer is responsi ble for the establis hment of c onnecti on, maintenanc e of sessi ons, authenticati on, and also e nsures secu rity. 1.6.4 T ran sp ort L ayer Layer 4 is responsi ble f or end-to-end comm unic ati on between th e two d evices. This includes taking data fro m the sessi on layer and breaking it up int o chunks call ed segment s before sending it to layer 3. The transport layer on the receivi ng devic e is responsi ble for reassembli ng the segmen ts i nto data the sessi on layer can consum e. Thetransport layer isals oresponsi blefo r flowco n trol an derrorcon trol.Flowcontrol determi nesanopti malspeedoftransmi ssi ontoensurethatasenderwithafastconnecti ondoes not overwhelm a re ceive r with a slow connecti on . The transpo rt layer per f orms erro r control on the receivi ng end by ensuring that the data rec eived is compl ete, and requesti ng a 1.6.5 Netwo rk L ayer The network lay er wo rks for the transmi ssi on of d ata from one host to t he o ther located in diffe rent netw orks. It also t akes c are o f packet rou ti n g i.e. selecti on of the shortest addresses are pla ced in t h e head er by the netwo rk l ayer. The functi ons of the N et work layer are : 1. Routin g: The network la yer protocols dete rmine which route is sui table fr om so urce to desti nati on. This functi on of the network lay er i s known as routing. 2. L ogical Add ressi n g: In order to identi fy e ach de vice on int ernetwo rk uniquely, the network laye r defines an addressi ng schem e. The s endeplaced in t he he ader by t he network lay er. Such a n address di sti nguis hes e ach devic e uniquely and universall y. 1.6.6 Data L in k L ayer The data link l aye r is res ponsi ble for the node-to-node deli very of th e mes sage. The main functi on of thi s layer is to m ake sure d ata transf er is error-fre e from one no de to another, ove r the physical l ayer. When a pack et arriv es in a netw ork, it i s the responsi bil ity of DLL to transmi t i t t o the Host us ing it s MAC address. Data Link Lay er is divi ded int o two subl ayers: 1. Logical Li nk C ontrol (LLC) 2. Media Acc ess C ontrol ( MAC) The pack et re ceived f ro m t he Network laye r is f urther divided into fram e s depending on the frame siz e of N IC (Ne twork Interf ac e C ard). D LL also encapsul ates Sen der and will reply wit h it s MAC address. 1.6.7 Ph ysical L ayer This l ayer includes the p hysi cal equipment invol ved in t he data trans fer, su ch as the cables and switch es. This i s also t he layer whe re th e data gets conv erted int o a bit stream, which is a string of 1s an d 0s. The physi cal l aye r of both devices mus t also agree on a signal conventi on so t hat t he 1s can be dist ingui shed fro m t he 0s on bot h devices. S u mm ary of Layers COMPARISO N - OS I MODE L AND T CP/IP MODE L S.No OSI M ODEL TCP/IP M ODE L 1 Defined before advent of internet Defined after the adve n t of Internet. 2 Service inte rface an d protocols are clearly disti nguishe d before Service i nterface and p rotocols were not clearly di stinguis he d before 3 Internetwor king not su pported TCP/IP suppor ts In tern et working 4 Strict la yering Loosely layered 5 Protocol indep endent st andard Protocol Depe ndant sta ndard 6 Less Credi ble More Credibl e 7 All packet s are reliably delivered TCP reli ably deliv ers packets, IP does not relia bly deli ve r packets 1.7 In trod u ction to Sockets A sock et is one endpoin t of a two way comm un icati on li nk between two programs running on the network. The socket mechanism provides a means of int er- process comm unicati on(IP C )byestablis hingnamedcontactpoint sbetweenwhichthe comm unicati on take plac e. s ystem call . The socket p rovides bidi recti onal FIFO C omm unicati on facil it y over th e network. A so cket connecti ng to the netwo rk is creat ed at ea ch end of the comm unicati on. Each sock et has a specific add ress. Thi s ad dress i s compos ed of an I P address and a po rt number. S ocketar eg ener all yemp loyedincli ent serv erappl icati ons.Thes erve rcre at esa socket, att aches it to a netwo rk p ort addresses th en wait s f or the cli ent to conta ct it . The cli ent cr eates asocketandthenatt empt stoconnecttotheserver socket.Whentheconn ec ti onisestablis hed, transfer o f data tak es pl a ce. 1.7.1 S ock et Ad d resses The int er acti on betw een a cli ent and a serv er i s two- way comm unicati on. In a two-way comm unicati on, we ne ed a pair of addresses: local (sende r) and remot e (rec eiver ). The local address in on e directi on is the remot e a ddress in the other direct ion, and vice v ersa. B ecause comm unicati on in the cli ent/ server parad igm is between two sockets, we need a pair of socket addr esses fo r c omm unicati on: a local socket address an d a remot e sock et addr es s. A socket address shoul d first define the comput e r on which a client o r a s erver is running. A comput er in th e Int ernet is uniquely define d by it s IP addr ess, a 32-bit int eger in the curr ent Inte rnet version. An app li cati on program can be defined by a port number, a 16-bit int eger. This means that a socket address shoul d be a combi nati on of an IP address and a port number as shown in Figure 10.7. B ecause a socket de fines the end-point of the com muni cati on, we can s ay that a socket i s identified by a pair of so cket addr esses, a loc al an d a remot e. 1.7.2 Fin d in gS ock et Ad d resses How c an a cli ent or a se r ver find a pair o f so cket addresses for comm unica ti on? The sit uati on is di fferent fo r ea ch si te. S erver S ite The serve r ne eds a local (serve r) and a remot e (cli ent) socket add ress fo r co mm unicati on. Local S ocket A ddress The local (serv er) sock et a ddress is provided by the operati ng syst em. The ope rati ng syst em kn ows the IP addr ess of th e comput e r on which th e serv er proc ess is running. The port number of a serve r process, h owever, ne eds to be assi gned. If the server process is a standard one defined by the Int ernet a uthorit y, a port number is already assi gned to i t. When a serv er starts running, i t knows t he local socket addr ess. R emot e S ocket A ddress The remot e sock et addr e ss for a serv er is the sock et address of th e cli ent t hat m akes the con necti on. B ecaus e the serv er can s erve m any cli ents , it does not know beforeh and the r emot e so cket addr ess for c omm unicati on. The serv er c an fi nd thi s socket address wh en a cli ent t rie s to connect t o the serv er. The cli ent socket addres s, which is contained in t he requ est packet sent t o the se rver, becomes the r emot e sock et address t hat i s used for r espondi ng to t he cli ent. Client S ite The cli ent also ne eds a lo cal (cli ent) and a r emot e (serve r) sock et address f or comm unicati on. Local S ocket A ddress T he local (cli ent) socket address is also provided by the op erati n g syst em. The operati ng syst em knows the IP add ress of the comput er on which the cli ent is running. The port numbe r, howeve r, is a 16- bit t emporary int eg er that is assi gned to a cli ent process e ach ti me the pr ocess needs to start the c omm unicati on. The port number, howeve r, needs to b e assi gned fro m a set of int eg ers defin ed by th e Inte rnet autho rity and call ed th e ephemer al (tempor ary) p ort numbers. The op erati ng syst em, however, n ee ds to guarante e that the new port num ber is n ot used by any other runn ing client process. R emot eS ocketA ddress Findi ngtheremot e(serve r)socketaddressforacli ent,however,needs more work. When a cli e nt process starts, it should know the socket address of the server it wants to conn ect to. W e will have two sit uati ons in thi s c ase. S ometim es, the user wh o starts the cli ent proc es s knows both the server port number andIP add resso fthe com puteronwhi chthe serv erisrunning.Thisusuall yo ccursin sit uati ons when we h ave w ritten cli ent and serv er appli c ati ons and we w ant t o test t hem Although each standard appli cati on has a well-known port number, most of the ti me, we do not kno w the IP a ddress. This happ ens in s it uati ons such as wh en w e ne ed to cont act a web page, send an e-m ail to a friend, or copy a file from a remot e sit e. In t hese sit uati ons, the server h as a name, an id enti fier that uniquely def ines the server pro cess. Exampl es of these identifiers are URLs, su ch as www.xxx.yyy, or e-mail address es, such a s [email protected]. Thecli entprocessshoul dnow changethi sidentifier(name )tothecorrespo ndingserversocket address. 1.8 App li cation L ayer The appli cati on laye r is the highest l ayer in the pr otocol sui te. The appli cati on laye r pro vides services to t he use r . C omm unicati on is provided usi ng a logi cal conne c ti on, which means t hat t he two appli cati on layers assum e that there is an im agina ry direct conn ecti on thro ugh which they can send and re ceiv e messages. The appli cati on laye r is the only layer that provid es services to t he Intern et user The appli cati on laye r exc hange messag es with t heir peers on oth er machin e s Applicati ons need their o wn protocols. These appli cati ons are p art of netwo rk protocol. T yp es of Ap p li cation Protocols: S tandard and Nonstand ar d P rotocols S tan dard A ppli cati on-Layer Prot ocols o There are s ever al applicati on-laye r protocols t ha t have been st and ardiz ed and documented by the I nternet authorit y. o Each st anda rd protocol is a pair of comput e r pro grams t hat i nteract wit h t he user and the tr ansport lay er to provide a sp ecific s ervice to t he us er. o Two very widely-used standardized appli cati on protocols: S MTP : Sim ple Mail Transfer Protocol i s used to exchang e ele ctronic mail. HTTP : Hyper Text Tr an sport P rotocol i s used to comm unicate between Web bro wsers a nd Web serv ers. Nons tan dard A pplication-Layer Prot ocols o A programm e r can cre a te a nonst andard appli cat ion-layer prog ram i f they can writ e two programs t hat provide se rvice to t he user by inte ra cti ng with the transport layer. App li cation-L ayer Parad igm s Two paradigm s hav e bee n developed fo r Appli cat ion Layer 1. Tradit ional P aradigm : C li ent-S erver 2. New Par adigm : P eer-to-P eer Client-S erve r Parad igm o The tradit ional par adigm is call ed the cli ent-ser ver par adigm . o It w as the most popular P aradigm . o In thi s pa radigm , the se rvice provide r is an appli cati on program, call ed th e serve r proc ess; it runs conti nuousl y, wait ing for another appli cati on program, c all ed the cli ent process, t o make a conne cti on through the Inte rnet and ask for s ervi ce. o The serve r proc ess m ust be running all the ti me; the cli ent process i s st art ed when the cli ent needs t o re ceive se rvice. o There are no rmall y som e server p roc esses that can provide a specifi c type of servic e, but there a re many cli ents t hat request s e rvice f rom a ny of these serv er pro ces ses. Peer-to-P eer (P2P) Pa ra d igm o A new pa radigm , call e d the peer-to-pee r par adi gm has emerged to r espo nd to the needs of some new appli cati ons. o In thi s pa radigm , there is no need for a serv er pr ocess t o be running all t h e ti me and wait ing for the cli ent pro cesses to connect. o The responsi bil it y is s hared betw een p eers. o A comput er conn ected to t he Inte rnet c an provid e servic e at one tim e and receiv e servic e at another ti me. o A comput er c an even p rovide and r eceiv e servic es at t he same tim e. Mixed Parad igm o An appli cati on may ch oose to us e a mi xture of t he two paradigm s by co mbi ning t he advantages o f both. o For ex ampl e, a li ght-lo ad cli ent-serv er comm unicati on can b e used to fin d the address of the peer that can of fer a s ervice. o When the add ress of the peer is foun d, the actu a l service c an be r ec eived from the pee r by using the peer-to-p eer p a radigm . 1.8.1 T h e Hyp erT ext Tran sfer Proto col (HT T P) The HyperT ext Trans fe r Protocol (HTTP) is use d to define how the cli ent- serve r progr ams can be w ritten to retriev e web pages from t he W e b. It i s a pr otocol used to acc ess t he data on the W orld Wide Web (W WW). The HTTP protocol c a n be used to t ransf er the data in the form of plain t ext, hypertext, audio, vi deo, and so on. HTTP is a stateless req uest/ response protocol th at governs cli ent/ serv er c omm unicati on. An HTTP client sends a request; an HTTP serve r returns a response. The serve r uses the po r t num ber 80; the cli ent uses a tempora ry port num ber. HTTP uses the servic es of TC P , a connecti on-or iented and reli abl e protoc ol. HTTP is a text-oriented protocol. It contains em bedded URL known as li nks. When hypertext i s cli ck ed, browse r opens a n ew connecti on, ret rieves file from the server and dis plays the file. Each HTTP messag e h as the gene ral form S TAR T_LINE <C R LF> MES S AGE_HEADER < C R LF> <C R LF> MES S AGE_BODY <C R LF > where <C R LF> stands fo r car riage-return-li ne-f ee d. Features of HT T P o C on n ecti on less prot ocol: HTTP is a connecti onles s protocol. HTTP client ini ti ates a request and wai ts for a respons e from t he serv er. Wh en the serve r re ceives the requ est, t he serve r proc esses t he request and sends back the response t o the HTTP cli ent afte r which the cli ent di sconne cts t he connecti on. The conne cti on between cli ent and serv er exist on ly during t he current requ est and response ti me only. o Med ia i n d ep en d en t: HTTP protocol i s a media independent as data c an be sent as long as both the cli ent and server kno w how to hand le the data content. It i s r equired for both t he cli en t and server to specify the cont ent t ype in MIME-type he ader. o S tateless: HTTP is a stateless protocol as bot h the cli ent and server kno w ea ch other o nly during the current r equest. Du e to t his nature of the proto col, both t he cli ent and serv er do not retain the information between v ari ous requests of the w eb p ages. HT T P Req u est An d Resp on se Messages The HTTP protocol def ines the format of the req uest and response m essa ges. R equest M essage: The request m essag e is s ent by t he cli ent t hat consist s of a requ est l ine, headers, and som eti mes a body. R esponse Message: Th e response mess age is s e nt by t he server to the cli ent that consi sts of a status l ine, heade rs, and som eti mes a body. HT T P Req u est Message The first l ine in a requ e st m essage is call ed a req uest l ine. After the r equest l ine, we can h ave zero o r mor e request h eade r lines. The body is an opti onal one. It contains t he com ment to be sent or the fil e to be publis hed on the websit e when the method is P UT or POS T. R equ est Li n e There are thr ee fi elds i n this request l ine - Meth od, URL and Version. The Method field de fines the requ est t ypes. The URL field defin es the address an d name of t he corr espondi ng web p a ge. The Version fi eld gi ves the version of the proto c ol; the most current versi on of HTTP is 1.1. S ome of the Method t ypes are: R equ est H eader Each r equest head er lin e sends addit ional inform ati on from t he cli ent t o the serve r. Each he ader line h as a header n ame, a colon, a s pace, and a he ader v alue. The value fi eld defines the values associat ed with each h eade r name. Heade rs defined for r eq uest m essage include: B ody The body can b e pres en t i n a request m essag e. It is opti onal. Usuall y, it contains t he comm ent t o be sent or th e file to be publis hed on t he websit e wh en the method i s P UT or POS T. C on dit ion al R equ est A cli ent can add a cond it ion i n it s request. In thi s c ase, the se rver will send the requested w eb page if the condit ion i s met or inform the cli ent ot herwise. One of the most comm on condit ions i mpos ed by the cli ent i s the ti me and date the web page is m odified. The cli ent can s end the header line If-Modi fi ed-S ince with t he request t o tell t he server that it needs t he page only i f i t i s mod ified after a certa in poi nt i n ti me. HT T P Resp on se Message The first l ine in a requ e st m essage is call ed a stat us l ine. After the r equest l ine, we can h ave zero o r mor e response h eade r lines. The body is an opti onal one. The body is pres ent unl ess t he response is an error message. S tat u s Lin e The S tatus l ine contains t hree fields - HTTP ver sion , S tatus code, S tatus phrase The first field de fines the version of HT TP protocol, curr entl y 1.1. The status code fi eld de fines the status of the r eq uest. It classifies the HT TP result . It consi sts of three digi ts. 1xxIn formational, 2xx S uccess, 3xxR edire cti on, 4xxC li ent error, 5xxS e rver e rror The S tatus phrase field gives brief des criptio n ab out st atus code in t ext for m. S ome of the St atus codes are R espon se Header Each he ader p rovides a ddit ional information t o the cli ent. Each he ader line h as a header n ame, a colon, a s pace, and a he ader v alue. S ome of the response h eaders are: B ody The body contains t he document to be sent from the server to the cli ent. The body is present unl ess t he response is an err or message. HT T P CONNECTI ONS HTTP C li ents and Servers exch ange mul ti ple messages ove r the same T C P connecti on. If som e of the obje cts a re located on th e same se rver, w e have two choice s: t o retrieve e ach object usi ng a new TC P connecti on or to m ake a TCP connecti on and retri eve them all . The first m ethod i s ref e rred to as a no n-pe rsist ent connecti on, the second as a persist ent connecti on. HTTP 1.0 uses non-per sis tent connecti ons and HTTP 1.1 uses persist ent connecti ons . Non-Persi stent C on n ection s In a non-pe rsist ent con necti on, one TCP connec ti on is made for ea ch req uest/ response. Only one object c an be sent over a singl e TCP c onnecti on The cli ent opens a TCP connecti on and sends a r equest. The serve r sends t he re sponse and closes the co nnecti on. The cli ent re ads t he dat a unti l i t encounters an e nd-of-file ma rker. It t hen closes the conn e cti on. Persi stent C on n ecti ons HTTP version 1.1 speci fies a persist ent conn ecti on by default . Mult ipl e objects can be sent over a singl e TCP c onnecti on. In a persist ent conn ecti on, the server l eaves th e connecti on open fo r mor e requests a fter sending a response. The serve r c an close th e conne cti on at t he requ e st of a cli ent or if a ti me-out has been reach ed. Time and resour ces a re saved usi ng persist ent co nnecti ons. Only one set o f buffe rs and variables ne eds t o be set for the conn ecti on at e ac h si te. The round trip t im e for connecti on establis hment and conne cti on termi nati on is saved. Ht tp C ookies AnHTTP cookie( also call edweb cookie, Int ern et cookie,brows erco okie,orsim ply cookie) is a small piece of data sent from a websit e and st ored on the user's comput er by the user's web browser whil e th e user is browsing. HTTP is s tateless , C ookies are used to add S tate . C ookies were d esigned to be a reli able me chanism for w ebsit es to remember st atefu l information (such as it e ms added in t he shoppi ng cart in an onli ne stor e) o r to re cord the user's browsing acti vit y (includi ng cli cking particular bu tt ons, loggi ng in, or recording which page s were visi ted in the past). They can also be used to remember arbitr ary pi eces of inform ati on that the user previous ly entered int o form fields s uch as names, address es, passwords, and c redit c ar d numbers. C ompon en ts of C ookie A cookie consi sts of the f oll owing components: 1. Name 2. Value 3. Zero or mor e att ribute s (name/value p airs). Att r ibut es st ore information such as the cookie's expir ati on, domain, and flags. C reati n g an dS tori n gC ookies The cr eati on and st oring of cookies dep end on the im plementation; however, the principl e is the same. 1. When a se rver re ceive s a request f rom a cli ent, it stores information about t he cli ent i n a file or a string. The inform ati on may include the doma in name of the cli ent, t he contents of the cookie (information t he s erver h as gathe red about the cli ent such as nam e, r egist rati on number, and so on), a ti mestamp, and other infor mation depending on t he im plementation. 2. The serve r includes th e cookie in the r esponse t hat i t sends to t he cli ent. 3. When the cli ent r ec eives the response, th e brow ser stores the cookie in the cookie dire ctory, which is s orted by the ser ver domain name. Usin g C ookies When a cli ent sends a r equest t o a serv er, the br owser looks in t he cookie directory to see i f it can find a cookie s ent by that server. If found, the cookie is i ncluded in the requ est. When the se rver rec eiv es the requ est, i t knows t hat t his i s an old client, not a new one. The contents of the coo kie are n ever read by th e browser or dis closed to t he user. It i s a cookie made by the s erve r and eat en by the serv er. Types of Cooki es 1.A u th en tication cookies These ar e the most com mon m ethod us ed by we b servers to know wh ethe r the user is logged in or not, and which ac co unt t hey are logged in wi th. Wit hout such a mecha nism , the sit e would not know whether to send a page containing sensit ive informati on, or require the us er to authenti cate themselve s by l ogging in. 2.Trackin g cookies These ar e comm only us e d as ways t o compi le indivi duals browsing h ist ories. 3.S essi on cookie A sessi on cookie exist s o nly i n temporary memor y while the user navig ate s the websit e. Web browsers norm all y delete sessi on cookies when th e user closes th e browse r . 4.Persi stent cookie Inste ad of expi ring when the web brows er is close d as session cookies do, a persist ent cookie expires at a sp ecific d ate or after a spe cific length of tim e. This m eans t hat, for the cookie's enti re li fespan , it s infor mation wil l be transmi tt ed to t he server every tim e the user visit s the websit e that it belongs to, or every tim e the us er v iews a resou rce b elongi ng to t hat websit e from another websit e Http Cach in g HTTP C aching enabl e s the cli ent t o retrieve do cument faster and r educe s load on the server. HTTP C aching i s im plemented at P roxyserv er, IS P router and B rowse r. S erver s ets expirati on date (Expires h ead er) fo r each p age, beyond which it is not cached. HTTP C ache do cumen t i s returned to client only i f it i s an updated copy by checking against If- Modi fied-S ince head er. If c ache do cument is o ut-of-date, then requ est i s forwa rded to t he se rver and response is cach ed along t he w ay. A web p age will not be ca ched if no-ca che dire cti ve is s pecified. HTTP S E C URITY HTTP does not provid e security. Howev er HTTP c an be run over the S e cure S oc ket Layer (SS L). In thi s case, H TTP i s refer red to as HT TP S . HTTP S provides confi denti ali ty, client and serv er authentic ati on, and dat a int egrity. 1.8.2 FTP (FIL E T RANSFE R PROT OCOL ) FTP stands for Fil e tra nsfer protocol. FTP is a standa rd inter net protocol provided by TCP /IP used for tr ansmi tt ing t he files from one host to another. It i s mainl y used for tr ansfer ring the web p age f il es from t heir cr eator to the comput er that acts as a se rver for othe r comput ers on the int ernet . It i s also us ed for dow nloading the fil es to comput er from other s erve rs. Although we c an trans fer fil es usi ng HTTP , FT P is a bett er choice to t r a nsfer larg e files or to t ransfer files usi ng diff erent form ats. F TP OB JE C TIV ES It provides the sha ring of files. It i s used to encour age the use of remot e comput ers. It t ransfe rs the data mo re reli ably and ef ficiently. F TP MEC HA NIS M The abov e figure sho w s the basic model of the FTP . The FTP cli ent h as thr ee components: o user interf ace, control process, and d ata trans fer process. The serv er has two co mponents: o server control proc ess a nd server d ata trans fer p r ocess. F TP CONNECTIONS There are two types o f connecti ons i n FTP - C o ntrol C onnecti on and Dat a C onnecti on. The two conn ecti ons i n FTP have dif fer ent l ifeti mes. The control conn ecti o n remains conne cted duri ng the enti re int er acti ve FTP sessi on. The data conne cti on is o pened and then closed f or each file transf er acti vit y. When a user starts an FTP sessi on, the control connecti on open s. Whil e the control c onn ecti on is open, the data c onnecti on can b e opened and closed mul ti ple tim es if several fil es are tr ansfe rred. FTP uses two well-kno wn TC P ports: o P ort 21 is us ed for the control connecti on o P ort 20 is us ed for the data conne ction. C on trol C on n ecti on : o The control conn ecti on uses very simpl e rules fo r comm unicati on. o Through control conne cti on, we can tr ansfe r a li ne of comm and or li ne o f response at a ti me. o The control conn ecti on is m ade between th e con trol processes. o The control conn ecti on remains conne cted durin g the enti re int era cti ve F TP sessi on. Data C onn ecti on : o The Data Conne cti on uses very compl ex rules as data types may va ry. o The data conn ecti on is made betwe en data tr ansf er proc esses. o The data conn ecti on op ens when a comm and co mes for transf erring t he f il es and closes when the fil e is t ransf err e d. F TP COMMUNIC A TION FTP C omm unicati on is achieved through com mands and responses. FTP C omm ands are s e nt from t he cli ent t o the server FTP respons es ar e sent from t he serv er to the cli ent. FTP C omm ands are in the form of ASC II uppe r case, which m ay or may not be followed by an argument. S ome of the most comm on comm ands are: Every FTP comm and ge nerates at l east one r espo nse. A response h as two pa rts: a three-digi t num ber followed by text. The numeric p art de fines the code; t he text p art defines ne eded pa ramete r . F TP FILE TYPE FTP can tr ansf er one o f the following file types across the dat a conne cti on: ASC II file, EBC DIC file, o r image file F TP DA TA S TRUC TUR E FTP can tr ansf er a file across the dat a conne cti on usi ng one of the follow ing data structure : file structure, r eco rd stru cture, or p age structur e. The file structu re fo rmat i s the default one and has no st ructure. It i s a c onti nuous st ream of bytes. In the re cord stru cture, the fil e is di vided into records. This can b e used o nly with text fil es. In the pag e structure, t he file is di vided into pages, with each p age havin g a page numbe r and a pag e head er. Th e p ages can b e stored and ac cessed r andoml y or sequ enti all y. F TP TR A NSMI SS ION MODE FTP can tr ansf er a file across the dat a conne cti on usi ng one of the follow ing three transmi ssi on modes: st ream m ode, block mode, or compressed mode. The stre am m ode is t he default mode; dat a ar e deli vered f rom FTP to T C P as a conti nuous stream of bytes. In the block mode, d ata can b e deli ver ed from FTP to TC P in bl ocks. In the compr essed mo de, data c an be compress ed and deli ver ed from FT P to TCP . F TP FILE TRA NSF E R Fil e trans fer o ccurs ov er the data conne cti on under the control of th e co mm ands sent over the control conne cti on. Fil e trans fer in FTP means one of th ree thi ngs: o retrieving a fil e (serv er to client) o st oring a file (cli ent t o server ) o directory li sti ng (serve r to client). F TP SE C URITY FTP requir es a p asswo rd, the password is s ent i n plaintext which is unencrypted. This means i t can be int e rcept ed and used by an att ack er. The data tr ansfe r conn ecti on also t ransf ers data in pl aint ext, which is i nsecure. To be secu re, on e can add a S ecur e S ocket L ay er betwe en the FTP appli cati on layer and the TCP layer. In thi s case FTP is call ed S S L-FTP . 1.8.3 E MAIL (SMTP, MIME , IMAP, POP) One of the most popul ar Intern et servic es is ele ctronic mail (E-mail). Email is on e of the old est network appli c ati ons. The thre e main compo nents of an Email ar e 1. User Agent (UA) 2. Messsage Tr ansfe r Ag ent (MTA) S MTP 3. Messsage Ac cess Ag e nt (MAA) - IM AP , P OP When the s ender and the rec eiver o f an e-mail a re on the same system, w e need only t wo User Agents and no Mes sage Trans fer Agent When the s ender and the rec eiver o f an e-mail a re on diffe rent sys tem, w e need two U A, two pairs of MTA ( cli ent and serve r), and two M AA (cli ent and s erve r). WORK ING OF E MA IL When Alic e needs t o s end a messag e to B ob, she runs a UA p rogram t o p repar e the message and s end it to her mail s erver. The mail s erv er at he r sit e uses a queue (spool) to st ore messages w ait ing t o be sent. The message, howev er, n eeds to be sent t hrough Her e two message t ran sfer ag ents are n eed ed: one cli ent and one s erve r. The serv er ne eds t o ru n all the tim e because it d oes not know when a cli e nt wil l ask for a connecti on. The cli ent c an be trigg ered by the system wh en there is a messag e in t he queue to be sent. The user agent at the B ob si te all ows Bob t o rea d the rec eived messag e. B ob later uses an MA A cli ent t o retriev e the message f rom an MAA se r ver running on t he second serv er. US E R A GENT (UA) The first component o f an electroni c mail s ystem i s the user agent (U A). It provides servi ce to t he user to make th e proc ess of sending and r ec eivi ng a message easier. A user agent i s a softw are pa ckag e that compos es, reads, repli es to, and f orwards mess ages. It also h andles local m ail boxes on t he user comput ers. There ar e two types of user agents: C omm and-d riven and GU I- bas ed. Com m an d d riven o C omm and driven user agents belong t o the ea rl y days of ele ctronic mail. o A comm and-driven us e r agent normall y a ccepts a one ch ara cter comm and from the keyboard to pe rform it s task. o S ome exampl es of com mand driven user agents are mail, pi ne, and elm . GUI-b ased o Modern user agents ar e GU I-bas ed. o They all ow the user to i nteract wit h the softw are by usi ng both t he keyboard and the mouse. o They have g raphic al co mponents such as icons, menu bars, and windows that make the services e asy t o ac cess. o S ome exampl es of GU I-based use r agents are Eu dora and Outlook. ME S S A GE TRA NSFE R AGENT (MTA ) The a ctual mail t ransfe r is done through messag e transfe r ag ents (MTA). To send mail, a system must have the cli ent MT A, and to rec eive mail , a syst em m ust have a serve r MTA. The form al protocol that defines the MTA cli en t and server in the Intern et i s call ed S im ple Mail Transfe r Protocol ( S MTP ). ME S S A GE A C CE S S AGENT (MA A ) MAA is a softwa re tha t pul ls m essages out of a mailbox. P OP3 and IM AP4 are exampl es of MAA. A DDR E S S F OR MA T OF E MA IL E-mail addr ess i s userid @ dom ain where dom a in is hos tname of the mail server. ME S S A GE F ORMA T OF E MA IL Email message consi st s of two parts namely he ader and body . Each h eade r line conta ins t ype and value sep ara ted by a colon (:). S ome heade r contents are: o From: i denti fier send er of the message. o To: m ail address of the recipi ent(s). o S ubject: says about purpose of the messag e. o Date: ti mestamp of wh en the message was trans mi tt ed. Head er is sepa rated fro m t he body by a blank line. B ody contains t he actu al m essage. Email was extend ed in 1993 t o carry many dif fe rent t ypes of data: audio, vi deo, im ages, Word documents, and so on. This extended ve rsion is known as MIME (Multi purpose Mail Extension ) . 1.8.4.1 S IMPLE MAIL T RANSFE R PROT OCOL (SMTP) S MTP is t he standard protocol for trans fer ring mail between host s in t he TCP /IP protocol suit e. S MTP is no t concerne d with t he format or cont ent of messages themselv es. S MTP uses information writ ten on the envelope of the mail (message h ea der), but does not look at the contents (mes sage body) of th e envelo pe. S MTP cli ents and serv ers have two m ain comp onents o User Agents( UA) P r e pares the mess age, en clo ses it in an envelope. o Mail Transfe r Agent ( MTA) Trans fers the m ail across the intern et SM TP also allowst heuse of Relays allowing other M TAst or elayt hemail. S MTP MA IL F LOW To begin, m ail is cre ated by a user-agent p rogra m i n response to user inp ut. Each cre ated messag e consi sts of a head er that i ncludes the re cipi ent's e mail address and other information, and a message body containing the message to be sent. These messag es ar e th en queued in s ome f ashion and provided as inpu t t o an S MTP S ender program. S MTP COMMA NDS AND R E S PONSE S The oper ati on of S MTP consi sts of a series of c omm ands and responses exchang ed betwe en the SM TP sender and S MTP receive r. The ini ti ati ve is wit h the SMTP sender, who es tablis hes the TCP connec ti on. Once the conne ction is establis hed, the SMTP sender sends comm ands o ver the conn ecti on to t he receiv er. The comm and is from an MTA cli ent t o an MT A serve r; the response is from an MTA server to the MT A cli ent. S MTP Com man ds C omm ands are sent f r om t he cli ent t o the serve r. It consist s of a keywo r d followed by ze ro or more argum ents. S MTP defines 14 comm ands. S MTP Respon ses R esponses ar e sent fro m t he server to the cli ent. A response is a three d igi t code that may be foll owed by addit ional textu al i nformation. S MTP OPER A TIONS B asic SM TP operati on occurs in thre e phases: 1. C onnecti on S etup 2. Mail Transfe r 3. C onnecti on Terminati on Conn ection S etup An SM TP sender will att empt to set up a TCP connecti on with a target h ost when it has one or mor e mail m essages to d eli ver to t hat host . The sequen ce is qu it e sim ple: 1. The sender opens a TC P connecti on with t he rec eiver. 2. Once the connecti on is establis hed, the re ceive r identifies it self wit h 3. The sender id enti fies it self wit h the HELO com mand. 4. The re ceiver ac cepts t he sender's id enti ficati on with " OK". 5. If the mail servic e on t he desti nati on is unavail a ble, the desti nati on host returns a "S ervice Not Avail able" reply i n s tep 2, and the proc ess i s termi nated. Mail Tran sfer Once a conne cti on has been establis hed, the S MTP sender may send on e or more mess ages to t he S MTP receiver. There ar e three logi c al phases to t he transf er of a message: 1. A MA IL comm and ide nti fies the origi nator of t he message. 2. One or more R C P T co mmands i denti fy the reci pients for thi s message. 3. A DATA comm and tr ansfers the m essage text. C on n ecti on Termi n ati on The S MTP sender clos es the conne cti on in t wo steps. First, t he send er sends a QU IT comm and and w ait s for a r eply. The second st ep is t o ini ti ate a TCP close opera ti on for the TCP connecti on. The re ceive r initi ates its TCP close after sending it s reply t o the QU IT co mm and. Limi tat ion s Of S mt p S MTP cannot t ransmi t executabl e files or othe r binary objects. S MTP cannot t ransmi t t ext data that includes na ti onal l anguage ch ara cter s, as these ar e repres ented by 8-bit cod e s with values of 128 deci mal or higher, and S MTP is l im it ed to 7-bit ASC II. S MTP servers may r eject m ail message ov er a certain si z e. S MTP gateways t hat t r anslate betwe en ASC II a nd the char acte r code EB C DIC do not us e a consi stent set of mappings, result ing i n translation problems. S ome SM TP im plementations do not adhere co mpl etely to t he S MTP standards defined. C omm on problems i nclude the following: 1. Deletion, additi on, or r ecording of car riage r etur n and li nefeed. 2. Truncati ng or w rappin g li nes long er than 76 ch aract ers. 3. R emoval of trail ing whit e space (t ab and spa ce characters ). 4. P adding of li nes in a message to t he same leng th. 5. C onversion of tab cha r acters int o mul ti ple- spac e char acte rs. 1.8.4.2 MULT IPURPOS E INTE RNE T MAILE XTE NSIO N (MIME ) S MTP provides a basic email servic e, while M IME adds m ult im edia cap abil it y to S MTP . M IME is an extension to S MTP and is used to overcome the p roblems an d li mi tations of SMTP . Email syst em was desi gned to s end messages o nly i n ASC II form at. Languages su ch as F re nch, C hinese, etc., are no t supp orted. Imag e, audio and vid eo files cannot be sent. M IME adds t he follow ing features to em ail serv ice: B e able to send mul ti ple att achments wit h a sing le message; Unlim it ed message len gth; Use of ch ara cter sets ot her than ASC II cod e; Use of rich te xt (layout s, fonts, colors, etc) B inary att achments ( ex ecutables, im ages, audio or video files, etc. ), whic h may be divi ded if need ed . M IME is a protocol t h at converts non-ASC II d ata to 7-bit NVT(N etwork Virtual Terminal) AS C II and vice-v ersa. MIME HE A DER S Using heade rs, M IME describes the type o f mes sage content and th e enc oding used. Head ers de fined in M IME are: MIME-Version- curr en t version, i.e., 1.1 C ontent-Type - messag e type (text/ht ml , im age/j peg, appli cati on/pdf) C ontent-Transfe r-Enco ding - message en coding s cheme ( eg base64 ). C ontent-Id - unique ide nti fier for the mess age. C ontent-Descriptio n - d escribes type o f the mess age body. MIME CONT E NT T YPE S There ar e seven dif fer e nt m ajor types of content and a tot al of 14 subtype s. In gene ral, a content type decla res the g ener al t ype of data, and the subty pe specifies a particular fo rmat for th at t ype of data. M IME also defin es a mul ti part type that says how a message car rying more than one d ata type is st ructured. This i s li ke a program mi ng language that defin es bot h base types ( e.g., int egers and flo ats) and compound t ypes (e.g ., st ructures and arr ays). One possi ble mult ipart subt ype is m ixed, which says t hat t he message co ntains a set of independent data pi eces i n a specified o rder. Each pie ce then h as it s own heade r line that des cribes the type of th at pi e ce. The table b elow li sts the M IME content types: E NCODING F ORMA TS OF MI ME M IME uses various en coding formats t o conve r t bi nary data into t he ASC II char acte r set. To transfe r binary d ata , MIME o ffe rs five en co ding formats which can b e used in t he header t ransf er-encoding : 7-bit : 7-bit text format (for messag es without ac cented ch ara cters ); 8-bit : 8-bit text format; quoted-printable : Quot ed-P rintable form at, reco mm ended for messag es which use a 7-bit alphabet (such as when t here a re acc ent m arks); base-64 : B ase 64, for s ending bi nary fil es as att achments; binary : bi nary form at; not recomm ended. S ince M IME is very o pen, it can use thi rd-p art y encoding formats such as: B inHex : A proprietary format belongi ng to App le Uuencode : f or UN IX-to-UN IX encoding Xencode : fo r binary-to-text encoding ME S S A GE TRA NSFE R IN MIME MTA is a mail daemo n (send mail) acti ve on h osts having m ail box, used to s end an email. Mail passes through a sequence o f gate ways be fore it re aches th e re cipi e nt m ail server. Each g ateway st or es a nd forwa rds the mail us ing S im ple mail transfer pr otocol (S MTP ). S MTP defines comm unicati on between MT As over TC P on port 25. In an S MTP session, sending M TA is client an d receiv er is serv er. In ea ch exch ange: C li ent pos ts a comm and (HELO, MA IL, RC P T, DATA, QU IT, VRFY, e tc.) S erver responds wit h a code (250, 550, 354, 221 , 251 etc) and an explan a ti on. C li ent i s identi fied using HELO command and verified by the se rver C li ent forwards mess a ge to server, i f serv er is will ing t o accept. Message is t erminat ed by a li ne with onl y si ngle period (.) in it . Eventually client termi nates the conne cti on. 1.8.4.3 IMAP (INT E RN E T MAIL ACCES S PROT OCOL ) IMAP i s an Applicati o n Layer Int ernet proto col t hat allows an e-mail cli ent t o acc ess e- mail on a remot e mail s erv er. It i s a method of a cces sing electronic mail m ess ages that ar e kept on a po ssi bly shared mail server. IMAP i s a more c apab le wire protocol. IMAP i s si mi lar to S MTP in m any ways. IMAP i s a cli ent/ serve r protocol running over T C P on port 143. IMAP all ows mul ti ple cli ents s im ult aneousl y connected to the same m ail box, and through flags st ored on the se rver , different cli ents acc essi ng the same mailbox at the same or dif fer ent ti mes can detect st ate cha nges made by other cli en ts. In other wo rds, it perm it s a "client" email program t o acc ess remot e mes sage stores as if they were lo cal. For exampl e, em ail stored on an IM AP server c an be manipulated f rom a desktop comput er at hom e, a workstation at the office, and a noteboo k computer whil e trav ell ing, wit hout t he need to t ransf er messag e s or fil es back and forth b etween thes e comput ers. IMAP can support email serving i n three mode s: Offline Online Users may conn ect t o the server, look at what ema il is avail able, and ac cess it onli ne. This Disconnect ed oper ati on disconnects from t he se r ver. The use r can then w ork on the messages o ffli ne, and conn ect t o the server l ater and resyn chronize the s erve r status with t he cach e. OPE R A TION OF IM A P The mail t ransf er begi ns wit h the cli ent authenti cati ng the user and id enti fying the mail box they want t o ac cess. C li ent C omm ands LOG IN, A UTHENT IC A TE, SELECT, EXAM IN E, CLOSE, and LOGOU T S erver Respons es OK, NO (no p ermiss ion), BAD (incorr ect comman d), When use r wishes to F ETCH a message, s erve r responds i n M IME forma t. Message att ributes suc h as si ze ar e also ex chan ged. Flags a re used by cli en t t o report user a cti ons. S EEN, ANS WERED, D ELETED, R ECENT IMA P4 The latest ve rsion is IMAP 4. IMAP4 i s more p owerful and mo re compl ex. IMAP4 provides thefo ll owing extra functi ons: A user c an che ck the e-mail header p rior to dow nloading. A user c an sea rch the c ontents of the e-mail for a specific string of cha ra cters prior to downloading. A user c an partiall y do wnload e-mail. Thi s is es pecially us eful if band width is l im ited and the e-mail contains m ultim edia wit h high bandwidt h requirements. A user c an cr eate, d elet e, or ren ame mail boxes o n the mail server. A user c an cr eate a hier archy of m ail boxes in a f older for e-mail st orage Advan tages Of IMAP Wit h IMAP, t he prima ry storage is on the se rve r, not on the local m achin e. Email being put away for storage can b e folder e d on local di sk, or can b e foldered on the IMAP s e rver. The protocol allows fu ll user of remot e fold ers, including a remot e folder hierar chy and mul ti ple inboxes. It keeps t r ack of expli c it status of messages, and all ows for user-defin ed st atus. S upports new mail not ificati on expli cit ly. Extensibl e for non-em ail data, like netnews, do cument st orage, etc. S electi ve f etching of i ndivi dual MIME body pa rts. S erver-based s ear ch to m ini mi ze data transfe r. S ervers may h ave exte nsion s that can be negoti ated. 1.8.4.4 POS T OFFICEPROT OCOL (POP3) P ost Office P rotocol ( P OP3) is an appli cati on-layer Int ernet st and ard pr otocol used by local e-mail clients t o retriev e e-mail from a remot e se r ver over a TCP /IP conn e cti on. There ar e two versions of POP . he mi d-80's and requires S MTP to send messages. uses TC P /IP port 110. P OP i s a much simpl er protocol, making im plementation easier. P OP su pports offline a ccess t o the messag es, thu s requires less i ntern et usage time P OP does not allow search f acil it y. In orde r to ac cess t he messages, it is necessa ry to download them. It allows onl y one mailbox t o be cre ated on serv er. It i s not sui table for ac cessi ng non mail data. P OP m ail moves the message f rom the email ser ver onto thelocal comput er, alt hough ther e is us uall y an opti on to l eave the messag es on t he email server as well . P OP t reats t he mailbox as one store, and has no concept of folders. P OP works i n two modes namely, delete and k eep mode. In d elete mode, mail is deleted from t he m ail box after r etriev al. The delet e mode is normall y used when the use r is wo rking at t heir perman ent comput er and c an sav e a nd organize the receiv ed mail afte r re ading or replyi ng. In k eep mode, mail a fte r reading i s kept i n mailb ox for later retriev al. The keep mode is normall y used when the user ac cesses h er mail a way from their p rimary c omput er . P OP3 client is inst all ed on the recipi ent comput er and P OP serv er on the mail server. C li ent opens a conne cti on to t he server using T C P on port 110. C li ent sends username and password to a cc ess m ail box and to retrieve messages. POP3 Com m an d s P OP commands are gen e rall y abbrevi ated into co des of three o r four l ett er s The following describ es som e of the P OP commands: 1. U ID - This command opens t he conne cti on 2. S TAT - It i s used to dis play number of messag e s currentl y in t he mailbo x 3. LIS T - It is us ed to get the summary of message s 4. R ETR -This command helps t o select a mailbox to access t he m essages 5. DELE - It i s used to de lete a messag e 6. R S ET - It i s used to re set t he sessi on to i ts i nit ial st ate 7. QU IT - It i s used to lo g off the sessi on Advan tages of IMAP o ver POP IMAP i s more power f ul and more compl ex tha n P OP. User can ch eck the e-mail header p rior to dow nloading. User can se arch e-mail for a spe cific string of c haract ers prior to downlo ading. User can download p ar ti all y, very useful in cas e of lim it ed bandwidth. User can c reat e, delete , or renam e mailboxes on the mail server. 1.9 DNS (DOMAIN N A ME S YST E M) Domain Name Sys tem was designed in 1984. DNS is us ed for nam e-to-address m apping. The DNS provides the protocol which all ows cli ents and serve rs to comm unicate wit h ea ch other. Eg: Host name li ke w ww.yahoo.com i s translat ed int o numerical IP addr esses li ke 207.174.77.131 Domain Name Sys tem (DNS) is a dist ributed d atabase us ed by TCP /IP a ppli cati ons t o map between host names and IP addresses and to provid e electroni c mail routi ng information. Each si te maint ains i ts own database of informat ion and runs a serv er pro gram that other syst ems across the Inte rn et can que ry. WORKI NG OF DNS The following si x st eps shows t he working of a D NS. It maps the host nam e to an IP address: 1. The user pass es the ho st name to t he file transf e r cli ent. 2. The file transf er cli ent passes the host name to t he DNS cli ent. 3. Each comput e r, afte r b eing boot ed, knows the address of one D NS serve r. The DNS cli ent sends a message to a DN S server wit h a qu ery tha t gi ves the fil e transfe r se rver nam e usi ng the known IP address o f the DNS serve r. 4. The DNS serv er r esponds wit h the IP add ress o f the desired file transf er server. 5. The DNS serv er passe s the IP add ress to t he fil e transfe r cli ent. 6. The file transf er cli ent now uses the re ceived IP address t o ac cess t he file transfer s erve r. NAME S PACE To be unambi guous, t he names assi gned to m a c hines must be care fully selected f rom a name spac e with complet e control over th e bindi ng between the n ames and IP add ress. The names must be un ique becaus e the add ress es are uniqu e. A name spa ce that ma ps each add ress t o a uniq ue name c an be org anize d in t wo ways: flat (or) hier archi cal. Flat Nam e S p ace In a flat nam e spac e, a name is assi gned to an ad dress. A name in thi s space is a sequenc e of char acte rs wit hout s tructure. The main dis advantag e of a flat nam e spac e is t hat i t cannot be used in a l arge syst em such as Internet b ecaus e it must be centrall y controll ed to avoid ambi guit y and dupli cati on. Hierar chical Name Space In a hier archic al name space, e ach n ame is m ad e of seve ral pa rts. The first part c an de fine the organiz ati on, the se cond part c an defin e the name, the third part can defin e depa rtments, a nd so on. In thi s c ase, the autho rity t o assi gn and control t he name spa ces c an be d ecentr ali zed. A central authorit y can assi gn the part of the n a me that defines the n atur e of the org anizati on and the name. The responsi bil it y for the rest of the n ame c an b e given to the organiz ati on it self. S uffixes can be added to t he nam e to define host or resou rc es. The managem ent of the organizati on ne ed not w orry that the pre fix chose n for a host is taken by another o rganiz ati on because even if p art of an addr ess i s the same , the whole address i s di ffe rent. The names a re unique without the need to be as signed by a centr al autho rity. The centr al authorit y c ontrols onl y part of the n ame, not the whole nam e . DOMA IN NA ME S PACE To have a hiera rchic al name spac e, a domain na me space w as designed. I n thi s design, the names ar e defined in an inverted-tr ee structu re wit h the root at the top. Each nod e in t he tree h as a label, which is a string wit h a maximum of 63 chara cters. The root label i s a null string. DNS requir es that chil dren of a nod e hav e diffe rent l abels, whi ch gu aran tees the uniqueness of the domain names. Each nod e in t he tree h as a label, which is a string wit h a maximum of 63 chara cters. The root label i s a null string (empt y st ring). DNS requires that chil dr en of a node (nod es that branch f rom the sam e node) hav e diff erent l a bels, whi ch guar antees th e uniqueness of the domain names. Domain Name Each node in t he tr ee h as a label c all ed as dom ai n name. A full domain name is a sequenc e of lab els s epa rated by dots (.) The domain names a re always re ad from t he nod e up to t he root. The last label i s the lab el of the root (null ). This m eans t hat a full d omain name always ends in a null l abel, which me ans t he last chara cter is a dot b ecaus e the null st ring is not hing. If a lab el i s termi nated by a null string, i t i s call ed a fully quali fied domai n name ( FQDN). If a lab el i s not termi nated by a null string, i t i s call ed a partiall y quali fied domain name (PQDN). Domain A domain i s a subt ree o f the domain name spa ce. The name of th e domai n is t he domain name of t he node at t he top of the sub- tree. A domain m ay it self be divi ded int o domains. DISTR IB UTION OF NAME S PAC E The information cont ained in the domain name space must be stored. B ut i t i s very inefficient and also no t reli able to have just one comput er s tore such a hug e amount of informati on. It i s inefficient be caus e respondi ng to requ ests from all over the wo rld, places a h eavy load on the system. It i s not reli able bec au se any fail ur e makes the data inac cessi ble. The sol uti on to t hese problems i s to d ist ribute the information among ma ny comput ers call ed DNS serv ers. HIE R A RC HY OF NA ME S E RV E RS The way to di stribut e i nformation among DNS servers is t o divi de the w hole space int o many domains based on t he first l evel. Let t he root stand-alone and cr eate as many do mains as there a re fi rst level nodes. B ecause a domain c rea ted this way could be ve r y large, DNS all ows domains t o be divi ded further int o smaller domains. Thus we hav e a hie rar chy of serv ers in the sam e way that w e have a hier archy of n ames. ZONE What a s erve r is respo nsibl e for, or has authorit y over, is call ed a zone. The serv er mak es a dat abase c all ed a zone file a nd keeps all the informati on for eve ry node under that dom ain. If a s erve r ac cepts r esponsi bil it y for a domain and does not divi de the domains i nto sm all er domains, t he domain and zone re fer to the s ame thing. B ut i f a serve r divides its domain int o sub dom ains and delegates p arts of it s authorit y to other serve rs, domain an d zone re fer to dif fer ent t hings . The information about the nodes in t he sub dom ains i s st ored in t he serve rs at t he lower levels, with t he original server k eeping s ome sort of ref eren ces to t hese lo wer level s erve rs. B ut st il l, t he original server do es not fre e it self from responsi bil it y tot ally. It st il l has a zone, but t he detailed inform ati on is kept by t he lower lev el servers. R OOT S E R V ER A root seve r is a serv er whose zone consi sts of the whole tre e. A root serv er usuall y d oes not store any informa ti on about dom ains bu t delegates its authorit y to ot her serve rs , keeping re fer ences to t h ose serve rs. C urrentl y there ar e more than 13 root se rvers, e ach cov ering the whole d omain name spac e. The serv ers a re dist rib uted all around the wo rld. PRIM A R Y AND SEC ONDAR Y S E R VE R S DNS defines two t ypes of serve rs: prim ary and s econdary. A Prim ary Serve r is a server that st or es a file a bout t he zone for which i t i s an authorit y. P rimary Servers are res ponsi ble for cr eati ng, ma int aini ng, and updati ng the zone file. P rimary Server stor es the zone file on a local di s c. A second ary se rver is a serve r that t ransf ers the compl ete informati on ab out a zone f rom another serv er (P rima ry or Secondary ) and st or es the fil e on it s local disc. If updati ng is requir ed, it must be done by the prim ary serve r, which send s the updated version to t he se condary. A prim ary se rver lo ads all information from t he disk fil e; t he secondary s erver loads all information fro m t he primary serv er. DNS IN THE I NTE R NET DNS is a protocol that can be used in di f fer ent p latforms. In the Inte rnet, the do main name spac e (tre e) is divi ded int o three diffe re nt secti ons - Gen eric domai ns, C ountry domains, and Inv erse dom ain. Gen eric Domai n s The gen eric domains d efine r egist ered host s a cc ording to t heir generic b e havior. Each nod e in t he tree d efines a domain, whi ch is an index to t he domain n ame spac e database. The first l evel i n the g eneric domains se cti on al lows seven possi ble three chara cter l evels. These lev els describ e the organiz ati on types as li sted in following t able. C ou n try Domain s The country domains s ecti on foll ows the same f ormat as the gen eric dom ains bu t uses two chara cters for country ab breviations E.g.; i n for India, us fo r Unit ed S tates etc) in pl a ce of the thr ee char acter organizati onal abbreviation at the first level. S econd level l ab els ca n be organiz ati onal, or th ey can b e more spe cific, nati onal designati on. India for exampl e, use s st ate abbreviations as a subdi visi on of the country domain us. (e.g., ca.in.) In verse Domai n s Mapping an add ress t o a name is call ed Invers e domain. The cli ent can send an IP add ress t o a se rver to be mapped to a domain n ame and it is call ed P TR(P oint er) query. To answe r queries o f t his ki nd, DNS uses the inverse domain. DNS R E S OLUTION Mapping a name to an address or an addr ess t o a name is call ed n ame ad dress resolut ion. DNS is designed as a c li ent server appli c ati on. A host t hat needs t o map an addr ess t o a name or a name to an addr ess c all s a DNS cli ent named a R esolver. The R esolver acc esses the closest DNS s erve r w it h a mapping request. If the se rver h as the inf ormati on, it sati sfies the resolver; ot herwise, it eit h er re fers the resolver to ot her s erve rs or asks ot her se rvers to p rovide the information. After the resolve r re cei ves the mapping, i t i nterprets t he respons e to see if it is a real resolut ion or an er ror and finall y deli vers the r esult to t he process t hat r eque sted it . A resolut ion can b e eit her re cursive or ite rati ve. Recu rsive R esolu tion The appli cati on progr a m on t he source host call s the DNS resolver (cli en t) to find the IP address of the d esti nati on host . The resolver, whic h does not know thi s address, sends the query to the local DNS s erver o f the sourc e (Ev en t 1) The local serv er sends t he query to a root DNS server (Event 2) The R oot server s ends t he query to the top-lev el-DNS server (Event 3) The top-level DNS s e r ver knows only t he IP ad dress of the loc al DNS s e rver at the desti nati on. S o it forward s the query to the local se rver, which kno ws the IP address of the desti nati on host (Event 4) The IP address o f the d esti nati on host is no w sent back to t he top-level D NS server( Event 5) then back to t he root se rv er (Event 6 ), then ba ck to t he source D NS serve r, which may ca che it for the futur e queries (Ev ent 7), and finall y ba ck t o the source host (Ev ent 8) Iterative Resolu tion In it e rati ve r esolut ion, each se rver th at does not know the mapping, sends the IP ad dress of the next serve r back to t h e one that requ ested it . The it erati ve r esolut ion t akes pl ace b etwe en two local serve rs. The original resolve r g ets t he final answe r from the desti nati on local serv er. The messages shown b y Events 2, 4, and 6 cont ain t he same que ry. Howeve r, the messag e shown by Event 3 contai ns the IP add ress of the t op- level dom ain server. The message shown by Event 5 contains t he IP a ddress of the desti nati on local DNS s erve r The message shown by Event 7 contains t he IP a ddress of the desti nati on. When the Sourc e local DNS server rec eives the IP add ress of the d esti nati on, it sends i t t o the resolver (Event 8). DNS CACHING Each ti me a s erve r re c eives a que ry for a name that is not i n it s dom ain, it needs to sear ch it s database for a serv er IP address. DNS handles thi s with a mechanism c all ed ca ch ing. When a s erve r asks fo r a mapping from anothe r server and re ceives the re sponse, it st ores thi s information i n it s cache memory befo re sendin g it to t he cli ent. If the sam e or anothe r cli ent asks for the sam e mapping, it can che ck it s cach e memory and resolve th e problem. Howev er, to inform t h e cli ent t hat t he respons e is comi ng from t he cach e memory and not from an authorit ati ve sou rce, the s erve r marks the response as un authorit ati ve. C aching speeds up res olut ion. R educti on of thi s search ti me would i nc re ase ef ficiency, but it can also be problem ati c. If a s erve r ca ches a m a pping for a long t im e, it may send an outdated ma pping to t he cli ent. To counter thi s, two t e chniques ar e used. First, t he autho ritati ve server always adds i nfo r mation t o the mapping call ed ti me to li ve (TTL). It de fines the ti me in seconds t hat t he r ece ivi ng server c an ca che th e information. Afte r that ti me, the mapping is i nvali d and any query mu st be sent again t o the aut horitati ve serve r. S econd, DNS r equires t hat each s erve r keep a T TL counter fo r ea ch map ping i t caches. The cach e memory mus t be s earch ed pe riodicall y and those mappings with an e xpired TTL must be purged. DNS RES OURCE RECORDS (RR) The zone info rmati on a ssociated wit h a serv er is im plemented as a set of resourc e re cords. In othe r words, a name server stor es a dat abase o f resour ce r ecords. A resour ce r ecord is a 5-tupl e structure : (Dom ain Name, Type, C lass, TT L, Value) The domain name ident ifies the resour ce r ecord. The type defin es how the value should be int erp reted. The value de fines the i nformation kept about t h e domain name. The TTL defin es the nu mber of secon ds for whic h the informati on is vali d. The class de fines the ty pe of network. T yp es of Resou rce R eco rd s DNS ME S S AGE S DNS has two t ypes of messages: query and resp onse. B oth t ypes have the sa me format. The query m essage co nsis ts of a heade r and qu esti on secti on. The respons e messag e consi sts of a head er, ques ti on secti on, answer se cti on, authorit ati ve secti on, and addit ional secti on . Header B oth query and respons e messages ha ve the sam e head er form at wit h some fields set to zero fo r the query mess ages. The head er fields are as follows: The identificati on field is us ed by the cli ent t o match the respons e with t he query. The flag field d efines whether the mess age is a query or r esponse. It also includes st atus of error. The next four fields i n the head er de fine the num ber of e ach r eco rd type i n the message. Questi on S ecti on The questi on secti on co nsis ts of one or more que sti on records. It i s pres en t i n both query and response messag es. A n sw er S ecti on The answe r secti on con sis ts of one or more r esource r ecords. It i s p resent only i n response messages. A uth orit ati ve S ecti on The authorit ati ve se cti on gives information (domain name) about on e or more authorit ati ve servers for the que ry. A ddition al In formati on S ecti on The addit ional informat ion secti on provides addi ti onal i nformation t hat may help t he resolver. DNS CONNE CTIO NS DNS can use eit her U DP or TCP . In both cases th e well-known port used by the s erver is port 53. UDP is us ed when the size of the r esponse mess age is l ess t han 512 bytes because most UDP packag es have a 51 2-byte pack et si ze li mi t. If the siz e of the r espo nse message is m ore than 512 bytes, a TCP connec ti on is used. DNS REG IS T RARS New domains a re a dde d to DNS t hrough a regis trar. A f ee is ch arged. A regist ra r first veri fie s that t he requested doma in name is un ique and then enters it int o the DNS database. Today, ther e ar e many regist rars; their n ames an d addresses can be found at htt p:/ /www.int enic.net To regist er, the o rgani zati on needs t o give the n ame of it s serve r and the IP add ress of the server. For exampl e, a n ew co mm ercial organiz ation na med wonderful wit h a s er ver named ws and IP add ress 200.200.200.5 , needs t o give the follow ing i nformation t o one of the regist rars: Domain name: ws.wonde rful.com IP addr ess: 200.200.200.5. DDNS (DYNA MIC DO MAIN NA ME S YST EM) In DNS , when the re is a chang e, such as adding a new host, removi ng a h ost, o r changing an IP address, t he chang e must be made to t he DN S master fil e. The DNS master file must be updated dynami call y. The Dynami c Domain Name Sys tem (DDNS) is used for thi s purpose. In DDNS, wh en a bind ing between a n ame and an address i s det ermined, the informati on is sent t o a primary DNS se rver. The primary s erve r up dates the zone. The second ary se rvers are noti fied eit her a cti vely or passi vely. In acti ve noti fic ati on, the prim ary se rver s ends a message to t he second ar y servers about t he change in t he zone, wh er eas in p assi ve noti ficati o n, the seconda ry serv ers periodicall y che ck for any ch anges. In eit her case, afte r bei ng noti fied about t he cha nge, the second ary se rver requests information about the ent ire zone (call ed the zone transfer ). To provide se curity an d prevent unauthori zed c hanges in t he DNS re cor ds, DDNS can use an authenticati on mech an ism . DNS S E CURITY DNS is on e of the mos t i mportant sys tems i n the Intern et i nfrastru cture; it provides crucial services to Inte rnet users. Applicati ons such as Web a ccess or e-mail a re heavil y depend ent on t he proper op erati on of DNS . DNS can b e att ack ed in s everal w ays i ncludi ng: Attack on C onfidenti ali ty - The att ack er may r ea d the response of a DNS server to find t he n ature or names of sit es the use r most ly accesses. This ty pe pro file. To prev ent t his att ack, DNS messages ne ed to be confidenti al. Attack on authentic ati on and int egrity - The att a cker may int e rcept t he response of a DNS serv er and chang e it or cr eate a tot all y new bogus respo nse to di rect t he user to the si te or domain the att ack er wishes the user to a ccess. This t ype of att ack c an b e prevent ed usi ng messa ge origin authenticati on a nd message int egrity. Attack on denial-of-ser vice - The att acke r may f lood t he DNS server to overwhelm it or ev entual ly crash i t. This t ype of a tt ack can b e prev ented us ing the provisi on against den ial-of-servi ce att a ck. To protect DNS, IETF has devised a te chnology named DNS S ecurity (D NSS EC) that provides message o rigin authenticati on and messa ge int egrity using a secur it y service c all ed digi tal si gnature. DNS S EC, however, d oes not provide confident ialit y for the DNS m essa ges. There is no spe cific pr otecti on against the denia l-of-servic e att a ck in t he specificati on of DNS S EC. However, the caching s ystem prote cts t he upper- l evel serv ers a gainst thi s att ack to some extent. 1.10 S NMP (S IMPLE NET WORK MANAGE ME NT PROT OCOL ) The S im ple Network Management P rotocol (S NMP) is a frame work for managing devices in an internet usi ng the T C P /IP protocol sui te. S NMP i s an applicati on layer protocol that mon it ors and manages rout er s, dist ributed over a network. It provides a set o f ope rati ons for moni toring an d managing t he int ernet. S NMP us es services of UDP on two well-know n ports: 161 (Agent) and 162 (manage r). S NMP us es the concep t of manager and ag ent. S NMP MANAGE R A manager is a host that runs t he S NMP cli ent program The manage r has a cc es s to t he values in t he data base kept by t he ag ent. A manager che cks t he agent by requ esti ng the informati on that refl ects t he behavior o f the agent. A manager also for ces t he agent t o per form a cer tain functi on by resett ing values in t he agent datab ase. For ex ampl e, a rout er c an st ore in approp riate va riables the number o f pac kets rec eived and forwa rded. The manage r c an fetch and compar e the values o f these two va riables to see if the rout er is congested or not. S NMP AGE NT The agent i s a rout er th at runs the SNMP server program. The agent i s used to ke ep the informati on in a d atabase while th e manag er is used to ac cess the values in t he datab ase . For ex ampl e, a rout er c an st ore the app ropriate v ariables such as a numbe r of pack ets receiv ed and fo rwa rded while the manage r can co mpare these v ariables to determi ne wheth er the router is congest ed or not. Agents can also contribut e to t he management pr ocess. A serve r progr am on t he agent ch ecks t he enviro nment, if something goes wrong, the ag ent sends a wa rning message to t he manager. S NMP MANAGE ME N T COMPONENT S Management of th e int ernet i s achi eved through sim ple interacti on betwe en a manag er and agent. Management is a chieve d through the use of two protocols: o S tructure of Man ageme nt Info rmati on (SM I) o Management In formati on B ase (M IB ). S tru cture of Man agem en t Inform ation (SMI) To use S NMP, we need rules for nami ng obje cts. S MI is a protocol that d efines these rules. S MI is a guideli ne fo r S NMP It emph asizes thr ee att r ibut es to h andle an object : name, data type, and encoding m ethod. Its fun cti ons are: To name obje cts. To define the typ e of d ata that can b e stored in a n object. To show how to encod e data fo r transmi ssi on over the netwo rk. Name S MI requires th at each managed obje ct (such as a router, a variabl e in a r outer, a value, etc.) have a unique n ame. To name objects gl oball y. S MI us es an object i de nti fier, which is a hier arc hical i denti fier bas ed on a tree stru cture. The tre e structur e starts with an unnamed root. E ach object can be d efined using a sequenc e of integers sep arated by dots. The tre e structur e can a lso define an obje ct usi ng a sequenc e of textu al na mes separat ed by dots. Type of data The se cond att ribute of an object i s the type of d ata stored in i t. To define th e data type, S MI uses Abstr act S ynta x Notati on One (AS N.1) definiti ons. S MI h as two broad cat egories of dat a types: si mpl e and st ructured. The sim ple data types a re atom ic data typ es. S ome of them ar e taken dir ectl y from AS N.1; some are added by S M I. S MI d efines two st ruct ured data types: s equ enc e and sequen ce o f. S equence - A sequ enc e data type is a combi nati on of sim ple data types, not necessaril y of th e sa me type. S equence o f - A s eque nce of dat a type is a com bination of sim ple data types all of the same type or a combi nati on of sequ ence d ata types all of the same type. E n codin g data S MI us es another stand ard, Basic Encoding R ule s (BER ), to encode dat a to be transmi tt ed over the netwo rk. B ER sp ecifies that e ac h piece of d ata be encode d in t riplet format (TLV): tag, length, value Man agem en t Inform ation B ase (MIB ) The Manag ement Inform ati on B ase (M IB ) is the s econd component used in network management. Each ag ent has it s own MIB , which is a coll ecti o n of objects t o be manag ed. MIB classifi es obj ects under groups. MIB Variab les MIB va riables a re of two types namely si mpl e and table. S im ple variables are ac cessed using group-id fol lowed by variable-id and 0 Tables ar e orde red as c olum n-row rules, i.e., col umn by column from t op to bott om. Only leaf elem ents are ac cessi ble in a table type. S NMP ME S S AGE S /PDU S NMP i s request/ reply protocol t hat supp orts various operati ons usi ng P DUs. S NMP defines eight types of protocol data unit s ( or PDUs): GetR equest, GetN ext-R e quest, GetB ulkR equest, S etR equest, R esponse, Trap, In formR equest, and Rep ort GetReq u est The GetR equ est P DU is s ent from t he manage r (cli ent) to t he age nt (serv er) to retrieve the v alue of a variable or a set of v ariab les. GetNext Req u est The GetN extR equest P DU is s ent from t he man ager to the ag ent t o retrie ve the value of a v ariable. GetB u lk Req u est The GetB ulkR equest P DU is s ent from t he man ager to the ag ent t o retrie ve a large amount of d ata. It c an be used inst ead o f mult ipl e GetR equest and GetNextR equest P DUs. S etReq u est The S etR equest P DU i s sent from the manag er t o the agent t o set (store ) a value in a vari able. Resp on se The R esponse PDU is sent from an ag ent t o a manager in response to GetR equest or G etNextR equest. It contains t he val ue(s) of the v ariable (s) requested by the m anage r. T rap The Tr ap P DU is s ent from t he agent t o the ma nager to r eport an ev ent. For exampl e, if the ag ent i s r ebooted, it i nforms t he manager and r eports the tim e of rebooti ng. In form Req u est The Info rmRequest P DU is s ent from one man ager to anothe r remot e manager to get the v alue of some variables from a gents un der the control o f the remot e manag er. The re mot e manager responds with a Response P DU. Rep ort The R eport P DU is de signed to report some typ es of er rors betw een managers. r˚Pµo„›ˆı˚’(} „oo˚u˚’ı˚„’oo˚›„ıu˚vı}ı˚’vˆÁ„]ıı˚v}ı˚’’ı˚„µ˚’ı]}v›˚„’µi˚ıÁ]’˚µ˚’ı]}vvl’u›}„ıvıµ˚’ı]}v’(}„˚u˚’ı˚„’„]}µ’µıZ}„}}l’