Tcp.ip Trong 14 Ngay.pdf
-
Upload
cuong-tran -
Category
Documents
-
view
234 -
download
0
Transcript of Tcp.ip Trong 14 Ngay.pdf
-
8/10/2019 Tcp.ip Trong 14 Ngay.pdf
1/486
Teach Yourself TCP/IP in 14 Days
Second Edition
Pr efa ce t o Second Edit ion
About t he Aut hor
Overview
Int r oduct ion
1. Open Syst ems, St an dar ds, and Pr ot ocol s
2. TCP/IP an d t he Int er net
3. The Int er net Pr ot ocol (IP)
4. TCP an d UDP
5. Gat eway an d Rout ing Pr ot ocol s
6. Tel net an d FTP
7. TCP/IP Configur a t ion and Administ r a t ion Basics
8. TCP/IP and Net wor ks
9. Set t ing Up a Sampl e TCP/IP Net wor k: Ser ver s
10. Set t ing Up a Sampl e TCP/IP Net wor k: DOS and Windows Cl ien t s
11. Domain Name Ser vice
12. Net wor k Fil e Syst em an d Net wor k Inf or mat ion Ser vice
13. Managing an d Tr oubl eshoot ing TCP/IP
14. The Socket Pr ogr amming Int er fa ce
Appendix A: Acr onyms an d Abbreviat ions
Appen dix B: Gl ossar y
Appen dix C: Commands
Appendix D: Wel l -Known Por t Number s
Appendix E: RFCs
Appendix F: Answer s t o Quizz es
This document was pr oduced u sing a BETA version of HTML Tr ansit 2
http://www.infoaccess.com/products/transit/index.htmhttp://www.infoaccess.com/products/transit/index.htm -
8/10/2019 Tcp.ip Trong 14 Ngay.pdf
2/486
Teach Yourself TCP/IP in 14 Days, Second
Edition
The second edit ion of Teach Yourself TCP/IP in 14 Daysexpan ds on t he very popul ar fir st
dit ion, br inging t he infor mat ion u p-t o-dat e an d adding n ew t opics t o compl et e t he
over age of TCP/IP. The book ha s been r eor gan ized t o make r eading an d l ear ning easier ,
s wel l as t o pr ovide a mor e l ogical appr oach t o t he subject .
New mat er ial in t his edit ion deal s wit h inst al l ing, configur ing, an d t est ing a TCP/IP
et work of ser vers an d cl ient s. You wil l see how t o easil y set up UNIX, Linu x, an d
Windows NT ser ver s for a l l popul ar TCP/IP ser vices, incl uding Tel net , FTP, DNS, NIS,nd NFS. On t he cl ien t side, you wil l see how t o set up DOS, Windows, Windows 95, and
WinSock t o int er act wit h a ser ver. Exampl es an d t ips t hr oughout t hese sect ions make
he pr ocess easy and cl ear .
Al so added in t his edit ion of Teach Yourself TCP/IP in 14 Daysar e new sect ions on DNS,
NFS, an d NIS. These net wor k ser vices ha ve become popul ar wit h t he gr owt h of l ar ge
TCP/IP net wor ks, so we show you h ow t o conf igur e an d use t hem al l . A new sect ion on
he l at est ver sion of IP updat es t he t r eat ment of t he base pr ot ocol s t o 1996 st an dar ds.
Tim Par ker
Mail :
Dean Mil l er
Comment s Depar t ment
ams Publ ish ing
01 W. 103r d St r eet
ndianapol is, IN 46290
Topics Cover ed in Det a il in t h is Edit ion
The TCP/IP Pr ot ocol Famil y
Transport
Rout ing
Net wor k Addr esses
User Ser vices Gat eway Pr ot ocol s
Others
-
8/10/2019 Tcp.ip Trong 14 Ngay.pdf
3/486
Topics Cover ed in Det a il in t h is Edit ion
St an dar ds an d t erminol ogy
Net work ar chit ect ur e
Hist or y of TCP/IP an d t he Int er net
IPng (IP ver sion 6)
Tel net an d FTP
Configur ing ser vers and cl ient s
Introduction
o you've just been t ol d you a r e on a TCP/IP net wor k, you a r e t he n ew TCP/IP syst em
dminist r at or , or you ha ve t o inst al l a TCP/IP syst em. But you don't know very much
bout TCP/IP. Tha t 's wher e t his book comes in . You don 't need any pr ogr amming skil l s,
n d fa mil iar it y wit h oper at ing syst ems is assumed. Even if you've never t ouch ed a
omput er befor e, you shoul d be abl e t o fol l ow t he mat erial .
This book is int ended for beginn ing t hr ough int er mediat e user s an d covers al l t he
r ot ocol s invol ved in TCP/IP. Each pr ot ocol is examined in a fa ir l evel of det ail t o showow it wor ks an d how it int era ct s wit h t he ot her pr ot ocol s in t he TCP/IP famil y. Al ong
he way, t his book shows you t he basic t ool s r equir ed t o inst al l , configur e, an d maint ain
TCP/IP net wor k. It al so shows you most of t he user ut il it ies t hat ar e avail abl e.
Because of t he compl ex nat ur e of TCP/IP an d t he l ack of a fr iendl y user int erf ace,
here is a l ot of infor mat ion t o l ook at . Thr oughout t he book, t he r ol e of each pr ot ocol
s shown separ at el y, as is t he way it works on n et works of a l l sizes. The r el at ionship
wit h l ar ge int ern et wor ks (l ike t he Int ern et ) is al so cover ed.
Each ch apt er in t he book adds t o t he compl exit y of t he syst em, buil ding on t he mat er ial
n t he ear l ier chapt er s. Al t hough some chapt er s seem t o be unr el at ed t o TCP/IP at f ir st
-
8/10/2019 Tcp.ip Trong 14 Ngay.pdf
4/486
l an ce, al l t he mat erial is invol ved in an int egr al man ner wit h t he TCP/IP pr ot ocol
amil y. The l ast few chapt ers cover t he inst al l at ion and t r oubl eshoot ing of a n et wor k.
By t he t ime you f inish t his book, you wil l un der st an d t he diff er ent component s of a
TCP/IP syst em, as wel l as t he compl ex acr onym-hea vy jar gon u sed. Fol l owing t he
xampl es pr esent ed, you shoul d be a bl e t o inst al l an d configur e a compl et e TCP/IP
et wor k for any opera t ing syst em an d har dwar e pl at for m.
The TCP/IP Protocol Family
Transport
Tr ansmission Cont r ol Pr ot ocol (TCP): connect ion-based ser vices
User Dat agr am Pr ot ocol (UDP): conn ect ionl ess ser vices
Routing
Int er net Pr ot ocol (IP): ha ndl es t r an smission of infor mat ion
Int er net Cont r ol Message Prot ocol (ICMP): ha ndl es st at us messages for IP
Rout ing Inf or mat ion Pr ot ocol (RIP): det er mines r out ing
Open Shor t est Pat h Fir st (OSPF): al t er nat e pr ot ocol for
det er mining r out ing
Network Addresses
Addr ess Resol u t ion Pr ot ocol (ARP): det er mines addr esses
-
8/10/2019 Tcp.ip Trong 14 Ngay.pdf
5/486
Domain Name Syst em (DNS): det er mines addr esses fr om mach ine names
Rever se Addr ess Resol u t ion Pr ot ocol (RARP): - det er mines
addresses
User Services
Boot Pr ot ocol (BOOTP): st ar t s up a net work mach ine
Fil e Tr an sfer Pr ot ocol (FTP): t r an sfer s fil es
Tel net : al l ows r emot e l ogins
Gateway Protocols
Ext erior Gat eway Pr ot ocol (EGP): t r an sfer s r out ing infor mat ion for
ext ernal net works
Gat eway-t o-Gat eway Pr ot ocol (GGP): t r an sfer s r out ing inf or mat ion
bet ween gat eways
Int erior Gat eway Pr ot ocol (IGP): t r an sfer s r out ing infor mat ion
for int ernal net works
Others
Net wor k Fil e Syst em (NFS): enabl es dir ect or ies on on e machine t o be
mount ed on anot her
Net wor k Inf or mat ion Ser vice (NIS): maint ains user accou nt s acr oss
net wor ks
-
8/10/2019 Tcp.ip Trong 14 Ngay.pdf
6/486
Remot e Pr ocedur e Cal l (RPC): ena bl es r emot e appl icat ions t o commun icat e
Simpl e Mail Tr an sfer Pr ot ocol (SMTP): t r an sfer s el ect r onic mail
Simpl e Net wor k Man agement Pr ot ocol (SNMP): sends st at us
messages about t he net work
-
8/10/2019 Tcp.ip Trong 14 Ngay.pdf
7/486
The TCP/IP Pr ot ocol Famil y
The TCP/IP Protocol Family
Transport
TCP (Tr ansmission Cont r ol Pr ot ocol ) Connect ion-based ser vices (Day 4)
UDP (User Dat agr am Pr ot ocol ) Connect ionl ess ser vices (Day 4)
Routing
IP (Int er net Pr ot ocol ) Han dl es t r an smission of inf or mat ion (Day 3)
ICMP (Int er net Cont r ol Message
Pr ot ocol )Handl es st a t us messages for IP (Day 3)
RIP (Rout ing Inf or mat ion Pr ot ocol ) Det er mines r out ing (Day 5)
OSPF (Open Shor t est Pat h Fir st )
Al t erna t e pr ot ocol for det ermining rout ing
(Day 5)
Network Addresses
ARP (Addr ess Resol u t ion Pr ot ocol ) Det er mines addr esses (Day 2)
DNS (Domain Name Syst em)Det er mines addr esses f r om mach ine names
(Day 2 and Day 11)
RARP (Rever se Addr ess Resol u t ion
Pr ot ocol )Det er mines addr esses (Day 2)
User Services
BOOTP (Boot Pr ot ocol ) St ar t s up a net wor k mach ine (Day 11)
FTP (Fil e Tr an sfer Pr ot ocol ) Tr an sfer s fil es (Day 6)
Tel net Ena bl es r emot e l ogins (Day 6)
TFTP (Tr ivial Fil e Tr an sfer Pr ot ocol ) Ena bl es r emot e fil e t r an sfer s (Day 6)
Gateway Protocols
-
8/10/2019 Tcp.ip Trong 14 Ngay.pdf
8/486
EGP (Ext er ior Gat eway Pr ot ocol )Tr ansfers rout ing infor mat ion for ext erna l
net wor ks (Day 3 an d Day 5)
GGP (Gat eway-t o-Gat eway Pr ot ocol )Tr an sfer s rout ing informat ion bet ween
gat eways (Day 3 and Day 5)
IGP (Int er ior Gat eway Pr ot ocol )Tr ansfers rout ing infor mat ion for int erna l
net wor ks (Day 5)Others
NFS (Net wor k Fil e Syst em)Ena bl es dir ect or ies on on e mach ine t o be
moun t ed on a not her (Day 12)
NIS (Net wor k Infor mat ion Ser vice)Maint ains user a ccoun t s acr oss net works
(Day 12)
NTP (Net wor k Time Pr ot ocol ) Synchr onizes cl ocks (Day 11)
PING (Packet Int er net Gr oper ) Checks conn ect ivit y (Day 7)
RPC (Remot e Pr ocedur e Cal l )Ena bl es r emot e appl icat ions t o commun icat e
(Day 12)
SNMP (Simpl e Net wor k Management
Pr ot ocol )
Sends st at us messages about t he net work
(Day 13)
-
8/10/2019 Tcp.ip Trong 14 Ngay.pdf
9/486
Open Syst ems
What Is an Open Syst em?
Net wor k Ar chit ect ur es
Local Ar ea Net wor ks
The Bus Net wor k
The Ring Net wor k
The Hub Net wor k
Wide Ar ea Net wor ks
Layers
The Appl ica t ion Layer
The Pr esent at ion Layer
The Session Layer
The Tr an spor t Layer
The Net work Layer
The Dat a Link Layer
The Physical Layer
Ter minol ogy an d Not at ions
Packet s
Subsyst ems
Ent it ies
N Not at ion
N-Fun ct ions
N-Facil it ies
Services
Making Sense of t he Jar gon
Queu es an d Conn ect ions Standards
Set t ing St andards
In t erne t St andards
Pr ot ocol s
Br eaking Dat a Apar t
Pr ot ocol Headers
Summar y
Q&A Quiz
-
8/10/2019 Tcp.ip Trong 14 Ngay.pdf
10/486
1
Open Systems, Standards, and Protocols
Today I st ar t l ooking a t t he subject of TCP/IP by cover ing some backgr oun d inf or mat ion
ou wil l need t o put TCP/IP in per spect ive, an d t o un der st an d why t he TCP/IP pr ot ocol s
wer e designed t he way t hey a r e. This cha pt er cover s some impor t an t inf or mat ion,
ncl uding t he fol l owing:
What an open syst em is
How an open syst em ha ndl es net wor king
Why st an dar ds ar e requir ed
How st an dar ds for pr ot ocol s l ike TCP/IP ar e devel oped
Wha t a pr ot ocol is
The OSI pr ot ocol s
You might be eager t o get st ar t ed wit h t he nit t y-grit t y of t he TCP/IP pr ot ocol s, or t o
ind ou t how t o use t he bet t er -known ser vices l ike FTP an d Tel net . If you ha ve a specific
equir ement t o sat isfy (such a s how t o t r an sfer a f il e fr om one syst em t o anot her ), by
l l means use t he Tabl e of Cont ent s t o f ind t he sect ion you want . But if you want t o
eal l y underst and TCP/IP, you wil l need t o wade t hr ough t he mat erial in t his chapt er.
t 's not compl icat ed, al t hou gh t her e ar e quit e a few subject s t o be cover ed. Luckil y,
one of it r equir es memorizat ion; more oft en t ha n n ot it is a mat t er of set t ing t he st age
or somet hing el se I discuss in t he n ext week or so. So don't get t oo over whel med by t his
hapt er!
Open Systems
This is a book about a f amil y of pr ot ocol s cal l ed TCP/IP, so why bot her l ooking a t open
yst ems an d st an dar ds at al l ? Pr imar il y because TCP/IP gr ew out of t he n eed t o devel opst an dar dized commun icat ions pr ocedur e t ha t woul d inevit abl y be used on a var iet y of
l at forms. The need for a st andar d, and one t hat was r eadil y avail abl e t o anyone
hence open), was vit al l y impor t an t t o TCP/IP's success. Ther efor e, a l it t l e backgr ound
-
8/10/2019 Tcp.ip Trong 14 Ngay.pdf
11/486
el ps put t he design of TCP/IP in t o per spect ive.
Mor e impor t an t l y, open syst ems ha ve become de rigueur in t he cu r r ent compet it ive
mar ket . The t er m open systemis ban died ar oun d by man y peopl e as a sol ut ion f or al l
r obl ems (t o be r epl aced occasiona l l y by t he t er m client/server), but neit her t er m is
sual l y pr oper l y used or u nder st ood by t he peopl e spout ing t hem. Under st an ding what
n open syst em r eal l y is an d what it impl ies l eads t o a bet t er awar eness of TCP/IP's r ol e
n a net wor k and across l ar ge int ernet wor ks l ike t he Int ernet .
n a simil ar vein, t he u se of st an dar ds ensur es t ha t a pr ot ocol such as TCP/IP is t he same
n ea ch syst em. This mean s t ha t your PC can t al k t o a minicomput er r un ning TCP/IP
wit hout special t r ansl at ion or conver sion r out ines. It means t hat an ent ir e net wor k of
iffer ent ha r dwar e and opera t ing syst ems can wor k wit h t he same net wor k pr ot ocol s.
Devel oping a st an dar d is not a t r ivial pr ocess. Oft en a singl e st an dar d invol ves mor e
ha n a singl e document descr ibing a soft war e syst em. A st an dar d oft en invol ves t he
nt er r el at ionship of man y diff er ent pr ot ocol s, as does TCP/IP. Knowing t he int er act ionset ween TCP/IP and t he ot her componen t s of a commun icat ions syst em is impor t an t for
r oper configur at ion an d opt imiza t ion, an d t o ensur e t ha t al l t he services you n eed ar e
vail abl e and int erwor king pr operl y.
What Is an Open System?
Ther e ar e man y definit ions of open syst ems, an d a singl e, concise definit ion t ha t
ver yone is ha ppy wit h is fa r fr om being accept ed. For most peopl e, an open syst em is best
oosel y defined as one for which t he ar chit ect ur e is not a secret . The descript ion of t he
r chit ect ur e has been publ ished or is r eadil y avail abl e t o anyone who want s t o buil d
r oduct s for a ha r dwar e or soft war e pl at for m. This definit ion of an open syst em appl ies
qual l y wel l t o har dwar e and sof t ware.
When mor e t ha n a singl e vendor begins pr oducing pr oduct s for a pl at for m, cust omer s
a ve a choice. You don't par t icul ar l y l ike Nocr ash Soft war e's net wor k monit oring
oft war e? No pr obl em, because Fau l t Fr ee Soft war e's pr oduct r un s on t he Nocra sh
a r dwar e, an d you l ike it s fan cy int erf ace much bet t er. You need a more col or ful
r aphical fr ont -end t o your Whizban g PC t ha n t he one Whizban g pr ovides? Downl oad
ne fr om Super Soft war e t hr ough t he Int ern et , and it wor ks perf ect l y. The pr imar y
dea, of cour se, is a move away f r om pr opr iet ar y pl at for ms t o one t ha t is mul t ivendor.
A decade ago, open syst ems wer e vir t ua l l y nonexist ent . Each ha r dwar e manu fact ur er
ad a pr oduct l ine, and you were pr act ical l y bound t o t hat manufact ur er for a l l youroft war e an d ha r dwar e needs. Some compan ies t ook advant age of t he ca pt ive mar ket ,
ha r ging out r ageous pr ices or f or cing un wan t ed configur at ions on t heir cust omer s. The
roun dswel l of r esent ment grew t o t he point t hat cust omers began for cing t he issue.
-
8/10/2019 Tcp.ip Trong 14 Ngay.pdf
12/486
The l ack of choice in soft war e and ha r dwar e pur cha ses is why sever al dedicat ed
minicomput er an d mainf r ame compan ies eit her went ban kr upt or ha d t o accept open
yst em pr incipl es: t heir cust omer s got fed up wit h r el ying on a singl e vendor . A good
xampl e of a compan y t ha t made t he a dapt at ion is Digit al Equipment Cor por at ion (DEC).
They moved fr om a pr opr iet ar y oper a t ing syst em on t heir VMS minicomput er s t o a UNIX-
t an dar d open oper at ing syst em. By doing t ha t , t hey kept t heir cust omer s ha ppy, an d
hey sol d mor e mach ines. Tha t 's one of t he pr imar y r easons DEC is st il l in business t oday.
UNIX is a cl assic exampl e of an open soft war e pl at for m. UNIX has been a r oun d for 30
ear s. The sour ce code for t he UNIX oper at ing syst em was made a vail abl e t o an yone who
want ed it , al most fr om t he st ar t . UNIX's sour ce code is wel l un der st ood an d easy t o
wor k wit h, t he r esul t of 30 year s of devel opment an d impr ovement . UNIX can be por t ed
o ru n on pr act ical l y any har dwar e pl at for m, el imina t ing al l pr opr iet ar y dependencies.
The a t t r act ion of UNIX is not t he oper at ing syst em's feat ur es t hemsel ves but simpl y
ha t a UNIX user can r un soft war e fr om ot her UNIX pl at for ms, t ha t fil es ar e
ompat ibl e fr om one UNIX syst em t o an ot her (except for disk for mat s), an d t ha t a wide
ar iet y of vendor s sel l pr oduct s for UNIX.
The gr owt h of UNIX pushed t he l ar ge har dwar e man ufa ct ur ers t o t he open syst ems
r incipl e, r esul t ing in most man uf act ur er s l icensing t he r ight t o pr oduce a UNIX version
or t heir own ha r dwar e. This st ep l et cust omer s combine diff er ent ha r dwar e syst ems
nt o l ar ger net wor ks, al l r un ning UNIX an d wor king t oget her . Users coul d move
et ween machines al most t r anspar ent l y, ignor ant of t he act ual har dwar e pl at form
hey were on. Open syst ems, or igina l l y of pr ime impor t an ce onl y t o t he l ar gest
or por at ions an d gover nment s, is now a key el ement in even t he smal l est compan y'somput er st r at egy.
Al t hou gh UNIX is a copyr ight ed wor k now owned by
X/Open, t he det ail s of t he oper at ing syst em ha ve been publ ished
and ar e readil y avail abl e t o any devel oper who want s t o
pr oduce appl icat ions or ha r dwar e t hat wor k wit h t he opera t ingsyst em. UNIX is un ique in t h is r espect .
The t er m open system networkingmeans many t h ings, depending on whom you ask. In it s
r oadest definit ion, open syst em net working r efer s t o a net work based on a wel l -known
n d under st ood pr ot ocol (such as TCP/IP) t ha t ha s it s st an dar ds publ ished an d r eadil y
vail abl e t o anyone who wan t s t o use t hem. Open syst em net wor king al so r efers t o t he
r ocess of n et wor king open syst ems (mach aine-specific ha r dwar e a nd soft war e) using a
et work pr ot ocol . It is easy t o see why peopl e want open syst ems net working, t hough .
Thr ee services ar e widel y used and accoun t for t he highest percent age of net wor k
r af fic: fil e t r an sfer , el ect r onic mail , an d remot e l ogin. Wit hou t open syst ems
et working, set t ing up an y of t hese t hr ee ser vices woul d be a night mar e.
-
8/10/2019 Tcp.ip Trong 14 Ngay.pdf
13/486
il e t r an sfer s enabl e users t o sha r e fil es quickl y an d efficient l y, wit hout excessive
upl icat ion or concer ns about t he t r ansport met hod. Net wor k fil e t r ansfers ar e much
ast er t han an over night cour ier cr ossing t he count r y, and usual l y fast er t han copying
f il e on a disk an d car r ying it acr oss t he r oom. Fil e t r an sfer is al so ext r emel y
onvenient , which not onl y pl eases user s but al so el imina t es t ime del ays whil e wait ing
or mat er ial . A common open syst em gover ning fil e t r an sfer s mean s t ha t an y
ncompat ibil it ies bet ween t he t wo mach ines t r an sfer r ing fil es can be over come easil y.
El ect r onic mail ha s mushr oomed t o a phenomena l l y l ar ge ser vice, not just wit hin a
ingl e business but wor l dwide. The Int er net car r ies mil l ions of messages fr om peopl e in
over nment , pr ivat e indust r y, educat ional inst it ut ions, and pr ivat e int erest s.
El ect r onic mail is chea p (no paper , envel ope, or st amp) an d fa st (ar oun d t he wor l d in 60
econds or so). It is al so an obvious ext ension of t he comput er -based worl d we wor k in.
Wit hou t an open mail syst em, you woul dn't ha ve anywher e near t he capabil it ies you
ow enjoy.
ina l l y, r emot e l ogins ena bl e a user who is based on one syst em t o conn ect t hr ough a
et wor k t o any ot her syst em t ha t accept s him as a user. This can be in t he n ext
wor kgr oup, t he next st at e, or in an ot her count r y. Remot e l ogins enabl e users t o t ake
dvant age of par t icul ar har dwar e and sof t ware in anot her l ocat ion, as wel l as t o run
ppl icat ions on an ot her mach ine. Once aga in, wit hou t an open st an dar d, t his woul d be
l most impossibl e.
Network Architectures
To un der st an d net wor king pr ot ocol s, it is useful t o know a l it t l e about net wor ks. A
uick l ook at t he most common net wor k ar chit ect ur es wil l hel p l at er in t his book when
ou r ead about net wor k oper at ions an d rout ing. The t erm networkusua l l y means a set of
omput er s and per ipher al s (pr int er s, modems, pl ot t er s, scan ner s, an d so on) t ha t ar eonnect ed t oget her by some medium. The conn ect ion can be dir ect (t hr ough a cabl e) or
ndir ect (t hr ough a modem). The diff er ent devices on t he n et work commun icat e wit h
ach ot her t hr ough a pr edefined set of r ul es (t he pr ot ocol ).
The devices on a net work ca n be in t he same r oom or scat t er ed t hr ough a buil ding. They
an be separ at ed by man y mil es t hr ough t he use of dedicat ed t el ephone l ines, micr owave,
r a simil ar syst em. They can even be scat t er ed ar oun d t he wor l d, aga in conn ect ed by a
ong-dist an ce commun icat ions medium. The l ayout of t he n et work (t he a ct ua l devices
nd t he mann er in which t hey are connect ed t o each ot her) is cal l ed t he networkopology.
-
8/10/2019 Tcp.ip Trong 14 Ngay.pdf
14/486
Usual l y, if t he devices on a net wor k ar e in a singl e l ocat ion such a s a buil ding or a
roup of r ooms, t hey ar e cal l ed a l ocal ar ea net wor k, or LAN. LANs usua l l y have al l
he devices on t he net work connect ed by a singl e t ype of n et work cabl e. If t he devices
r e scat t ered widel y, such a s in differ ent buil dings or differ ent cit ies, t hey ar e usual l y
et up int o severa l LANs t hat ar e joined t oget her int o a l ar ger st r uct ur e cal l ed a wide
r ea net wor k, or WAN. A WAN is composed of t wo or mor e LANs. Each LAN has it s own
et wor k cabl e connect ing al l t he devices in t ha t LAN. The LANs ar e joined t oget her by
n ot her conn ect ion met hod, oft en h igh-speed t el ephone l ines or ver y fa st dedicat edet wor k cabl es cal l ed backbones, which I discuss in a moment .
One l ast point about WANs: t hey are of t en t r eat ed as a singl e ent it y for
r gan iza t iona l pur poses. For exampl e, t he ABC Soft war e compan y might ha ve br an ches
n f our diff er ent cit ies, wit h a LAN in ea ch cit y. Al l four LANs ar e joined t oget her by
igh-speed t el ephone l ines. However, as fa r as t he Int er net an d anyone out side t he ABC
oft war e compan y ar e concer ned, t he ABC Soft war e WAN is a singl e ent it y. (It ha s a
ingl e domain na me for t he Int er net . Dont worr y if you dont known wha t a domain is
t t his point in t ime; it r efers t o a singl e ent it y for or ganiza t ional pur poses on t he
nt ernet , as you wil l see l at er .)
Local Area Networks
TCP/IP wor ks acr oss LANs and WANs, and t her e ar e sever a l impor t ant aspect s of LANn d WAN t opol ogies you shoul d know about . You can st ar t wit h LANs an d l ook at t heir
opol ogies. Al t hough t her e ar e man y t opol ogies for LANs, t hr ee t opol ogies ar e
ominant : bus, r ing, an d hub.
The Bus Network
The bus net wor k is t he simpl est , compr ising a singl e main commun ica t ions pa t hway wit h
ach device at t ached t o t he main cabl e (bus) t hr ough a device cal l ed a t r an sceiver or
u nct ion box. The bu s is al so ca l l ed a backbone because it r esembl es a human spine wit h
ibs eman at ing fr om it . Fr om each t r an sceiver on t he bus, an ot her cabl e (oft en ver y
hor t ) r un s t o t he device's net work a dapt er . An exampl e of a bus net work is shown in
igu r e 1.1.
igur e 1.1. A schemat ic of a bus net wor k showingt h e back bo ne wit h t r ansce ive r sead ing t o ne t wo r k d evices.
The pr imar y advant age of a bus net work is t ha t it al l ows for a h igh-speed bus. Anot her
http://d%7C/UncleVan/Current/Teach%20Yourself%20TCP-IP%20in%2014%20Days%202nd%20Edition/01tyt01.gifhttp://d%7C/UncleVan/Current/Teach%20Yourself%20TCP-IP%20in%2014%20Days%202nd%20Edition/01tyt01.gifhttp://d%7C/UncleVan/Current/Teach%20Yourself%20TCP-IP%20in%2014%20Days%202nd%20Edition/01tyt01.gifhttp://d%7C/UncleVan/Current/Teach%20Yourself%20TCP-IP%20in%2014%20Days%202nd%20Edition/01tyt01.gifhttp://d%7C/UncleVan/Current/Teach%20Yourself%20TCP-IP%20in%2014%20Days%202nd%20Edition/01tyt01.gifhttp://d%7C/UncleVan/Current/Teach%20Yourself%20TCP-IP%20in%2014%20Days%202nd%20Edition/01tyt01.gif -
8/10/2019 Tcp.ip Trong 14 Ngay.pdf
15/486
dvant age of t he bus net wor k is t hat it is usua l l y immun e t o pr obl ems wit h a ny singl e
et wor k car d wit hin a device on t he n et wor k. This is becau se t he t r an sceiver al l ows
r aff ic t hr ough t he backbone whet her a device is at t ached t o t he junct ion box or n ot .
Each en d of t he bus is t er mina t ed wit h a bl ock of r esist or s or a simil ar el ect r ical device
o mar k t he end of t he cabl e el ect r ical l y. Each device on t he pat hway has a special
dent ifying n umber , or addr ess, t ha t l et s t he device know t ha t incoming inf or mat ion is
or t hat device.
A bus net wor k is sel dom a st r aight cabl e. Inst ead, it is usua l l y t wist ed ar ound wal l s
n d buil dings as needed. It does ha ve a singl e pat hway f r om one end t o t he ot her , wit h
ach end t er mina t ed in some way (usual l y wit h a r esist or ). Figur e 1.1 shows a l ogical
epr esent at ion of t he net work, mean ing it ha s simpl ified t he act ua l physical appear an ce
f t he net wor k int o a schemat ic wit h st r aight l ines and no real scal e t o t he
onnect ions. A physical r epr esent at ion of t he net wor k woul d show how it goes t hr ough
wal l s, ar ound desks, an d so on. Most devices on t he bus net work ca n send or r eceive
at a al ong t he bus by packaging a message wit h t he int ended r ecipient 's address.
A var iat ion of t he bus net work t opol ogy is foun d in man y smal l LANs t ha t use Thin
Et her net cabl e (which l ooks l ike t el evision coaxial cabl e) or t wist ed-pair cabl e (which
esembl es t el ephon e cabl es). This t ype of net work consist s of a l engt h of coaxial cabl e
ha t sna kes fr om mach ine t o mach ine. Unl ike t he bus net work in Figur e 1.1, t her e ar e no
r an sceivers on t he bus. Inst ead, each device is connect ed int o t he bus dir ect l y using a T-
ha ped connect or on t he net wor k int er face car d, oft en using a connect or cal l ed a BNC.
The conn ect or connect s t he machine t o t he t wo neighbors t hr ough t wo cabl es, one t o
ach n eighbor . At t he ends of t he n et work, a simpl e r esist or is added t o one side of t he T-onnect or t o t erminat e t he net wor k el ect r ical l y .
A schemat ic of t his t ype of n et wor k is shown in Figur e 1.2. Each net wor k device ha s a T-
onnect or a t t ached t o t he net wor k int erfa ce card, l eading t o it s t wo neighbors. The
wo ends of t he bus ar e t erminat ed wit h r esist ors.
igur e 1.2. A sche mat ic of a mac hine-t o-mac hine busne t wo r k .
This mach ine-t o-mach ine (al so cal l ed peer -t o-peer ) net wor k is not capabl e of sust aining
he higher speeds of t he backbone-based bus net wor k, pr imar il y becau se of t he medium of
he n et work ca bl e. A backbone n et work ca n use ver y high-speed cabl es such as fiber
pt ics, wit h smal l er (an d sl ower ) cabl es fr om each t r an sceiver t o t he device. A mach ine-
o-mach ine net work is usual l y buil t using t wist ed-pair or coaxial cabl e because t hese
abl es ar e much cheaper an d easier t o wor k wit h. Unt il r ecent l y, mach ine-t o-mach ine
et works wer e l imit ed t o a t hr oughput of a bout 10 Mbps (megabit s per second), al t hou gh
ecent devel opment s cal l ed 100VG AnyLAN an d Fast Et her net al l ow 100 Mbps on t his
ype of net wor k.
The a dvant age of t h is machine-t o-machine bus net wor k is it s simpl icit y. Adding new
machines t o t he net wor k means inst al l ing a net wor k car d and connect ing t he new
http://d%7C/UncleVan/Current/Teach%20Yourself%20TCP-IP%20in%2014%20Days%202nd%20Edition/01tyt02.gifhttp://d%7C/UncleVan/Current/Teach%20Yourself%20TCP-IP%20in%2014%20Days%202nd%20Edition/01tyt02.gifhttp://d%7C/UncleVan/Current/Teach%20Yourself%20TCP-IP%20in%2014%20Days%202nd%20Edition/01tyt02.gifhttp://d%7C/UncleVan/Current/Teach%20Yourself%20TCP-IP%20in%2014%20Days%202nd%20Edition/01tyt02.gif -
8/10/2019 Tcp.ip Trong 14 Ngay.pdf
16/486
mach ine int o a l ogical pl ace on t he backbone. One major advan t age of t he mach ine-t o-
mach ine bus net work is al so it s cost : it is pr obabl y t he l owest cost LAN t opol ogy
va il abl e. The pr obl em wit h t his t ype of bus net work is t ha t if one machine is t aken off
he net wor k cabl e, or t he net wor k int erf ace car d mal fun ct ions, t he backbone is br oken
n d must be t ied t oget her aga in wit h a jumper of some sor t or t he net work might cease
o funct ion pr operl y.
The Ring Network
A r ing n et wor k t opol ogy is oft en dr awn as it s na me suggest s, sha ped l ike a r ing. A
ypical r ing n et wor k schemat ic is shown in Figur e 1.3. You might ha ve hea r d of a token
ing networkbefor e, which is a r ing t opol ogy net wor k. You might be disappoint ed t o find
o physical r ing ar chit ect ur e in a r ing net wor k, t hough.
igur e 1.3. A schemat ic of a r ing net wor k.
Despit e t he al most au t omat ic assumpt ion t ha t a r ing
net wor k has a backbone wit h t he ends of t he cabl e joined t o
for m a l oop, t her e is no r eal cabl ing r ing at al l . The r ing na me
der ives fr om t he const r uct ion of t he cent r al cont r ol unit .
The t er m ringis a misnomer because ring net works don't ha ve an un ending ca bl e l ike a
us net wor k wit h t he t wo t erminat ors joined t oget her . Inst ead, t he r ing r efer s t o t he
esign of t he cent r al unit t hat ha ndl es t he net wor k's message passing. In a t oken r ing
et work, t he cent r al cont r ol un it is cal l ed a Media Access Unit , or MAU. The MAU ha s
r ing cir cuit inside it (for which t he n et work t opol ogy is na med). The r ing inside t heMAU ser ves as t he bus for devices t o obt a in messages.
The Hub Network
A hu b net work u ses a main cabl e much l ike t he bus net work, which is cal l ed t he
ackplane.The hu b t opol ogy is shown in Figur e 1.4. Fr om t he backpl an e, a set of ca bl eseads t o a h ub, which is a box cont aining severa l por t s int o which devices ar e pl ugged.
The cabl es t o a connect ion point ar e of t en cal l ed drops, because t hey dr op fr om t he
ackpl an e t o t he port s.
http://d%7C/UncleVan/Current/Teach%20Yourself%20TCP-IP%20in%2014%20Days%202nd%20Edition/01tyt03.gifhttp://d%7C/UncleVan/Current/Teach%20Yourself%20TCP-IP%20in%2014%20Days%202nd%20Edition/01tyt03.gif -
8/10/2019 Tcp.ip Trong 14 Ngay.pdf
17/486
igur e 1.4. A schemat ic of a hub net wor k.
Hub net works can be very l ar ge, using a high-speed fiber opt ic backpl an e an d sl ight l y
l ower Et her net dr ops t o hu bs fr om which a workgr oup can be suppor t ed. The h ub
et work can al so be smal l , wit h a coupl e of hu bs suppor t ing a few devices connect ed
oget her by st an dar d Et her net cabl es. The hu b net wor k is scal eabl e (meaning you can
t ar t smal l an d expan d as you n eed t o), which is par t of it s at t r act ion.
Hub net wor ks ha ve become popul ar for l ar ge inst al l at ions, in par t because t hey ar e
asy t o set up an d maint ain. They a l so can be t he l east expensive syst em in man y l ar ger
nst al l at ions, which adds t o t heir at t r act ion. The backpl an e can ext end across a
onsider abl e dist an ce just l ike a bus net work, wher eas t he por t s, or connect ion point s,
r e usua l l y grou ped in a set pl aced in a box or pan el . Ther e can be man y pan el s or
onnect ion boxes at t ached t o t he backpl an e.
Wide Area Networks
As I ment ioned ea r l ier , LANs can be combined int o a l ar ge ent it y cal l ed a WAN. WANs
r e usual l y composed of LANs joined t oget her by a h igh-speed l ink (such as a t el ephon e
ine or dedicat ed cabl e). At t he ent r an ce t o each LAN, one or mor e mach ines act as t he
ink bet ween t he LAN an d WAN: t hese ar e cal l ed gat eways. I t al k about gat eways andhe t ypes of gat eways used in a WAN in mor e det ail on man y of t he f ol l owing days, but
or now you need t o know onl y t hat a gat eway is t he int erfa ce bet ween a LAN and a
WAN. The same appl ies for an y LAN t ha t accesses t he Int er net : one mach ine u sua l l y
ct s as t he gat eway fr om t he LAN t o t he Int ernet (which is r eal l y just a very l ar ge
WAN).
Many t erms ot her t han gatewayar e al so used. You wil l hear t erms l ike routerand bridge.
They ar e al l gat eways, but t hey perfor m sl ight l y different t asks. To underst and t heir
ol es (which I ment ion man y t imes in t he n ext week's mat er ial ), you need t o t ake a qu ick
ook at how WANs ar e l aid out .
LANs can be t ied t o a WAN t hr ough a gat eway t ha t ha ndl es t he passage of dat a
et ween t he LAN an d WAN backbone. In a simpl e l ayou t , a r out er is used t o per for m t his
u nct ion . This is shown in Figur e 1.5.
igur e 1.5. A r out er connect s a LAN t o t hebackbone.
Anot her gat eway device, cal l ed a br idge, is used t o connect LANs using t he same
et wor k pr ot ocol . Br idges ar e used onl y when t he same net wor k pr ot ocol (such a s
TCP/IP) is on bot h LANs. The br idge does not ca r e which physica l media is used. Br idges
http://d%7C/UncleVan/Current/Teach%20Yourself%20TCP-IP%20in%2014%20Days%202nd%20Edition/01tyt04.gifhttp://d%7C/UncleVan/Current/Teach%20Yourself%20TCP-IP%20in%2014%20Days%202nd%20Edition/01tyt05.gifhttp://d%7C/UncleVan/Current/Teach%20Yourself%20TCP-IP%20in%2014%20Days%202nd%20Edition/01tyt05.gifhttp://d%7C/UncleVan/Current/Teach%20Yourself%20TCP-IP%20in%2014%20Days%202nd%20Edition/01tyt05.gifhttp://d%7C/UncleVan/Current/Teach%20Yourself%20TCP-IP%20in%2014%20Days%202nd%20Edition/01tyt05.gifhttp://d%7C/UncleVan/Current/Teach%20Yourself%20TCP-IP%20in%2014%20Days%202nd%20Edition/01tyt04.gif -
8/10/2019 Tcp.ip Trong 14 Ngay.pdf
18/486
an connect t wist ed-pair LANs t o coaxial LANs, for exampl e, or act as an int er fa ce t o a
iber opt ic net work. As l ong as t he net work pr ot ocol is t he same, t he br idge fu nct ions
r oper l y.
f t wo or mor e LANs ar e invol ved in on e or gan iza t ion a nd t her e is t he possibil it y of a
ot of t r aff ic bet ween t hem, it is bet t er t o connect t he t wo LANs dir ect l y wit h a br idge
nst ead of l oading t he backbone wit h t he cr oss-t r af fic. This is shown in Figur e 1.6.
igur e 1.6. Using a br idge t o connect t woLANs.
n a configur at ion u sing bridges bet ween LANs, t r af fic fr om one LAN t o an ot her can be
ent t hr ough t he br idge inst ead of ont o t he backbone, pr oviding bet t er per for man ce. For
er vices such as Tel net an d FTP, t he speed diff er ence bet ween u sing a br idge an d going
hr ough a r out er ont o a heavil y used backbone can be significant .
WANs ar e an impor t an t subject , an d I l ook at t hem aga in in mor e det ail on Day 13,Managing an d Tr oubl eshoot ing TCP/IP."
Layers
uppose you h ave t o writ e a pr ogra m t ha t pr ovides net working fu nct ions t o ever ymachine on your LAN. Wr it ing a singl e soft war e packa ge t ha t accompl ishes ever y t ask
equir ed for commun icat ions bet ween diff er ent comput er s woul d be a night mar ish t ask.
Apar t fr om having t o cope wit h t he differ ent ha r dwar e ar chit ect ur es, simpl y writ ing
he code for al l t he appl icat ions you desir e woul d resul t in a pr ogr am t hat was far t oo
ar ge t o execut e or maint ain.
Dividing al l t he r equir ement s in t o simil ar -pur pose gr oups is a sensibl e appr oach, much a s
pr ogr ammer br eaks code in t o l ogica l chunks. Wit h open syst ems communica t ions, gr oups
r e quit e obvious. One group deal s wit h t he t r ansport of dat a, anot her wit h t heacka ging of messages, an ot her wit h end-user appl icat ions, an d so on. Each gr oup of
el at ed t asks is cal l ed a layer.
The l ayer s of an ar chit ect ur e are meant t o be st and-
al one, independent ent it ies. They usua l l y cannot perf orm an yobservabl e t ask wit hout int eract ing wit h ot her l ayer s, but
fr om a pr ogr amming point of view t hey a r e sel f-cont ained.
http://d%7C/UncleVan/Current/Teach%20Yourself%20TCP-IP%20in%2014%20Days%202nd%20Edition/01tyt06.gifhttp://d%7C/UncleVan/Current/Teach%20Yourself%20TCP-IP%20in%2014%20Days%202nd%20Edition/01tyt06.gifhttp://d%7C/UncleVan/Current/Teach%20Yourself%20TCP-IP%20in%2014%20Days%202nd%20Edition/01tyt06.gifhttp://d%7C/UncleVan/Current/Teach%20Yourself%20TCP-IP%20in%2014%20Days%202nd%20Edition/01tyt06.gif -
8/10/2019 Tcp.ip Trong 14 Ngay.pdf
19/486
Of cour se, some cr ossover of f un ct iona l it y is t o be expect ed, an d sever al diff er ent
ppr oach es t o t he same division of l ayer s for a n et wor k pr ot ocol wer e pr oposed. One
ha t became adopt ed as a st an dar d is t he Open Syst ems Int er connect ion Refer ence
Model (which is discussed in mor e det ail in t he next sect ion). The OSI Refer ence Model
OSI-RM) uses seven l ayer s, as shown in Figur e 1.7. The TCP/IP ar chit ect ur e is simil ar but
nvol ves onl y five l ayer s, becau se it combines some of t he OSI fu nct iona l it y in t wo
ayer s int o one. For now, t hough , consider t he seven-l ayer OSI model .
igur e 1.7. The OSI Ref er ence Model showing al l seven l ayer s.
The a ppl icat ion, pr esent at ion, an d session l ayer s ar e al l appl icat ion-orient ed in t ha t
hey are r esponsibl e for pr esent ing t he appl icat ion int erfa ce t o t he user . Al l t hr ee are
ndependent of t he l ayers bel ow t hem an d ar e t ot al l y obl ivious t o t he means by which
at a get s t o t he appl icat ion. These t hr ee l ayer s ar e cal l ed t he upper l ayers.
The l ower four l ayers deal wit h t he t r ansmission of dat a, covering t he packaging,out ing, verificat ion, an d t r an smission of each dat a gr oup. The l ower l ayer s don't
wor r y about t he t ype of dat a t hey receive or send t o t he appl icat ion, but deal simpl y
wit h t he t ask of sending it . They don't differ ent iat e bet ween t he differ ent appl icat ions
n a ny wa y.
The fol l owing sect ions expl ain each l ayer t o hel p you un der st and t he ar chit ect ur e of
he OSI-RM (an d l at er cont r ast it wit h t he ar chit ect ur e of TCP/IP).
The Application Layer
The appl icat ion l ayer is t he end-user int er fa ce t o t he OSI syst em. It is wher e t he
ppl icat ions, such as el ect r onic mail , USENET news rea der s, or dat abase displ ay modul es,
eside. The a ppl icat ion l ayer 's t ask is t o displ ay r eceived inf or mat ion a nd send t he u ser 's
ew dat a t o t he l ower l ayer s.
n dist r ibut ed appl icat ions, such as cl ient /ser ver syst ems, t he appl icat ion l ayer is wher e
he cl ient appl icat ion r esides. It commun icat es t hr ough t he l ower l ayers t o t he server .
The Presentation Layer
The pr esent at ion l ayer 's t ask is t o isol at e t he l ower l ayers fr om t he appl icat ion's dat a
or mat . It convert s t he dat a f r om t he appl icat ion int o a common for mat , oft en cal l ed
http://d%7C/UncleVan/Current/Teach%20Yourself%20TCP-IP%20in%2014%20Days%202nd%20Edition/01tyt07.gifhttp://d%7C/UncleVan/Current/Teach%20Yourself%20TCP-IP%20in%2014%20Days%202nd%20Edition/01tyt07.gifhttp://d%7C/UncleVan/Current/Teach%20Yourself%20TCP-IP%20in%2014%20Days%202nd%20Edition/01tyt07.gifhttp://d%7C/UncleVan/Current/Teach%20Yourself%20TCP-IP%20in%2014%20Days%202nd%20Edition/01tyt07.gif -
8/10/2019 Tcp.ip Trong 14 Ngay.pdf
20/486
h e canonical representation.The pr esent at ion l ayer pr ocesses mach ine-dependent dat a
r om t he appl icat ion l ayer int o a machine-independent for mat for t he l ower l ayers.
The pr esent at ion l ayer is wher e fil e for mat s an d even cha r act er f or mat s (ASCII an d
EBCDIC, for exampl e) ar e l ost . The conver sion fr om t he appl icat ion da t a f or mat t akes
l ace t hr ough a "common n et work pr ogra mming l an gua ge" (as it is cal l ed in t he OSI
Reference Model document s) t ha t has a st r uct ur ed for mat .
The pr esent at ion l ayer does t he r everse for incoming dat a. It is convert ed fr om t he
ommon for mat int o appl icat ion-specific for mat s, based on t he t ype of appl icat ion t he
machine h as inst r uct ions for . If t he dat a comes in wit hout r eformat t ing inst r uct ions,
he inf or mat ion might not be assembl ed in t he cor r ect man ner for t he u ser 's appl icat ion.
The Session Layer
The session l ayer or ganizes an d synchr onizes t he exchan ge of dat a bet ween a ppl icat ion
r ocesses. It works wit h t he a ppl icat ion l ayer t o pr ovide simpl e dat a set s cal l ed
ynchronization pointst ha t l et an appl icat ion know how t he t r an smission an d recept ion of
at a a r e pr ogr essing. In simpl ified t er ms, t he session l ayer can be t hou ght of a s a t iming
nd f l ow cont ro l l ayer .
The session l ayer is invol ved in coor dina t ing commun icat ions bet ween diff er entppl icat ions, l et t ing each know t he st at us of t he ot her . An er r or in one appl icat ion
whet her on t he same mach ine or acr oss t he count r y) is ha ndl ed by t he session l ayer t o
et t he r eceiving appl icat ion know t ha t t he err or h as occur r ed. The session l ayer can
esynchr onize appl icat ions t hat ar e curr ent l y connect ed t o each ot her . This can be
ecessar y when commun icat ions ar e t empor ar il y int er r upt ed, or wh en an er r or h as
ccurr ed t hat r esul t s in l oss of dat a.
The Transport Layer
The t r an spor t l ayer , as it s na me suggest s, is designed t o pr ovide t he "t r an spar ent
r an sfer of dat a fr om a sour ce end open syst em t o a dest ina t ion en d open syst em,"
ccor ding t o t he OSI Refer ence Model . The t r an spor t l ayer est abl ishes, maint ains, an d
er mina t es commun icat ions bet ween t wo mach ines.
The t r ansport l ayer is r esponsibl e for ensur ing t hat dat a sent mat ches t he dat a
eceived. This ver ificat ion r ol e is import an t in ensur ing t hat dat a is cor r ect l y sent , wit h
r esend if an err or was det ect ed. The t r ansport l ayer man ages t he sending of dat a,
-
8/10/2019 Tcp.ip Trong 14 Ngay.pdf
21/486
et er mining it s or der an d it s pr ior it y.
The Network Layer
The net wor k l ayer pr ovides t he physical r out ing of t he dat a, det er mining t he pat h
et ween t he machines. The net wor k l ayer ha ndl es al l t hese r out ing issues, r el ieving
he h igher l ayer s fr om t his issue.
The net wor k l ayer examines t he net wor k t opol ogy t o det ermine t he best r out e t o send
message, as wel l as figur ing out r el ay syst ems. It is t he onl y net wor k l ayer t ha t sends
message fr om sour ce t o t ar get mach ine, man aging ot her chu nks of dat a t ha t pass
hr ough t he syst em on t heir way t o anot her machine.
The Data Link Layer
The dat a l ink l ayer, according t o t he OSI r eference paper , "pr ovides for t he cont r ol of
he physical l ayer, and det ect s an d possibl y cor r ect s err ors t ha t can occur ." In
r act ical it y, t he dat a l ink l ayer is r esponsibl e for cor r ect ing t r an smission er r ors
ndu ced dur ing t r an smission (as opposed t o er r or s in t he appl icat ion da t a it sel f, whichr e handl ed in t he t r anspor t l ayer ).
The dat a l ink l ayer is usual l y concerned wit h signal int erfer ence on t he physical
r an smission media, whet her t hr ough copper wir e, fiber opt ic cabl e, or micr owave.
nt er fer ence is common, r esul t ing f r om man y sour ces, incl uding cosmic r ays and st r ay
magn et ic int er fer ence fr om ot her sour ces.
The Physical Layer
The physical l ayer is t he l owest l ayer of t he OSI model an d deal s wit h t he "mechan ical ,
l ect r ical , fun ct ional , an d pr ocedur al means" r equir ed for t r an smission of dat a,
ccor ding t o t he OSI definit ion. This is r eal l y t he wir ing or ot her t r an smission f or m.
When t he OSI model was being devel oped, a l ot of concern deal t wit h t he l ower t woayers, becau se t hey ar e, in most cases, insepar abl e. The r eal wor l d t r eat s t he dat a l ink
ayer an d t he physical l ayer as one combined l ayer, but t he for mal OSI definit ion
t ipul at es diff er ent pur poses for each. (TCP/IP incl udes t he da t a l ink a nd physical
-
8/10/2019 Tcp.ip Trong 14 Ngay.pdf
22/486
ayer s as one l ayer , r ecognizing t ha t t he division is mor e academic t ha n pr act ical .)
Terminology and Notations
Bot h OSI and TCP/IP ar e r oot ed in f or mal descr ipt ions, pr esent ed as a ser ies of compl ex
ocument s t ha t define a l l aspect s of t he pr ot ocol s. To define OSI an d TCP/IP, sever al
ew t er ms wer e devel oped and int r oduced int o use; some (most l y OSI t er ms) ar e r at her
nu sual . You might find t he t erm OSI-speakused t o refer t o some of t hese ra t her
r ot esque definit ions, much as legaleser efer s t o l egal t erms.
To bet t er un derst an d t he det ail s of TCP/IP, it is necessar y t o deal wit h t hese t er ms now.
You won't see al l t hese t er ms in t his book, but you might encount er t hem when r eading
man ua l s or onl ine document at ion. Ther efore, al l t he major t erms ar e cover ed here.
Man y of t he t er ms used by bot h OSI and TCP/IP might seem
t o ha ve mul t ipl e meanings, but t her e is a definit e at t empt t o
pr ovide a singl e, consist ent definit ion f or each word.
Unfor t una t el y, t he user communit y is sl ow t o adopt newt er minol ogy, so t her e is a consider abl e amoun t of conf usion.
Packets
To t r an sfer dat a eff ect ivel y, many experiment s ha ve shown t ha t creat ing a un ifor m
hunk of dat a is bet t er t ha n sending char act ers singl y or in widel y var ying sized
r oups. Usua l l y t hese chun ks of dat a h ave some inf or mat ion ah ead of t hem (t he header)
n d somet imes an indicat or at t he end (t he trailer). These chunks of dat a a r e cal l ed
acketsin most synchr onous communica t ions syst ems.
The amount of dat a in a packet an d t he composit ion of t he hea der ca n cha nge depending
n t he commun icat ions pr ot ocol as wel l as some syst em l imit at ions, but t he concept of a
acket al ways r efers t o t he ent ir e set (incl uding header an d t r ail er) . The t ermpacketis
sed oft en in t he comput er indu st r y, somet imes when it shou l dn't be.
-
8/10/2019 Tcp.ip Trong 14 Ngay.pdf
23/486
You oft en see t he wor dpacketused as a gener ic r efer ence t o any gr oup of dat a packaged
or t r ansmission. As an appl icat ion's dat a passes t hr ough t he l ayers of t he a r chit ect ur e,
ach adds mor e inf or mat ion. The t er mpacketis f r equent l y used at each st age. Tr eat t he
ermpacketas a genera l izat ion for any dat a wit h a ddit ional infor mat ion, inst ead of t he
pecific r esul t of onl y one l ayer 's addit ion of h eader an d t r ail er. This goes against t he
ffor t s of bot h OSI an d t he TCP gover ning bodies, but it hel ps keep your san it y int act !
Subsystems
A subsystemis t he col l ect ive of a par t icul ar l ayer acr oss a n et wor k. For exampl e, if 10
mach ines ar e conn ect ed t oget her , each r un ning t he seven-l ayer OSI model , al l 10
ppl icat ion l ayers ar e t he appl icat ion subsyst em, al l 10 dat a l ink l ayers ar e t he dat a
ink subsyst em, an d so on. As you might ha ve al r eady deduced, wit h t he OSI Refer ence
Model t her e ar e seven subsyst ems.
t is ent ir el y possibl e (an d even l ikel y) t ha t al l t he individual component s in a
ubsyst em wil l not be act ive at one t ime. Using t he 10-mach ine exa mpl e aga in, onl y t hr ee
might have t he dat a l ink l ayer act ual l y act ive at any moment in t ime, but t he
umul at ive of al l t he mach ines makes up t he subsyst em.
Entities
A l ayer can have more t han one par t t o it . For exampl e, t he t r ansport l ayer can ha ve
out ines t hat ver ify checksums as wel l as r out ines t hat han dl e resending packet s t hat
idn't t r ansfer cor r ect l y. Not al l t hese rout ines ar e act ive at once, because t hey might
ot be r equir ed at an y moment . The a ct ive rout ines, t hough, ar e cal l ed ent it ies. The
word entitywas adopt ed in or der t o find a singl e t erm t ha t coul d not be confused wit h
n ot her comput er t er m such as modul e, pr ocess, or t ask.
N Notation
The not at ions N, N+1, N+2, an d so on ar e used t o ident ify a l ayer an d t he l ayers t ha t
r e rel at ed t o it . Referr ing t o Figur e 1.7, if t he t r an sport l ayer is l ayer N, t he physical
ayer is N3 an d t he pr esent at ion l ayer is N+2. Wit h OSI, N al ways ha s a val ue of 1hr ough 7 incl usive.
One r eason t his not at ion was adopt ed was t o enabl e wr it ers t o refer t o ot her l ayer s
-
8/10/2019 Tcp.ip Trong 14 Ngay.pdf
24/486
wit hout ha ving t o wr it e out t heir names every t ime. It al so makes fl ow char t s an d
iagr ams of int er act ions a l it t l e easier t o dr aw. The t er ms N+1 an d N1 ar e commonl y
sed in bot h OSI an d TCP for t he l ayers above and bel ow t he cur r ent l ayer,
espect ivel y, as you wil l see.
To make t hings even mor e confu sing, man y OSI st an dar ds r efer t o a l ayer by t he f ir st
et t er of it s name. This can l ead t o a r eal mess for t he casua l r eader , because "S-ent it y,"
5-ent it y," an d "l ayer 5" al l r efer t o t he session l ayer.
N-Functions
Each l ayer perf orms N-fun ct ions. The fu nct ions ar e t he differ ent t hings t he l ayer does.
Therefor e, t he funct ions of t he t r anspor t l ayer a r e t he dif ferent t asks t hat t he l ayerr ovides. For most pur poses in t h is book, fu nct ions and en t it ies mean t he same t h ing.
N-Facilities
This uses t he hiera r chical l ayer st r uct ur e t o expr ess t he idea t ha t one l ayer pr ovides a
et of fa cil it ies t o t he next higher l ayer . This is sensibl e, because t he appl icat ion l ayer
xpect s t he pr esent at ion l ayer t o pr ovide a r obust , wel l -defined set of fa cil it ies t o it . In
OSI-speak, t he (N+1)-ent it ies assume a def ined set of N-fa cil it ies fr om t he N-ent it y.
Services
The en t ir e set of N-fa cil it ies pr ovided t o t he (N+1)-ent it ies is cal l ed t he N-ser vice. In
t her wor ds, t he service is t he ent ir e set of N-fun ct ions pr ovided t o t he next higher
ayer . Ser vices might seem l ike fun ct ions, but t her e is a f or mal diff er ence bet ween t he
wo. The OSI document s go t o gr eat l engt hs t o pr ovide det ail ed descr ipt ions of ser vices,
wit h a "ser vice definit ion st an dar d" for each l ayer . This was necessar y dur ing t he
evel opment of t he OSI st an dar d so t hat t he differ ent t asks invol ved in t he
ommun icat ions pr ot ocol coul d be assigned t o differ ent l ayers, an d so t ha t t he
unct ions of each l ayer ar e bot h wel l -defined and isol at ed from ot her l ayer s.
The ser vice definit ions ar e for mal l y devel oped fr om t he bot t om l ayer (physical ) upwar d
o t he t op l ayer. The advant age of t his appr oach is t ha t t he design of t he N+1 l ayer can
e based on t he fu nct ions perf ormed in t he N l ayer, avoiding t wo funct ions t ha t
-
8/10/2019 Tcp.ip Trong 14 Ngay.pdf
25/486
ccompl ish t he same t ask in t wo adjacent l ayer s.
An en t ir e set of var iat ions on t he ser vice name ha s been devel oped t o appl y t hese
efinit ions, some of which ar e in r egul ar use:
An N-ser vice user is a u ser of a ser vice pr ovided by t he N l ayer t o t he n ext higher (N+1)
ayer .
An N-ser vice pr ovider is t he set of N-ent it ies t ha t ar e invol ved in pr oviding t he N l ayer
ervice.
An N-ser vice access poin t (oft en abbr evia t ed t o N-SAP) is wher e an N-ser vice is pr ovided
o a n (N+1)-ent it y by t he N-ser vice pr ovider .
N-ser vice dat a is t he packet of dat a excha nged at an N-SAP.
N-ser vice dat a un it s (N-SDUs) ar e t he individua l un it s of da t a
excha nged a t an N-SAP (so t ha t N-ser vice dat a is made u p of N-
SDUs).
These t er ms ar e shown in Figur e 1.8. Anot her common t er m is encapsulation,which is t he
ddit ion of cont r ol infor mat ion t o a packet of dat a. The cont r ol dat a cont ains
ddressing det ail s, checksums for err or det ect ion, an d pr ot ocol cont r ol fun ct ions.
igur e 1.8. Ser vice pr ovider s and ser vice user scommunicat e t hr ough ser vice access
oint s.
Making Sense of the Jargon
t is impor t an t t o r emember t ha t al l t hese t er ms ar e used in a f or mal descr ipt ion,ecau se a formal l an guage is usua l l y t he onl y met hod t o adequat el y describe
omet hing a s compl ex as a commun icat ions pr ot ocol . It is possibl e, t hou gh, t o f it t hese
erms t oget her so t ha t t hey make a l it t l e more sense when you encount er t hem. An
xampl e shou l d hel p.
The session l ayer ha s a set of session f un ct ions. It pr ovides a set of session f acil it ies t o
he l ayer above it , t he pr esent at ion l ayer . The session l ayer is made u p of session
nt it ies. The pr esent at ion l ayer is a u ser of t he ser vices pr ovided by t he session l ayerayer 5). A pr esent at ion en t it y is a user of t he ser vices pr ovided by t he session l ayer an d
s cal l ed a pr esent at ion ser vice user .
http://d%7C/UncleVan/Current/Teach%20Yourself%20TCP-IP%20in%2014%20Days%202nd%20Edition/01tyt08.gifhttp://d%7C/UncleVan/Current/Teach%20Yourself%20TCP-IP%20in%2014%20Days%202nd%20Edition/01tyt08.gifhttp://d%7C/UncleVan/Current/Teach%20Yourself%20TCP-IP%20in%2014%20Days%202nd%20Edition/01tyt08.gifhttp://d%7C/UncleVan/Current/Teach%20Yourself%20TCP-IP%20in%2014%20Days%202nd%20Edition/01tyt08.gifhttp://d%7C/UncleVan/Current/Teach%20Yourself%20TCP-IP%20in%2014%20Days%202nd%20Edition/01tyt08.gifhttp://d%7C/UncleVan/Current/Teach%20Yourself%20TCP-IP%20in%2014%20Days%202nd%20Edition/01tyt08.gif -
8/10/2019 Tcp.ip Trong 14 Ngay.pdf
26/486
The session ser vice pr ovider is t he col l ect ion of session ent it ies t ha t ar e act ivel y
nvol ved in pr oviding t he pr esent at ion l ayer wit h t he session's ser vices. The point at
which t he session service is pr ovided t o t he pr esent at ion l ayer is t he session service
ccess point , wher e t he session ser vice dat a is sent . The individua l bit s of da t a in t he
ession service dat a ar e cal l ed session ser vice dat a un it s.
Confusing? Bel ieve it or not , aft er a whil e you wil l begin t o feel more comfor t abl e
wit h t hese t erms. The import an t ones t o know now ar e t ha t a l ayer pr ovides a set ofnt it ies t hr ough a service access point t o t he next higher l ayer, which is cal l ed t he
er vice u ser .The dat a is sent in ch un ks cal l ed ser vice dat a, made up of ser vice dat a
n it s.
Queues and Connections
Commun icat ion bet ween t wo par t ies (whet her over a t el ephon e, bet ween l ayer s of an
r chit ect ur e, or bet ween appl icat ions t hemsel ves) t akes pl ace in t hr ee dist inct st ages:
st abl ishment of t he conn ect ion, dat a t r an sfer , an d connect ion t ermina t ion.
Commun icat ion bet ween t wo OSI appl icat ions in t he same l ayer is t hr ough queues t o t he
ayer beneat h t hem. Each a ppl icat ion (mor e pr oper l y cal l ed a ser vice user ) ha s t wo
ueues, one for each dir ect ion t o t he ser vice pr ovider of t he l ayer beneat h (which
ont r ol s t he whol e l ayer ). In OSI-speak, t he t wo queu es pr ovide for simul t an eous (ortomic) int er act ions bet ween t wo N-ser vice act ion point s.
Dat a, cal l ed service primitives,is put int o and r et r ieved fr om t he queue by t he
ppl icat ions (ser vice user s). A ser vice pr imit ive can be a bl ock of dat a, an indicat or t ha t
omet hing is r equired or r eceived, or a st at us indicat or . As wit h most aspect s of OSI, a
exicon h as been devel oped t o descr ibe t he a ct ions in t hese queues:
A request primitiveis when one ser vice submit s a ser vice pr imit ive t o t he qu eue (t hr ough
he N-SAP) r equest ing per mission t o commun icat e wit h a not her ser vice in t he same l ayer .
An indication primitiveis what t he ser vice pr ovider in t he l ayer beneat h t he sending
ppl icat ion sends t o t he int ended receiving appl icat ion t o l et it know t ha t
ommunicat ion is desir ed.
A response primitiveis sent by t he r eceiving appl icat ion t o t he l ayer beneat h's ser vice
r ovider t o acknowl edge t he gr an t ing of commun icat ions bet ween t he t wo ser vice user s.
A confirmation primitiveis sent fr om t he ser vice pr ovider t o t he
fina l appl icat ion t o indicat e t ha t bot h appl icat ions on t he
l ayer above can now commun icat e.
-
8/10/2019 Tcp.ip Trong 14 Ngay.pdf
27/486
An exampl e might hel p cl ar ify t he pr ocess. Assume t ha t t wo appl icat ions in t he
r esent at ion l ayer wan t t o commun icat e wit h each ot her . They can 't do so dir ect l y
accor ding t o t he OSI model ), so t hey must go t hr ough t he l ayer bel ow t hem. These st eps
r e shown in Figur e 1.9.
igur e 1.9. Two appl icat ions communicat e t hr ough SAPs using pr imit ives.
The f ir st appl icat ion sends a r equest pr imit ive t o t he service pr ovider of t he session
ayer an d wait s. The session l ayer 's ser vice pr ovider r emoves t he r equest pr imit ive fr om
he inboun d queue fr om t he fir st appl icat ion a nd sends an indicat ion pr imit ive t o t he
econd appl ica t ion 's inbound queu e.
The second a ppl icat ion t akes t he indicat ion pr imit ive fr om it s queu e t o t he session
er vice pr ovider an d decides t o accept t he r equest for conn ect ion by sending a posit ive
esponse pr imit ive back t hr ough it s queu e t o t he session l ayer . This is r eceived by t heession l ayer ser vice pr ovider , an d a conf ir mat ion pr imit ive is sent t o t he f ir st
ppl icat ion in t he pr esent at ion l ayer . This is a pr ocess cal l ed confirmed servicebecause
he appl icat ions wait for confir mat ion t ha t commun icat ions ar e est abl ished an d rea dy.
OSI a l so pr ovides for unconfirmed service,in wh ich a r equest pr imit ive is sent t o t he ser vice
r ovider , sending t he indicat ion pr imit ive t o t he second appl icat ion. The r esponse an d
onf ir mat ion pr imit ives ar e not sent . This is a sor t of "get r eady, becau se her e it comes
whet her you want it or n ot " commun icat ion, oft en r eferr ed t o as send and pray.
When t wo ser vice user s ar e using confir med ser vice t o commun icat e, t hey a r e consider ed
onnect ed. Two appl icat ions ar e t al king t o each ot her , awar e of what t he ot her is
oing wit h t he ser vice dat a. OSI r efer s t o t he est abl ishment an d maint ena nce of state
nformationbet ween t he t wo, or t he fact t hat each knows when t he ot her is sending or
eceiving. OSI cal l s t his connection-orientedor connection-modecommunica t ions.
Connectionlesscommun icat ion is when ser vice dat a is sent independen t l y, as wit h
n conf ir med ser vice. The ser vice dat a is sel f-cont ained, possessing ever yt hing a r eceivinger vice user needs t o know. These ser vice dat a packet s ar e oft en cal l ed datagrams.The
ppl icat ion t ha t sends t he dat agr am ha s no idea who receives t he dat agr am an d how it is
a ndl ed, and t he r eceiving service users have no idea who sent it (ot her t ha n
nfor mat ion t ha t might be cont ained wit hin t he dat agr am it sel f). OSI cal l s t his
onnectionless-mode.
OSI (an d TCP/IP) use bot h con nect ed an d connect ionl ess syst ems bet ween l ayer s of t heir
r chit ect ur e. Each ha s it s benefit s an d ideal impl ement at ions. Al l t hese commun icat ions
r e bet ween a ppl icat ions (ser vice user s) in each l ayer , using t he l ayer beneat h t oommun icat e. Ther e a r e man y ser vice user s, and t his pr ocess is going on al l t he t ime. It 's
uit e amaz ing when you t hink about it .
http://d%7C/UncleVan/Current/Teach%20Yourself%20TCP-IP%20in%2014%20Days%202nd%20Edition/01tyt09.gifhttp://d%7C/UncleVan/Current/Teach%20Yourself%20TCP-IP%20in%2014%20Days%202nd%20Edition/01tyt09.gifhttp://d%7C/UncleVan/Current/Teach%20Yourself%20TCP-IP%20in%2014%20Days%202nd%20Edition/01tyt09.gifhttp://d%7C/UncleVan/Current/Teach%20Yourself%20TCP-IP%20in%2014%20Days%202nd%20Edition/01tyt09.gif -
8/10/2019 Tcp.ip Trong 14 Ngay.pdf
28/486
Standards
eopl e don't quest ion t he n eed for r ul es in a boar d game. If you didn't ha ve ru l es, each
l ayer coul d be happil y pl aying as it suit s t hem, r egar dl ess of whet her t heir pl ay wasonsist ent wit h t hat of ot her pl ayer s. The exist ence of ru l es ensur es t hat each pl ayer
l ays t he game in t he same way, which might not be as much fu n a s a fr ee-for -al l .
However, when a f ight over a pl ayer 's act ions ar ises, t he writ t en r ul es cl ear l y indicat e
who is r ight . The r ul es ar e a set of st an dar ds by which a game is pl ayed.
t an dar ds pr event a sit ua t ion a r ising wher e t wo seemingl y compat ibl e syst ems r eal l y
r e not . For exampl e, 10 year s ago wh en CP/M was t he domina nt oper at ing syst em, t he
.25-inch fl oppy was used by most syst ems. But t he f l oppy f r om a Kaypr o II coul dn 't be
ead by an Osbour ne I because t he t r acks wer e l aid out in a differ ent man ner . A ut il it yr ogr am coul d conver t bet ween t he t wo, but t hat ext r a st ep was a major ann oyance for
machine user s.
When t he IBM PC became t he pl at for m of ch oice, t he 5.25-inch for mat used by t he IBM
C was adopt ed by ot her companies t o ensur e disk compat ibil it y. The IBM for mat became
de fa ct o st an dar d, one a dopt ed because of mar ket pr essur es an d cust omer deman d.
Setting Standards
Cr eat ing a st an dar d in t oday's wor l d is not a simpl e mat t er . Severa l organ iza t ions ar e
edicat ed t o devel oping t he st an dar ds in a compl et e, un ambiguou s man ner . The most
mport an t of t hese is t he Int ern at ional Or ganiza t ion for St an dar diza t ion, or ISO (oft en
al l ed t he Int ernat ional St andardizat ion Or ganizat ion t o f it t heir acronym, al t hough
his is incor r ect ). ISO consist s of st an dar ds or gan iza t ions fr om man y count r ies who t r yo agr ee on int ern at ional crit er ion. The American Nat ional St an dar ds Inst it ut e (ANSI),
Br it ish St an dar ds Inst it ut e (BSI), Deut sches Inst it ut fu r Nor mun g (DIN), an d Associat ion
r ancaise du Nor mal iza t ion (AFNOR) ar e a l l member gr oups. The ISO devel oped t he Open
yst ems Int er connect ion (OSI) st an dar d t ha t is discussed t hr oughou t t his book.
Each nat ion's st andar ds organizat ion can creat e a st andar d for t hat count r y, of
our se. The goal of ISO, however , is t o agr ee on worl dwide st an dar ds. Ot her wise,
ncompat ibil it ies coul d exist t ha t woul dn't al l ow one coun t r y's syst em t o be used in
n ot her . (An exa mpl e of t his is wit h t el evision signa l s: t he US r el ies on NTSC, wher easEur ope uses PALsyst ems t ha t ar e incompat ibl e wit h ea ch ot her .)
Cur iousl y, t he l an guage used for most int er nat ional st an dar ds is Engl ish, even t hough
-
8/10/2019 Tcp.ip Trong 14 Ngay.pdf
29/486
he major it y of par t icipan t s in a st an dar ds commit t ee ar e not fr om Engl ish-speaking
ount r ies. This can cau se quit e a bit of conf usion, especial l y because most st an dar ds ar e
wor ded awkwar dl y t o begin wit h.
The r eason most st an dar ds invol ve awkwar d l an gua ge is t ha t t o descr ibe somet hing
n ambiguousl y can be ver y diff icul t , somet imes necessit at ing t he cr eat ion of new t er ms
hat t he st andar d defines. Not onl y must t he concept s be cl ear l y defined, but t he
bsol ut e beha vior is necessar y t oo. Wit h most t hings t ha t st an dar ds appl y t o, t his meanssing nu mber s and physical t er ms t o pr ovide a concr et e definit ion. Defining a 2x4 piece of
umber necessit at es t he u se of a measur ement of some sor t , an d simil ar l y defining
omput er t er ms r equir es mat hemat ics.
impl y def in ing a met hod of communica t ions, such as TCP/IP, woul d be fa ir l y
t r aight for war d if it weren 't for t he compl icat ion of defining it for open syst ems. The
se of an open syst em adds an ot her diff icul t y because al l aspect s of t he st an dar d must
e mach ine-independen t . Imagine t r ying t o define a 2x4 wit hou t using a measur ement your e famil iar wit h, such as inch es, or if inches ar e adopt ed, it woul d be diff icul t t o define
nches in an u nambiguous way (which indeed is wha t ha ppens, because most unit s of
engt h ar e defined wit h r espect t o t he wavel engt h of a par t icul ar kind of coherent
ight ).
Comput er s commun icat e t hr ough bit s of dat a, but t hose bit s can r epr esent cha r act er s,
u mber s, or somet hing el se. Number s coul d be int eger s, fr act ions, or oct al
epr esent at ions. Again, you must define t he u nit s. You can see t ha t t he compl icat ions
mount , one on t op of t he ot her .
To hel p define a st an dar d, an abst r act appr oach is usual l y used. In t he case of OSI, t he
meaning (cal l ed t he seman t ics) of t he dat a t r an sfer r ed (t he abst r act synt ax) is fir st
eal t wit h, and t he exact r epr esent at ion of t he dat a in t he machine (t he concr et e
ynt ax) an d t he means by which it is t r ansferr ed (t r an sfer synt ax) ar e handl ed
epar at el y. The separ at ion of t he abst r act l et s t he dat a be r epr esent ed as an ent it y,
wit hout concer n for what it r eal l y means. It 's a l it t l e l ike t r eat ing your car as a unit
nst ead of a n en gine, t r an smission, st eering wheel , an d so on. The a bst r act ion of t he
et ail s t o a simpl er whol e makes it easier t o convey infor mat ion. ("My car is br oken" isbst r act , whereas "t he power st eer ing fl uid has al l l eaked out " is concr et e.)
To descr ibe syst ems abst r act l y, it is necessar y t o have a l an gua ge t ha t meet s t he
ur pose. Most st andar ds bodies ha ve devel oped such a syst em. The most commonl y u sed is
SO's Abst r act Synt ax Not at ion One, fr equent l y shor t ened t o ASN.1. It is suit ed
special l y for descr ibing open syst ems net wor king. Thu s, it 's not sur pr ising t o find it used
xt ensivel y in t he OSI and TCP descr ipt ions. Indeed, ASN.1 was devel oped concu r r ent l y
wit h t he OSI st an dar ds when it became necessar y t o descr ibe upper -l ayer fu nct ions.
The pr imar y concept of ASN.1 is t ha t al l t ypes of da t a, r egar dl ess of t ype, size, or igin, or
ur pose, can be r epr esent ed by an object t ha t is independent of t he ha r dwar e, oper at ing
-
8/10/2019 Tcp.ip Trong 14 Ngay.pdf
30/486
yst em soft war e, or appl icat ion. The ASN.1 syst em defines t he con t ent s of a dat agr am
r ot ocol headert he chun k of infor mat ion at t he beginn ing of an object t hat descr ibes
he cont ent s t o t he syst em. (Header s ar e discussed in mor e det ail in t he sect ion t it l ed
Pr ot ocol Headers" l at er in t his chapt er.)
ar t of ASN.1 descr ibes t he l an guage u sed t o descr ibe object s an d dat a t ypes (such as a
at a descr ipt ion l an gua ge in dat abase t er minol ogy). Anot her par t defines t he basic
ncoding r ul es t ha t deal wit h moving t he da t a object s bet ween syst ems. ASN.1 definesat a t ypes t ha t ar e used in t he const r uct ion of dat a packet s (dat agr ams). It pr ovides for
ot h st r uct ur ed an d unst r uct ur ed dat a t ypes, wit h a l ist of 28 support ed t ypes.
Don't be t oo worr ied about l ear ning ASN.1 in t his book. I
r efer t o it in passing in on l y a coupl e of pl aces. It is usefu l ,t hough, t o know t hat t he l anguage is pr ovided for t he formal
definit ion of al l t he a spect s of TCP/IP.
Internet Standards
When t he Defen se Advanced Resear ch Pr oject s Agency (DARPA) was est abl ished in 1980,
gr oup was for med t o devel op a set of st andar ds for t he Int ern et . The group, cal l ed t he
nt ern et Configur at ion Cont r ol Boar d (ICCB) was r eor ganized int o t he Int ern et
Act ivit ies Boar d (IAB) in 1983, whose t ask was t o design , engineer , and manage t he
nternet .
n 1986, t he IAB t ur ned over t he t ask of devel oping t he Int er net st an dar ds t o t hent er net Engineer ing Task For ce (IETF), an d t he l ong-t er m r esear ch was assigned t o t he
nt er net Resear ch Task For ce (IRTF). The IAB r et ained fina l au t hor iza t ion over
n yt hing pr oposed by t he t wo t ask for ces.
The l ast st ep in t his saga wa s t he for mat ion of t he Int er net Societ y in 1992, when t he
AB was r ena med t he Int er net Ar chit ect ur e Boar d. This gr oup is st il l r esponsibl e for
xist ing and fu t ur e st andar ds, r eport ing t o t he board of t he Int ernet Societ y.
Aft er a l l t ha t , what ha ppened dur ing t he shu ffl ing? Al most fr om t he beginning, t hent ernet was defined as "a l oosel y or ganized int erna t ional col l aborat ion of
u t onomous, int er conn ect ed net wor ks," which suppor t ed host -t o-host commun icat ions
t hr ough vol un t ar y adherence t o open pr ot ocol s an d pr ocedur es" defined in a t echnical
-
8/10/2019 Tcp.ip Trong 14 Ngay.pdf
31/486
aper cal l ed t he Int er net St an dar ds, RFC 1310,2. Tha t definit ion is st il l used t oday.
The IETF cont inu es t o work on r efining t he st an dar ds used for commun icat ions over t he
nt er net t hr ough a nu mber of wor king gr oups, each on e dedicat ed t o a specific aspect of
he overal l Int ernet pr ot ocol suit e. There a r e working groups dedicat ed t o net wor k
man agement , secur it y, user ser vices, rou t ing, and man y mor e t hings. It is int er est ing t ha t
he IETF's gr oups ar e considera bl y mor e fl exibl e an d efficient t ha n t hose of, say, t he
SO, whose wor king gr oups can t ake year s t o agr ee on a st an dar d. In man y cases, t heETF's gr oups can f or m, cr ea t e a r ecommendat ion , and disband wit h in a year or so. This
el ps cont inuousl y r ef ine t he Int ernet st andar ds t o ref l ect changing har dwar e and
oft war e capabil it ies.
Cr eat ing a n ew Int er net st an dar d (which ha ppened wit h TCP/IP) fol l ows a wel l -defined
r ocess, shown schemat ica l l y in Figur e 1.10. It begins wit h a r equest for comment (RFC).
This is usual l y a document cont a in ing a specific pr oposa l , somet imes new a nd somet imes a
modificat ion of a n exist ing st an dar d. RFCs ar e widel y dist r ibut ed, bot h on t he n et worksel f a nd t o int er est ed par t ies as pr int ed document s. Impor t an t RFCs an d inst r uct ions
or r et r ieving t hem ar e incl uded in t he appendixes at t he end of t his book.
igur e 1.10. The pr ocess for adopt ing a newInt e r ne t st a nd ar d .
The RFC is usual l y discussed for a whil e on t he net work it sel f, wher e anyone can
xpr ess t heir opinion, as wel l as in for mal IETF wor king gr oup meet ings. Aft er a suit abl e
moun t of r evision a nd con t inu ed discussion, an Internet draftis cr eat ed and dist r ibut ed.
This dr af t is cl ose t o fina l for m, pr oviding a consol idat ion of a l l t he comment s t he RFCener at ed.
The next st ep is usua l l y a proposed standard,which r emains as such for at l east six
mont hs. Dur ing t his t ime, t he Int ern et Societ y r equir es at l east t wo independent an d
nt er oper abl e impl ement at ions t o be writ t en a nd t est ed. Any pr obl ems ar ising fr om t he
ct ua l t est s can t hen be addressed. (In pr act ice, it is usual for man y impl ement at ions t o
e wr it t en and given a t hor ough t est ing.)
Aft er t ha t t est ing an d r efinement pr ocess is compl et ed, a draft standardis wr it t en, which
emains for at l east fou r mont hs, dur ing which t ime man y mor e impl ement at ions ar e
evel oped and t est ed. The l ast st epaf t er man y mont hsis t he adopt ion of t he
t an dar d, at which point it is impl ement ed by al l sit es t ha t r equir e it .
Protocols
Dipl omat s fol l ow ru l es when t hey conduct business bet ween n at ions, which you see
http://d%7C/UncleVan/Current/Teach%20Yourself%20TCP-IP%20in%2014%20Days%202nd%20Edition/01tyt10.gifhttp://d%7C/UncleVan/Current/Teach%20Yourself%20TCP-IP%20in%2014%20Days%202nd%20Edition/01tyt10.gifhttp://d%7C/UncleVan/Current/Teach%20Yourself%20TCP-IP%20in%2014%20Days%202nd%20Edition/01tyt10.gifhttp://d%7C/UncleVan/Current/Teach%20Yourself%20TCP-IP%20in%2014%20Days%202nd%20Edition/01tyt10.gif -
8/10/2019 Tcp.ip Trong 14 Ngay.pdf
32/486
eferr ed t o in t he media a s pr ot ocol . Dipl omat ic pr ot ocol r equir es t ha t you don't insul t
our host s an d t hat you do respect l ocal cust oms (even if t ha t means you ha ve t o eat
ome u nappet izing dinn er s!). Most embassies an d commissions ha ve special ist s in pr ot ocol ,
whose fu nct ion is t o ensur e t ha t ever yt hing pr oceeds smoot hl y when commun icat ions
r e t aking pl ace. The pr ot ocol is a set of r ul es t ha t must be fol l owed in or der t o "pl ay
he game," as car eer dipl omat s ar e fond of saying. Wit hout t he pr ot ocol s, one side of t he
onver sat ion might not r eal l y under st and what t he ot her is saying.
imil ar l y, comput er pr ot ocol s define t he man ner in which commun icat ions t ake pl ace. If
ne comput er is sending infor mat ion t o anot her an d t hey bot h fol l ow t he pr ot ocol
r oper l y, t he message get s t hr ough, r egar dl ess of what t ypes of mach ines t hey ar e and
wha t oper at ing syst ems t hey r un (t he basis for open syst ems). As l ong a s t he mach ines
a ve soft war e t ha t can man age t he pr ot ocol , commun icat ions ar e possibl e. Essent ial l y,
comput er pr ot ocol is a set of r ul es t ha t coordina t es t he exchan ge of infor mat ion.
r ot ocol s ha ve devel oped fr om ver y simpl e pr ocesses ("I'l l send you on e cha r act er , youend it back, an d I'l l make sur e t he t wo mat ch") t o el abor at e, compl ex mechan isms t ha t
over al l possibl e pr obl ems an d t r an sfer condit ions. A t ask such as sending a message
r om one coast t o anot her can be ver y compl ex when you consider t he man ner in which
moves. A singl e pr ot ocol t o cover a l l aspect s of t he t r an sfer woul d be t oo l ar ge,
n wiel dy, an d overl y special ized. Ther efor e, sever al pr ot ocol s ha ve been devel oped,
ach ha ndl ing a specific t ask.
Combining sever al pr ot ocol s, each wit h t heir own dedicat ed pur poses, woul d be a
ight mar e if t he int er act ions bet ween t he pr ot ocol s wer e not cl ear l y defined. Theoncept of a l ayered st r uct ur e was devel oped t o hel p keep each pr ot ocol in i t s pl ace
n d t o define t he man ner of int er act ion bet ween each pr ot ocol (essent ial l y, a pr ot ocol
or commun icat ions bet ween pr ot ocol s!).
As you saw ea r l ier , t he ISO ha s devel oped a l ayer ed pr ot ocol syst em cal l ed OSI. OSI
efines a pr ot ocol as "a set of r ul es an d for mat s (seman t ic an d synt act ic), which
et er mines t he commun icat ion behavior of N-ent it ies in t he per for man ce of N-fu nct ions."
You might r emember t ha t Nr epr esent s a l ayer , an d an en t it y is a ser vice component of a
ayer .
When mach ines commun icat e, t he r ul es ar e for mal l y defined a nd a ccoun t for possibl e
nt err upt ions or f au l t s in t he fl ow of infor mat ion, especial l y when t he fl ow is
onnect ionl ess (no f or mal connect ion bet ween t he t wo mach ines exist s). In such a
yst em, t he abil it y t o pr oper l y rou t e and verify each packet of dat a (dat agr am) is
it al l y import an t . As discussed ear l ier, t he dat a sent bet ween l ayers is cal l ed a ser vice
at a u nit (SDU), so OSI defines t he a na l ogous dat a bet ween t wo machines as a pr ot ocol
at a u nit (PDU).
The fl ow of infor mat ion is cont r ol l ed by a set of act ions t ha t define t he st at e machine
or t he pr ot ocol . OSI defines t hese act ions as pr ot ocol cont r ol inf or mat ion (PCI).
-
8/10/2019 Tcp.ip Trong 14 Ngay.pdf
33/486
Breaking Data Apart
t is necessar y t o in t r oduce a f ew mor e t er ms commonl y used in OSI and TCP/IP, but
uckil y t hey ar e readil y un der st ood becau se of t heir r eal -wor l d conn ot at ions. These
er ms ar e necessar y because dat a doesn't usual l y exist in man ageabl e chun ks. The dat a
might ha ve t o be br oken down int o smal l er sect ions, or sever al smal l sect ions can be
ombined int o a l ar ge sect ion for mor e efficient t r an sfer . The basic t er ms ar e as fol l ows:
egmentationis t he pr ocess of br eaking an N-ser vice dat a un it (N-SDU) int o sever al N-
r ot ocol dat a un it s (N-PDUs).
eassemblyis t he pr ocess of combining sever a l N-PDUs in t o an N-SDU (t he r ever se ofegment at ion).
lockingis t he combina t ion of sever al SDUs (which might be fr om diff er ent ser vices) int o
l ar ger PDU wit hin t he l ayer in which t he SDUs originat ed.
Unblockingis t he br eaking up of a PDU int o sever al SDUs in t he same l ayer .
Concatenationis t he pr ocess of on e l ayer combining sever al N-PDUs fr om t he n ext higher
ayer int o one SDU (l ike bl ocking except occur r ing acr oss a l ayer boun dar y).
Separationis t he rever se of concat enat ion, so t hat a l ayer
br eaks a singl e SDU int o severa l PDUs for t he n ext l ayer
higher (l ike unbl ocking except acr oss a l ayer bounda r y).
These six pr ocesses ar e shown in Figur e 1.11.
igur e 1.11. Segment at ion, r ea ssembl y, bl ock ing,unbl ocking, concat enat ion, andepar a t ion.
ina l l y, her e is one l ast set of definit ions t ha t deal wit h connect ions:
Multiplexingis when sever al connect ions ar e suppor t ed by a singl e conn ect ion in t he next
ower l ayer (so t hr ee pr esent at ion service connect ions coul d be mul t ipl exed int o a
ingl e session con nect ion).
Demultiplexingis t he r everse of mul t ipl exing, in which one conn ect ion is spl it int o severa l
onnect ions for t he l ayer a bove it .
http://d%7C/UncleVan/Current/Teach%20Yourself%20TCP-IP%20in%2014%20Days%202nd%20Edition/01tyt11.gifhttp://d%7C/UncleVan/Current/Teach%20Yourself%20TCP-IP%20in%2014%20Days%202nd%20Edition/01tyt11.gifhttp://d%7C/UncleVan/Current/Teach%20Yourself%20TCP-IP%20in%2014%20Days%202nd%20Edition/01tyt11.gifhttp://d%7C/UncleVan/Current/Teach%20Yourself%20TCP-IP%20in%2014%20Days%202nd%20Edition/01tyt11.gifhttp://d%7C/UncleVan/Current/Teach%20Yourself%20TCP-IP%20in%2014%20Days%202nd%20Edition/01tyt11.gifhttp://d%7C/UncleVan/Current/Teach%20Yourself%20TCP-IP%20in%2014%20Days%202nd%20Edition/01tyt11.gif -
8/10/2019 Tcp.ip Trong 14 Ngay.pdf
34/486
plittingis when a singl e connect ion is suppor t ed by sever al connect ions in t he l ayer
el ow (so t he dat a l ink l ayer might have t hr ee connect ions t o support one net wor k
ayer conn ect ion).
Recombiningis t he r ever se of spl it t ing, so t hat severa l
connect ions ar e combined int o a singl e one for t he l ayer above.
Mul t ipl exing a nd spl it t ing (and t heir r ever ses, demul t ipl exing a nd r ecombining) ar e
iffer ent in t he man ner in which t he l ines ar e spl it . Wit h mul t ipl exing, sever al
onnect ions combine int o one in t he l ayer bel ow. Wit h spl it t ing, however, one
onnect ion can be spl it int o sever al in t he l ayer bel ow. As you might expect , each h as
s impor t ance wit h in TCP an d OSI.
Protocol Headers
r ot ocol cont r ol infor mat ion is infor mat ion about t he dat agr am t o which it is
t t ached. This infor mat ion is usua l l y assembl ed int o a bl ock t ha t is at t ached t o t he
r ont of t he dat a it accompan ies an d is cal l ed a headeror protocol header.Pr ot ocol
eaders ar e used for t r an sfer r ing infor mat ion bet ween l ayers as wel l as bet ween
mach ines. As ment ioned ear l ier , t he pr ot ocol hea ders ar e devel oped accor ding t o r ul es
a id down in t he ISO's ASN.1 document set .
When a pr ot ocol header is passed t o t he l ayer beneat h, t he dat agr am incl uding t he
ayer 's header is t r eat ed as t he ent ir e dat agra m for t hat r eceiving l ayer , which adds it s
wn pr ot ocol header t o t he fr ont . Thus, if a dat agra m st ar t ed at t he appl icat ion l ayer ,
y t he t ime it r eached t he physical l ayer, it woul d have seven set s of pr ot ocol headers
n it . These l ayer pr ot ocol headers ar e used when moving back up t he l ayer st r uct ur e;
hey ar e st r ipped off as t he dat agr am moves up. An il l ust r at ion of t his is shown in Figur e
.12.
igu r e 1.12. Adding each l ayer ' s pr o t oco l header t o u se r d at a .
t is easier t o t hink of t his pr ocess as l ayer s on an onion. The inside is t he dat a t ha t is t o
e sent . As it passes t hr ough ea ch l ayer of t he OSI model , an ot her l ayer of onion skin is
dded. When it is finished moving t hr ough t he l ayer s, severa l pr ot ocol hea ders ar e
ncl osing t he dat a. When t he dat agr am is passed back up t he l ayer s (pr obabl y on
not her machine), each l ayer peel s off t he pr ot ocol header t hat cor r esponds t o t he
ayer . When it r eaches t he dest inat ion l ayer , onl y t he dat a is l ef t .
This pr ocess makes sense, becau se each l ayer of t he OSI model r equir es diff er ent
nfor mat ion fr om t he dat agr am. By using a dedicat ed pr ot ocol header for each l ayer of
he dat agr am, it is a r el at ivel y simpl e t ask t o r emove t he pr ot ocol header, decode it s
http://d%7C/UncleVan/Current/Teach%20Yourself%20TCP-IP%20in%2014%20Days%202nd%20Edition/01tyt12.gifhttp://d%7C/UncleVan/Current/Teach%20Yourself%20TCP-IP%20in%2014%20Days%202nd%20Edition/01tyt12.gifhttp://d%7C/UncleVan/Current/Teach%20Yourself%20TCP-IP%20in%2014%20Days%202nd%20Edition/01tyt12.gifhttp://d%7C/UncleVan/Current/Teach%20Yourself%20TCP-IP%20in%2014%20Days%202nd%20Edition/01tyt12.gif -
8/10/2019 Tcp.ip Trong 14 Ngay.pdf
35/486
nst r uct ions, an d pass t he r est of t he message on. The al t ern at ive woul d be t o have a
ingl e l ar ge header t hat cont ained al l t he informat ion, but t his woul d t ake l onger t o
r ocess. The exact cont ent s of t he pr ot ocol header a r e not import an t r ight now, but I
xamine t hem l at er when l ooking at t he TCP pr ot ocol .
As usua l , OSI ha s a for mal descript ion for al l t his, which st at es t ha t t he N-user dat a t o
e t r an sfer r ed is pr epended wit h N-pr ot ocol cont r ol inf or mat ion (N-PCI) t o for m an N-
r ot ocol da t a unit (N-PDU). The N-PDUs ar e passed a cr oss an N-ser vice a ccess poin t (N-AP) as one of a set of ser vice par amet er s compr ising an N-ser vice da t a unit (N-SDU). The
er vice par amet er s compr ising t he N-SDU ar e ca l l ed N-ser vice user da t a (N-SUD), which
s pr epended t o t he (N1)PCI t o for m anot her (N1)PDU.
or every s