NGHIÊN CỨU VÀ XÂY DỰNG MỘT SỐ ỨNG DỤNG DỰA TRÊN MOBILE AGENT
LÊ ĐÌNH DUY
Trang nhan đề
Mục lục
Mở đầu
Chương1: Tổng quan về Mobile Agent.
Chương2: Phân tích hệ thống Mobile Agent.
Chương3: Xây dựng ứng dụng dựa trên Mobile Agent.
Chương4: Các vấn đề về an toàn khi triển khai ứng dụng dựa trên Mobile Agent.
Kết luận
Tài liệu tham khảo
27 trang |
Chia sẻ: maiphuongtl | Lượt xem: 1811 | Lượt tải: 0
Bạn đang xem trước 20 trang tài liệu Luận văn Nghiên cứu và xây dựng một số ứng dụng dựa trên mobile agent, để xem tài liệu hoàn chỉnh bạn click vào nút DOWNLOAD ở trên
CHUaNG 2
PHAN TicH HE THONG MOBILE AGENT. .
H~th6ngmobileagentbaag6mhaithanhph§nchinhdola cacmobile
agentvamoitntangh6trQvi~cthihanhchung,t~mgQiIa moiWongthi
hanh.MQtmoitntangthihanhc§nphiiiGaplingcacyellc§usail:
.:. Qwin11vah6trQvi~cthihanhcuacacmobileagent,chophepnhi~u
agentclingt6nt~iva thihanhd6ngthai,clingca'pcacdichV\l troy
C?Pdentainguyencuah~th6ng.
.:.H6 trQchoHnhdi dQngcuacacmobileagent:chophepdungcac
mobileagentdangtht!chi~nvagii'inodenmoiWongthihanhkhac,
clingnhu'nh?nv~vachophepthihanhtrdl~icacmobileagentden
tumoitntangthihanhkhac.
.:.H6 trQchovi~clien l~cva traod6i giii'acacagent:chophepcac
agentgii'idi vanh?nv~cacthongdi~ptucacagentkhac,...
.:.Baodamantoanchocacagenttrongmoi Wong clingnhu'cactai
nguyencuah~th6ng.
I. MOBILE AGENT vA MOl TRUONG THI HANH
1.Mobileagent
Mobileagentla mQtht!cth€ conamthuQcHnh: tr~ngthai,matillhanh,
giaodi~n,dinhdaub,vacacthanchu(ngu'aiuyquy~n).Khi mQtagentdi
chuy€ntrenm~ngno semangtheocacthuQcHnhnay.
20
.:.TrlJ-ngthai:c~nchoagenttht!chi~nITahilicacthaolac sankhi di
chuy6n.
.:.Mil caidijt:c~nchocacagentthih~lllhdQcl~pvdi vi trL
.:.Giaodi?n:c~nchost!lien lc;lCgiii'acacagent.
.:.Dinh danh:c~nchovi~cnh~ndi~nva dinhvi cac agentkhi di
chuy6n.
.:.Thanchit:c~nchovi~cxac dinhquy~ntroyc~pva sa d\lngtai
nguyen.
Cae thanehu
Giaodi$n
Me eaidQt
TrQngthai
Dinhdanh
Hinh2.1- Cac thuQctfnhcua mobileagent
1.1.Tr(lngthai
KhimQtagentdi chuy6n,no c~nphaimangtheotrc;lngthaicuano di
cling.Dayla d~cdi6mcuah~uhe'ta'tcacacmobileagentd6coth6tie'n
hfmhtht/chi~nlc;licacthaolacamaydfch.
Trc;lngthaicua agenttc;liba'tki thai di~mnao la mQtth6 hi~ncua qua
trinhthihanhcua no. D6i vdi h~uhe'tngonfigii'l~ptrinhchungta co th6
chiatrc;lngthaicuaagentthanhtrc;lngthai thi hanhva trc;lngthaid6i tu'<;1ng.
21
Tr~ngthaithihanhg6mcacbQde'mchu'dngtrInh,tlOOtr~ngnganxe'p;
tr~ngthaid6itu'Qng6mgiatricuacacbie'nth~hi~ntrongd6itu'Qng.
1.2.Mil cai dij,t
Gi6ngOOu'b§t kl chu'dngtrlOOmaytiOOnaokhac,mQtmobileagentcffn
phaico madS thi hanh.Khi di chuySn,no co th~l1.fachQnho~cla mang
theomathihanh,ho~cla de'nmaydkhr6ixemdacomathihanht~ido
chu'a,ne'uchu'athltiii cacmaconthie'uv~.
Ma cuaagentphaivuacothSthlfChi~ndu'Qct~imaydkh vaphaivua
anloanchomaynaykhi thihaOO.Cac ngonngii'thongdichva kichban
hi~nnaynhu'Java du'ara mQtcd che'an loan, chopheph~nche'vi~ctruy
c~pWi cactai nguyendaOOrieng cua may.Di~u nay th1.fchi~ndu'Qcdo
m6itru'ongthihaOOdQcl~pvoi h~n~nclingOOu'du'QckiSmsoarch~tche.
1.3.Giaodifn
£>Scaeagentvacach~th6ngkhactu'dnglacvoi no,agentcffnphaico
m<)tgiaodi~n.Day la cacphu'dngthlicchophepcacagentva caclingd1;lng
khactroyc~pde'nagenthaychophepcacagentlienl~cad~ng"ngonngii'
agent"OOu'laKQML (KnowledgeQueryandManipulationLanguage).
KQML la mQtngonngii'chovi~clienl~cgiii'acacagent.KQML du'ara
nhi~ukiSuthongdi~p.CackiSuthongdi~pnayco thSgiupdo cacagent
xii'11cacyellcffucuachung.KQML vacuphapclingnhu'ngii'nghIacuano
t6nt~iamuctrencdsah~tffnglien l~cgiii'acacagent.
22
1.4.Binh danh
MQiagentco mQtdinhdanhduynha'trongsu6tthaigians6ngcuano.
Cacagentcftnco cacdinhdanhd€ chungco th€ dll'Qcnh~nbi€t va dll'QC
dinhvi quacac dichVl;l,VI dl;lnhll'dichVl;lthll'ml;lc.MQtdinhdanhco th€
duQcke'thQptudinhdanhcuathanchuva mQtmasO'.Bdi VI cacdinhdanh
cuaagent1aduy nha'txet trenloan cl;lCva kh6ngth€ thayd6i, lien no co
th€ duQcdungnhll'1amQtkhoatrongcac thaolac doi hoi thamchi€u Wi
ffi(>tth€ hi~nCl;lth€ agent.
1.5.Caethanehil
Thanchu1athl!Cth€ mamanh~nd(;lngcua no dll'Qcdungd€ xac nh~n
cacquy~nh(;lnkhi agentmuontroyc~Ptoi ba'tcu h~thongnaG.Than chu
coth€ 1affiQtca nhan,mQtt6 chuc,haymQtc6ngty, ...Ma nh~nd(;lngbaa
g6mtenva cacthuQctfnhco th€ khac.E>6ivoi cac agentta tha'yno co It
nha'thaithanchu:
.:.TaeKia: ngll'aiclingca'pcaid~tagent.
.:.Chilsdhilu:ngll'aicotrachnhi~mphap19vad(;loducchocachanh
. ?
VIcua agent.
2.M6itnidngthihanh
fHychinh1andimaagent6nt(;litrongsu6tchuki s6ngcuano.No cling
coth€duqcxemnhll'ladi€m VaGchocacagent"khach"(cacagentd€n tu
cacmaykhac)mu6nthihanh.M6i tru'angthihanhclingca'pt~pcacdichVl;l
gi6ngnhaud€ agentco th€ dlfatrendo mathihanhba'tk€ no d dau.Ta co
23
th€ xemmoitru'ongthihaOO0011Ia "h~di~uhaOO"choagent.B6n khai
ni~msaildongvai troquailtrQngtrongcacmoi tru'ongthihanh:
.:.Bl)ngcd:mayaoph\lcV\lchome>thaynhi~umoitru'ongthihaOO.
.:.Caengudn(cdnguyen:cac cd sd dii' li~u,be>xu 11,va cac dich V\l
khacd11<;1cclingcftpbdimaydo.
.:.Vi tri: diachim<;lngcuamoitru'ongthihaOO.
.:.Caethanchu: th1/cth~chill trachOOi~mphap11chocacthaolac cua
moitru'ongthihanh.
2.1.Bl)ngcd
Caemoitr11ongkhongth~t1/nothihanhcacagent.D~lamdi~udo,cac
agentphait6nttde>ngcd.De>ngcdnaydingclingcftpchocac
moitntongthihanhva cacagentOOunglien kC"tdi dng m<;lngnamd11diva
caetainguyenkhac ma may do cling cftp.Trong mo hlnhnay, de>ngcd
mangy nghiala la me>tth1/cth~v~t11hdnme>tkhai ni~mlogic.Trongh~
th6ngmobileagentd1/atrenJava, de>ngcd co th~d6ngnhfttvdi may ao
Java(JavaVirtualMachine- JVM) vah~di~uhanh.
MQtmaytfnhtrongmngcd,m6i de>ngcd co
th€ quail11OOi~umoi tru'ongtill haOO,va m6i moi tru'ongthi haOOco th~
qmlnIf nhi~uagent.Do me>tde>ngcdco th~chuaOOi~uhdnme>tmoi tru'ong
tillhanhnendoihoi cacmoitru'ongthihanhphaico tenduynhftttrongme>t
dQnged.
24
Trongm9ts6h~th6ngmobileagentco thekhongco khaini~mmoi
tntongthih~lllhr(;lchroi.Trongnhii'ngh~th6ngnhu'v~y,co thexemchfnh
caed9ngcd Ia m9td(;lngmoitru'ongtill hanh.
Maytinh
Tai
nguyen
MoitrLlang
thihanh
Hlnh2.2- M6i lienh$ giGam6itrLlangthihanhva dQnged
Cae dQng ed
Cae m6i trLlang
thihanh
CaeAgent
Hlnh2.3- M6hlnhella m6itrLlangthihanhagent
2.2.Caengudntid nguyen
D9ngcdvamoitru'ongthihanhclingca'pvi~ctroyc~p(coIdemsoat)
toicactainguyenvadichVl;!Cl;!Cb9nhu'la caccdsCJdii'li~u,cacb9xi't11
vab9 nho,cac<5ilia,va cacdichVl;!phftnclingclingnhu'phftnm~mkhac.
25
2.3.Vitri
Vi tr!la mQtkhaini~mquailtrQngdO'ivoimobileagent.Vi trfcuamQt
agentla st!ke'th<;1pgiuatenmoitntongmanothihanhtrongdovadiachi
m(;lngcuadQngcd matrongdo moi truongthi hanht6nt~i.Vi trf nay
thu'ongdU<;1cvie'tduoid(;lngmQtdiachiIP ke'th<;1pvoimQtportcuadQngcd
vavditencuamoitru'ongthihanh.
2.4.Caethanchit
ClinggiO'ngnhuagent,m6itru'ongthihanhclingcohaithanchu,dola :
ngu'oiclingca'pcaid~t,vanguoidieuhanhm6itrUong.
" " ??
II. CAC THAO TAC c(j BAN CUA MOBILE AGENT
1.1Qova hUymQtmobileagent
Haithaolaccdbannha'trongchukl sO'ngcuamobileagentdola t(;lOra
vabuybono.
MobileagentdU<;1ct(;loratrongmQtm6i tntongthihanhnaGdo.Vi~ct~o
naycoth~dU<;1cyell cftuho~cbdi mQtagentn~mtrongclingm6i tru'ongthi
hanhho~cbdi mQtagentkhac.Nguoi t~ophai dU<;1cmoi tntongxac nh?n
chophep,d6ngthai thie'tI?p cac quyenva cac nhi~mV\l du<;1cuy quyen
maagentmoisexii'lf.Nguoit~oding co th~clingca'pcacthallisO'khdi
dQngchoagent.CacdinhnghlalOpcftnchovi~ckhdit~oagentcoth~co
trenmayC\lCbQhaymayd xa,hayne'ucftn,co th~du<;1cclingca'pbdi
ngu'oit~o.Vi~ct~obaag6mbabuoc:
26
.:.Hifn th1/ccacdol tli(1ngvagandinhdanh:cacdli d~tcuaWpd6i
tuQngduQcnt;lpva thihanh,d6itu'QngagentduQckhditt;lo.Lop d6i
tuQngagentdinhnghlacagiaotie'pvacaid~tcuaagent.Saildo,moi
tru'angthihanhsegallchoagentmQtdinhdanhduynha't.
.:. Khdi tq.o:agentduQcpheptlfkhdi tt;lObiingcachsad1;lngcacthams6
khdi dQngduQcclingca'pbdi nguaitt;lo.Chi khi naGvi~ckhdi tt;lOdff
duQchoanthanh,agentmoiduQcxemnhula t6ntt;li.
.:. Thi hanh t1/trj: sail khi duQcxemla t6ntt;li,agentbat dftuvi~cthi
hanhcuano.Gia daynocokhaDangthihanhdQCl~pvoi cacagent
khactrongclingmoitru'angthihanh.
Hftuhe'tcacagentbi buytrongmQtmoitru'angthihanhnaGdo.Vi~c
buyco th~duQckhdixuongbdichfnhno haybdi agentkhacniimtrong
cungmoitru'angthihanh.MQtagentclingco th~bi buybdih~th6ngVI mQt
trongcac 11do sail :
.:. He'tthaigiancuachuki s6ng.
.:. Khongconsadl;lngVIkhongai thamchie'ude'nhaysad1;lngagent.
.:. Xam pht;lmslfantOaD.
.:. H~th6ngdangshutdown.
Vi~cbuyffiQtagentla mQtquitrlnhg6mhaibuoc:
.:.Chuilnhi chovifChuy:agentduQcthongbaavaduQCphepke'tthuc
cactrt;lngthaihi~nhanhcuanoWoc khibihuy.
.:.Binh chithihanh:moitru'angdinhchivi~cthihanhcuaagent.
27
2.S'idichuy~ncua mobileagent
Quatrlnhdi chuy~nco th~du'Qcyeticftubdi chinhagenthaybdi cac
agentkhactrongcungmoitru'ongthi h~mh.Saudo,moitru'ongthi hanh
hi~nhanh(moitru'ongthihanhngu6n)chuaagentsegii'iagentdi toimoi
tru'ongthihanhdfchdffdinhtru'oc.
Moi tru'ongthihanhngu6nva moitru'ongthihanhdfchseqwln11tie'n
trlnhgii'iagent.Khi moitru'ongthihanhngu6nlienl~cdu'Qcvoimoitru'ong
tillhanhdfch,moitru'ongihihanhdfchcoth~ho~cdaplingho~ckhongdap
lingyeticftudi chuy~n.Trongtru'onghQpkhongdaplingdu'Qc,moitru'ong
thihanhdfchtnl v~tinhi~u16ichomoitru'ongthihanhngu6n.Ne'umoi
tru'ongthihanhngu6nkhongth~lienl~cdu'Qcvoimoitru'ongthihanhdfch,
nophaitrav~tinhi~u16ichoagent.
2.1.Gui di mQtagent
KhimQtmobileagentchu§nbidi chuy~n,nophaicokhanangxacdinh
dfchd6ncuano.Ne'umoitru'ongthihanhdfchkhongdu'Qcxacdinh,agent
sethihanhtrongmoitru'ongthihanhm~cdinhcuah~th6ngagentdfch.
MQtkhivi trfcuadfchdu'Qcxacminh,mobileagentbaachoh~th6ngagent
chlianor~ngno mu6ndi chuy~nWi h~agentdfch.Thongdi~pnaydu'Qc
chuy€ntie'pquamQtgiaodi~nnQibQgiuaagentvah~agent(vi dl;!goO).
KhimQth~agentnh~nyeticftudichuy~ncuaagent,noselamnhu'sau:
.:.Dungagent:agentdu'Qcanhbaav~vi~cdi chuy~ns~pxayra va
du'QCphephoanthanhlac vl;!hi~nhanhcuano,Khi di~unaythl!c
hi~nxong,sl!thihanhcualu6ngcuanobi treo.
28
.:.fJanh dilu trg,ngthaiagent:tr~ngthaiva caclop dO'itttQngagent
duQcdanhda'ubdidQngcd.Bay la tieDtrinht~oramQth~hi~nnha't
qUailcuadO'ituQngagentd~co th~duQcmangdi trenm~ng.
.:.Mil hoaagent:dQngcdmahoaagentdaduQcdanhda'uvoi giaothuc
di chuy~nduQcchQn.
.:.Di chuyln agent:dQngcd thietl~pket n6i voi dkh va chuy~nagent
daduQcmahoadi.
2.2.Nhqnvi mQtagent
Truockhid9ngcdnh~nv~mQtagent,nophclixacdinhno coth~cha'p
nh~nagenttrmaygll'idi haykhong.Chi saukhinguoigll'iduQcxacnh~n
thanhcongt~idQngcdnh~n,vi~cchuy~ndii'li~umoitht!cst!xclyra :
.:. Nhqn vi agent:khi dQngcd dkh d6ngychuy~n,agentduQcmahoa
seduQcnh~nv~.
.:. Gilli mil agent:d9ngcdgiclimadongdii'li~ude'n.
.:. Khoi phy,cagent:th~hi~nnha'tqUailcuaagentsaukhi danhda'use
duQckhoiph~cl~i.Cac lOpd6i tuQngagentduQchi~ntht!c,tr~ngthai
cuaagentduQckhoiph~c.
.:.Tai thi hanhagent:agenthongbaovi~cde'ncuanot~imoitruong
thihanhdkh. BaygiOnocoth~chuftnbi d~tie'pWcl~ist!thihanh
cuanova duQCca'pmQtlu6ngthihanhmoi.
2.3.Di chuyln lfJpdOltti(Jngagent
Agentkhongth~tiept~cl~ivi~cthihanht~idQngcddkh makhongco
caclOpcuano.Co mQtsO'phudngand~lamcholOpnayco sanchodQng
cddich,tily thuQCvaovi tri cualOp:
29
.:.liJp Ill-idick:ne"umQtlopdffco sant<;lidkh,ho~ctrongvimgd~m
lopcuadQngcdho~ctrongh~th6ngt~ptinC1;lCbQ,thlkhongcftndi
chuy€nlOp.Cac agentduQcchuy€nchicftnchuathongtin doi hoi
xacdinhcaclOpnhulatendftyducualopvabQphangiai.No cling
coth€ chuathemthongtinmotavi tricuadinhnghlalOp.
.:.LfJpIll-ingu6n:ne"ulOpduQcd~tt<;lingu6n,dayla tru'onghQpthuong
g~p,noco th€ d~dangduQcchuy€n voi tr<;lngthaicuaagenttoi dQng
cddkh. Tuy nhienfa co nh~nxet r~ng:caclOptrongluQcd6 nayco
th€ d~dangdi chuy€n toi dQng.cddkh nhi€u hdnmQtIftn,co th€ lam
tangtai m<;lngva tangphiduongtruy€n cuam<;lng.
.:.Mil lap lily vi khi can: trongtru'onghQpnay,lOpco sant<;limQt
serverva dQngcddkh co th€ Iffy lOpt<;limQtdQngcdnaGdo tren
m~ng.Chli Y r~ngdQngcd dkh trongtru'onghQpnayphai th1!chi<%n
themmQtke"tn6i m<;lngd€ Iffy lOp.
Ngltoigw Ngltoinh{ln
I'
It
I
Mc;mgmay tfnh
Hinh2.4- Sl)di chuy4n clIa agent
30
Sailkhi agentdu'qckhdit';10,no thu'ongt';10ra cacd6i tu'qngkhac.R5
rang,caclapcuacacd6itu'qngnaycftnchovi~ckhdit';10vathihanhtie'p.
Neuba'tklldp naotrongsO'naykhongco sant';1idQngcddich,no phai
du'Qcchuy€nho~ctirngu6nho~ctu ngu'oigii'iagent.(j daytaco slfchQn
llfacacphu'dnganchovi~cchuy€ncaclapphl,l:agentco th€ quye'tdinh
ho~cmanghe'tcaclapcftnthie'trongmoitru'ongthihanhbandftuhaycac
lopphl,lcoth€ du'qcmangtheotliyyellcftu.
May phl,!cvI,!
Dich
(Classcode)
(c)
Nguon
/~~ '....
t Agent \/' ~
ClassCode
(b) (a)
Hinh2.5- OJehuyencae lopagent
III. TRAO DC)},LIEN L~C GIUA CAC MOBILE AGENT
Cacagentcoth€ lienl';1cvdicacagentkhactrongclingmQtmoitru'ong
thihanhhayvdi cacagentd trongcacmoi tru'ongthi hanhhanhkhac
(nhu'ngclingco th€ n~mtrongclingmQtdQngcd).MQtagentco th€ yell
cftumQtphu'dngthl1cuamQtagentkhachaygii'ichono mQtthongdi~p
31
n€u nodu'Qctiy quy~nchophepd€ lam vi~cnay.Thongthu'ong,vi~ctrao
d6ithongdi~pgiua cac agentco th€ la m9t- m9thaym9t- nhi~u.Ki€u
truy€nthongdi~pm9t- nhi~uchophepm9tagentgli'im9tthongdi~pWi
ffiQtnhomcac agentdangki va la m9t cd che'huu hi~utrongh~th6ng
nhi€uagent.
NgVoiQui NgVoinhQn NgVoi Qui NgVoi nhQn NgVoi Qui NgVoi nhQn
ThOngdi~pgliingay ThOngdi~pgltisau ThOngdi~pglii mQtchh3U
Hlnh2.6- Caeki4utruyenthongdi$p
Vi~ctraod6i,lien l~cgiuacacagentco th€ di~nra rheabaki€u sail :
? ,
.:.ThongdifjJgmngay(Now-typemessaging):dayJa kiclJ tIlJyenthong
di~pdu'Qcdungthongdl;lngnha't.M9tthongdi~pgli'ingayla d6ngb9
va lamcantrdslf thihanhchotdi khi ngu'oinh~nthongdi~phoan
thanhvi~cxli'11thongdi~pvah6iaml~ichono.
.:.ThongdifPginsau(Future-typemessaging):m9tthongdi~pgli'isail
la khongd6ngb9vakhongcantrdvi~cthihanhhi~nhanh.Ngu'oi
gU:igill mQt"the bai" co th€ duqc duI\~d€ n.h~n.k€t ,\ua..Do n.~uoi
gli'ikhongphaichochoWi khi ngu'oinh~nh6i dapva gli'ih6i am,
32
ki~utruy€nthongdi~pnaylinhdQngvala d~cbi~thUlllchkhinhi€u
agentlienlc;tcvoinhau.
.:.ThongdifPgia ml)tchilu (One-way-typemessaging):mQthongdi~p
gii'imQtchi€u la khongd6ngbQva khonglamcantrd sl! thihanh
hi~nhanh.Nguoigii'isekhonggifi'lc;ti"thebai"d~xii'11thongdi~p
nay,vanguoinh~nsekhongc~nphaih6iamlc;ti.Ki~utruy€nthong
di~pnaythu~nti~nkhihaiagentduqctie'nhanhcuQctraod6ibang
ke'tn6i khongduqcduytrllien tl;lc.Luc nayagentgii'ithongdi~p
khongc~nba'tkl h6iamnaotli'agentnh~nthongdi~p.
IV.JAVA vA CAC Ht MOBILE AGENT
1.Cae di~mthuQnlc;1icua Java khixcy dtjngmobileagent
Javala mQtngonngfi'l~ptrlnhhuangd6ituqngvathanthuQcvoi mc;tng.
C6th~noiJavala mQtphudngti~nhoanhaochomobileagent.Saudayla
mQtsO'd~ctinhcuaJava minhhQachonh~ndinhnay:
1.1.Dl)clijpviiihf nln
Javaduqcthie'tke'd~thihanhtrongcacmoitru'ongkhongd6ngnha't.
E>~IDQtlingdl;lngJavaco th~thihanhba'tcli datitrongmc;tng,trlnhbien
dichphatsinhkie'ntructrungl~pbytecoded6il~pvoimangu6nkhongth~
mangchuy~n.D~manaycoth~thihanhtrenmQtmaynaodo,h~th6ng
tillhanhJavaphait6ntc;ti.Javala ngonngfi'dQcl~pvdicacd~ctinhcuah~
n~n.Cacki~udfi'li~unguyenthuyduqcdinhnghlamQtcachch~tcheva
khongphl;lthuQcvao bQxii'11hayh~di€u hanhbell duoi.Ngay ca cacthu
vi~ncling la cac ph~ndQcl~pvoi h~di€u hanh.Vi dl;l,thu vi~ncii'as6
33
cungca'pmQtgiaoti€p donghincuagiaodi~nd6hQadQcl~pvoih~dieu
h~mhbell duoi.No chophepchungtat~ocacmobileagentma khongcfin
bie'tloc:LimayHnhmanosethihanhtrendo.
1.2.Thi hanh an toan
JavadU<;1cdungchoInternetva cacintranet,dodo yell cfiuve Hnhan
loandaanhhuangd€n thi€t ke'theonhieucachoVi dl;l,Java co mQtmo
hinhcontro bQnho giup.loc:Litru cac kha Dangxamphc:LmbQnho va lam
hOngdii'li~u.Java khongchophepvi~cchuy€n ki€u ba'th<;1pl~hayba'tki
phepto£lnsf)hQcnaotrencontro.Cac chuangtrinhkhongth€ gia mc:Lotroy
c~ptdidii'li~uriengtrongcacdoi tu<;1ngmachungkhongco co quyentruy
c~p,dieunaygiupnganch~nnguycdvirus.Th~mchine'uco nguoixam
phc;tmvoibytecode,h~thongthihanhcuaJavav~nch~cdingmanayse
khongcokhaDangxamphc:Lmcacngii'nghlacuaJava.
Javaclingco mQttrlnhquail11sl/ anloan d€ kiSmtra loan bQcacthao
tackh6nganloan tiemfin,vi dl;lnhutroyc~pt~ptin hayke'tnf)imc:Lng,dS
xacdinh chuangtrlnhdo dU<;1cphepthi hanhcacthaolac nay haykhong.
N6ichung,kie'ntrucanloancuaJava lam chono du anloan d€ ki€m soat
caeagentkhongtinc~y,bai vi nokhongth€ canthi~pvaocacmayphl;lC
Vl;!haytroyc~pcacthongtindaubrieng.
1.3.Tai [updQng
Cdch€ tai lOpdQngchophepmayaon~pvadinhnghlacaclop trong
.>'
hIethih~lllh.No clingca'pmQtkhonggiantendU<;1cbaav~chom6i agent,
14
dodochophepcacagenthihanhanloanvadQCl~pvoinhungagentkhac.
Cdche'tiii lOpmdrQngdll<;1cchophepcaclopdl1<;1ctiii quam~ng.
1.4.L4P trinh daluiJng
Cacagentla tlftri:nghIala agentcoth€ thihanhdQcl~pvoi cacagent
khacclingt6nt~itrongm6itrttongthihanh.Chophepm6iagenthihanh
tronglu6ngcuanola mQtcachchophepcacagentcokhiinangtlflingxU'.
1.5.Danh diiu dol tlit/ng
MQttinhchfttquailtrQngcuamobileagentdo la chungco th€ dl1<;1cdanh
da'utr~ngthaihi~nhanhva kh6iphl;lCl~itr~ngthaidadanhdftu.Java cling
ca'pmQtcd che'danhda'ura'tthu~nti~ndl1<;1cxay dlfngsand€ co th€ bi€u
di~ntr~ngthaicuamQtd6i tl1<;1ngdl1oid~ngtu§ntlf hoadu chi tie'tsaocho
doitu'<;1ngco th€ tai kie'ntrucl~isaunay.D~ngtu§ntlf hoacua d6i tl1<;1ng
phaicokhanangxacdinhcaclOpJavamatudocactr~ngthaicuad6i
tu'qngdl1<;1cIttul~iva khii nangphl;lCh6i tr~ngthaitrongmQtth€ hi~nmoi.
Cacd6i tl1<;1ngthl1ongthallichie'ude'ncac d6i tl1<;1ngkhac.D€ duytrl cftu
trucd6i tl1<;1ng,hungd6i tl1<;1ngkhacnayphiii dl1<;1clttutm va kh6i phl;lC
clingmQtluc. Khi mQtd6i tl1<;1ngdl1<;1clttutrU,tfttcii cacd6i tll<;1ngtrongd6
thico th€ troy c~pdl1<;1ctu d6i tl1<;1ngdo cling dl1<;1clttutill.
2.MQtsohQnchecua Java
M~cdli ng6nnguJavarfttthichh<;1pchovi~ct~ocacmobileagent,tuy
nhiennovftncomQtso'nhl1<;1cdi€m danglttuy.MQts6trongchungcoth€
du'<;1ckh~cphl;lC;nhungcaikhacquailtrQnghonva co lienquailde'nthie't
ke'quailni~mvaphattri€n t6ngth€ cuacach~mobileagentdlfatrenJava.
35
2.1.Thituhgtr(1kiim soulngudntainguyen
NgonnguJavakhongclingca'pcacphu'dngti~nchochungtaki~msoat
cactainguyendu'cJcdungbdimQtd6itu'cJngJava.VI dl;l,mQtagentcoth~
chi€mbQxli'11,va chie'mtainguyenbQnhob~ngcachkhongtlf giai phong.
HaiVI dl;lnay lien quailde'nmQtd(;lngCl;lth~cuata'ncongslf anloan du'cJC
gQila phahongdichVl;ln~n.MQttrongnhunglo(;lita'ncongdangscJnha'ttu
mobileagentdo la: cac agentdi chuy~nthanhdan vao mQtmay tinh va
chi€mta'tca cactai nguyencuano, lamchongu'oidi~uhanhkhongth~
ki~msoatdu'cJcmaytinh.Javakhongclingca'pcachnaochomaytinhd~
gioih(;lntai nguyenCPU va bQnhodu'cJc a'pphatchomQtd6i tu'cJnghay
lu6ng.
MQtva'nd~khaclien quailthlfCslfVu'cJtquat~mJava la khanangagent
ca"phattai nguyen ngoai chu'dngtrinh,VI dl;lnhu'mdcac t~ptin, cac socket
vat(;lOcaccli'as6.Vi~cca'pphatcuaagentrencactainguyennaycoth~
dU<;1cki~msoat,nhu'ngmQtkhiagentbi buyhaydu'cJchuy~ntoimQtmay
, khacnhungtainguyennayphaidu'cJcgiaiphong.Tuynhien,th~tkhoma
lamdi~unaybdivi Javakhongh6trcJchovi~cke'thcJpcactainguyennhu'
v~ychomQtd6i tu'cJngCl;lth~nao.Do do chungtaco th~tha'ymQtmobile
agentquellgiaodi<%nd6hQacuanovabo l(;limQtcli'as6dangmdtrenman
hinhcuachungtakhinodoiWimQtmaykhac.
2.2.Vi~cthamchitu khongdzt(Jcbaov~
Cacphu'dngthuccongkhaicuacacd6i tu'cJngJava la dungdu'cJchoba't
ki d6i tu'cJngnao khac co thamchie'uWi no. Bdi vi khongco khai ni<%m
36
thamchienduQcbaav~,mQts6d6i tu'QngduQcpheptroyc~ptoi t~pIon
hdncacphuongthuccongkhai tronglop giaotiep cua d6i tuQngJava hon
caed6ituQngkhac.Ki€u troyc~pnayla quailtrQngchoagent.Khongco
eachnaod€ agentcoth€ trv'ctiepgiamsatvaki€m soatnhii'ngagentkhac
dangtroyc~p toi cacphuongthuccuano.
MQtgiaiphapt6tchovffnd€ naydola duavaod6ituQngd~idi~ngiii'a
nguoigQi(nguoiyellc~u)va nguoiduQcgQid€ ki€m soatvi~ctruyc~p.
Cachtiepc~nnaykhongchiclingcffpvi~cbaav~cacmaconduaramQt
giaiphapchobai loand€ c~ptieptheovaclingcffps11trongsu6tv€ vi tri
n6ichung.
2.3.Khong co thamchie'usdhuudol tzt(lng
Khongai sdhii'ucacthamchie'utoimQtd6ituQngtrongJava.Voi mQt
agent,di€u ngayc6nghlala,nguaitacoth€ Iffynhanhthihanhrakhoino,
nhungkhongth€ lo~ibochinhagenthayd6ituQng.Dayla mQtlacvl;lcho
bQdQnrac.Hi~nnay,bQdQnracsekhongphl;lCh6ibfftkl d6i tuQngnao
chotoikhitfftcacacthamchie'uWid6ituQngnaydaduQclo~ibooDo do
ne'umQts6agentnaodocothamchienWiagentcuachungta,nosekhong
tranhduQcvi~ct~okehdchoagentdo d€ giii'choagent6nt~itraivoiy
mu6ncuachungta.Tfftcanhii'ngl chungtacoth€ lamla l~pl~ilai canh
caod€ khoi demchocacthamchientrtfctieptoi cacagenttrongJava.
2.4.Khong hg tr(lchovi?cduytri vabiltdilu [(litr(lngthai thi hanh
Hi~nthai Java khongth€ khoi phl;lCloanbQtr~ngthai thi hanhcuamQt
d6ituQng.Cac thongtinnhula tr~ngthaicuacontro chuangtrlnhva ngan
37
xe'pluaula vimgbi ca"md6icacch11'dngtrlnhJava.Do do,d€ mQtmobile
agentba:tdffuvi~cthihaOOtiOOloanmQtcachchiOOxactrenmQtmayd
xa,nophaid1!atrencacgia tri thuQctiOOnQiva cacbi€n co'bell ngoaiWi
notI1!cti€p. MQt s1!t1!dQnghoad11'Qcnhungvaoco th6gifi'v€t cualQtrlnh
cuaagentva cha:ccha:nding vi~ctiOOtmlnla d11'Qcngitngva ti€n hanhl~i
dung.
V. AGLET: MO HINH MOBILE AGENT DVA TREN JAVA
Agletla cacd6i t11'Qngd11'Qcxftyd1!ngbAngJavaco th6di chuy6ntit
maynaysangmaykhactrenInternet.Nghlala, mQtagletdangthihanh
trenmaynayco th6dQtngQtngitngthihaOO,t1!gli'imlnhtdi mQtmaykhac
(j trenm~ng,va thi hanhti€p d do. Khi agletdi chuy6n,no mangrheama
chl1dngtrlnhclingnh11'dli li~ucuano.
Agletla mQtJavamobileagenth6trQcackhaini~mthihanht1!triva
dinhtuy€ndQngtrenlQtrlOOcuano.Coth6xemaglet0011'Ia mQtkhaiquat
hoavamdrQngcuaJavaappletvaservlet.Agletd11'Qcdi€u khi6nbdimQt
Agletserverrheacacht11'dngtv nh11'cacappletd11'Qcdi€u khi6nbdi trlnh
duy~tweb.Agletserverclingca"pmQtmaitru'ongchocacagletthihanhva
mayao Javava trlOOqUailIi an loanagletdambaoanloand€ OO~nva
ki~msoarcacaglet.Agletla titghepgiliaagentvaapplet.
1.Aglet API
AgletAPI la mQtbQcongC1;}phattri€n agent- noi cachkhac,la mQtt~p
caelOpvagiaodi~nJava chophept~ocacmobileagent.AgletAPI du'Qc
caenhanghienCUllcuaIBM t~iNh~tBanphattri6n.
38
Di~mdQcdaocuaAgletAPI dola mdrQngkhaDangn6itie'ngcuacac
chu'dngtrinhJavadola : "vie'tmQtlan,thihanhbfftClld dati",d~apd\lng
chocacmobileagent.Kha Dangnaydu'QCdi&nd~tthanh"vie'tmQtlan,hill
h~lllhbfftClldati".NghlaJa, mQtkhi agletdu'QCt~ofa, no sech~ytrenmQi
mayco h6 trQAglet API. Chungtakhongcanquailtamde'nh<%di€u hanh
va phanclingbell du'oihay ngu6ng6c cua cai d~tC\l th~cua Aglet API
trenmaymaagletdangch~y.
AgletAPI phananhmohinhappletcuaJava.M\lc dfchla demd~ctinh
didQngvaoapplet.Mo hinhnaydu'Qcthie'tke'd~t~nd\lngcacIQithe'tu
cacd~cdi~magentcuaJava d6ngthai vu'Qtquanhungthie'usot trongh<%
ngonngunay.Trongmohinhd6i tu'Qngaglet,mQtmobileagentla mQtd6i
tu'Qngdi dQngco lu6ngki~msoatrieng cuano, lam vi<%ctheosl! ki<%n,va
lienl~cbiingcachtruy€n thongdi<%p.
2.Cae thanhphoncd ban
Bay giOchungtasexemxetkI hdnmohinhcdbancuaAgletAPI. Mo
hinhnaydu'aramQts6khaini<%mtrliutu'Qngbaag6m:aglet,d6itu'Qngd~i
di<%n,ngucanhthihanhva dinhdanh:
.:.Aglet:la mQtd6i tu'QngJavadi dQngco th~di chuy~nde'ncacmay
chophepdungagentrongm~ng.No la tl!tri,bdivinothihanhtrong
nhanhriengsailkhide'nmaydo,va tu'dnglac,bdivi no co th~dap
trah.dcacthongdi<%pde'n.
.:. f)ol t"(lngd{lidi~n:dongvai tra nhu'mQtlOpbaav<%agletkhoi cac
truyc~ptnfctie'ptoi cacphu'dngthllCcongkhaicuano.D6i tu'Qngd~i
39
di~nclingcungca'pslftrongsu6t~~vi tr!choaglet,nghlala, no co
th~da'uvi tri thlfccuaaglet.E>i~unayconghlala mQtagletva cac
d6itu'<;1ngd~idi~ncuanocoth~duQctachriengrad~d6ituQngd~i
di~nClJCbQcheda'uslfcachbi~tcuaaglet.
."""-'--'-""-'--"""'--""""".
Clients <Tlldng tac ~ I
'
Hlnh2.7- M6iquan h$ giGaAgletva d6itvqngdQidi$n
.:.Ngil canhthihanh:la mQtmoitr1.tanglamvi~ccuaaglet.Gffntu'dng
tlfvdikhaini~mmoitru'angthihanhdu'<;1cgidithi~udphffntru'dc.No
la mQtd6i tu'<;1ngtInhcungca'pphu'ongti~nd~duytrl va qmln11cac
agletdangthihanhtrongmQtmoi tru'anglamvi~cnha'tqUailmad do
h~th6ngcacmaydu'<;1cbaav~anloantranhcacagletphaho~i.MQt
maytrongm~ngco th~thihanhnhi~udQngcd,va m6idQngcdco
th~qUail11nhi~ungfi'canhthihanh.Cac ngfi'canhthi hanhdu'<;1cd~t
tenva dodo co th~du'<;1cdinhvi biingcachke'th<;1pdiachi moi tru'ang
thihanhvatencuachung.
.:.Binh danh:du'inhdanhnayla duynha'tloan
clJcvakhongthayd6itrongthaigians6ngcuaaglet.
V€ cdbanchi co haicacht~oraslf s6ngchomQtaglet:ho~cla du'<;1ct~o
ho~cla du'~ki~mgOatso'1u'<;1ngcac
aglet,chungtacoth~huychung.
40
May tinh
NgCtcanh
thi hanh
NgCtcanh
thi hanh
NgCtcanh
thi hanh
E>Qngcd
MQng
Hlnh2.8 - M6iquanh$ giQamay tfnh,dQngCdva ngQcanh thihanh
Cacagletdi dQngtheohaicachkhacnhau:chudQngvabi dQng.Cach
tie'pc~nchudQngdu'Qcmota bdimQtaglett1;1'no dffytirmayhi~nhanh
chuano tdi mQtmayd xa.MQtmaykeomQtagletrakhoimaychuhi~n
hanhmota d~ngbi dQngcuas1;1'di dQngcuaaglet.Khi cacagletdangthi
hanh,chungchie'mcactainguyen.D~h~nche's1;1'lieu tontainguyencua
, chung,cacagletcoth~t~mthoikhongho~tdQng,tral~icactainguyen,va
saildoco th~du'Qcdu'atrdl~iche'dQthihanh.Cuoicling,nhi~uagletco
th~traod6ithongtind~hoanthanhmQtlacvl;!naodo.
Dayla t~ptoithi~ucacthaolacdoihoichovi~ct~ovaqUail11mQtmoi
tHrongmobileagentphantan.
Nhu'v~y,cacthaolaccdsdcuamQtagletbaag6m:t~o,nhanban,gti'i
di,keol~i,ngu'ngho~tdQng,ho~tdQngl~i,vahuyboo
41
.:.Tlf,o:vi~ct~omQtagletxayra trongmQtngii'canhthihanh.Aglet.
moisedu<;JcgallmQtdinhdanh,chenVaGngii'canhthih~lllh,vadu<;Jc
khdit~o.Agletb~tdffuthvchi~nngaykhino du<;Jckhdit~othanh
congo
.:. Nhiin ban: nhanban agletse t~ora ffiQtbansaGra'tgi6ngvoi aglet
Dand~\l\Iongcungng\!dum\ninann.S\fKhacnnauuu-yI\n~t\1\a\1ill.
danhdu<;Jcgallva vi~chanhthihanhb~tdfful~itrongagletmojoChu
ydingcaclu6ngthi.h~lllhkhongdu<;Jcnhanban.
.:.aili di: gll'imQtaglettumQtngii'canhthih~lllhtoimQtngucanhthi
hanhkhacsedemnotungucanhthihanhhi~nhanhvachennoVaG
ngucanhthihanhdfch,ndino seb~tdfful~isvthihanht~ido (cac
lu6ngthihanhkhongdu<;Jcdaidi).Chungtanoidingag1etdu<;Jcdffy
Wingucanhthihanhmoicuano.
.:.KeoIlf,i:vi~ckeGag1etl~iseloi nokhoingucanhthihanhhi~nh~lllh
va chenno VaGngucanhthihanhmatu do vi~ckeGl~idu<;Jcyell
c~u.
.:. Kich hOlf,tva tlf,mngltng:t~mngungmQtaglet1akha nangtC;lmthai
dungsvthihanhcuanova-100tm trC;lngthaicuano va thie'tbi hill trU
ph\!nhuiliacling.KichhoC;ltcuamQtagletsekhoiph\!cnotfongcling
ngucanhthihanh.
.:.Buy hi}:vi~cbuymQtagletsedlnhchisvthihanhcuanova10C;libo
nofakhoingucanhthihanhhi~nhanhcuano.
42
-...
Ngl1canh
thlhanhA
Ngl1canh
thlhanhB
Nhan
ban
Guidi
KeolQi
TQo TQmngLlng Kh6i phl,Jc IQi
Lop
Dia
cang
Hinh2.9 - Chu kl song CLIOAglet
3. Mo hinh bienco
Mo hinhl~p trlnhalgerla d1;1'atrenbie'nc6.Mo hinhnay chophepngu'oi
l~ptrlnhthemvao cac listenersdu'Qctuy bie'nvao aglet.Cac listenerbat
eaebie'nc6d~cbi~ttrangchuki s6ngcuamQtagletvachophepngu'oil~p
trlnhxli'11,vid\lnhu',khiagletdangdu'Qchuy~ndi.
C6balo~ilistener:
.:. Clone listener:dungchocacbie'nc6nhanban.Chungtaco th~tuy
bie'nlistenernay d~co mQthanhdQngC\lth~nao do khi mQtaglet
sapdu'QCnhanban,khi vi~cnhanbandu'Qcth1;1'cs1;1't~ora,va sailkhi
vi~c nhanbanxayra.
.:.Mobilitylistener:dungcacbie'nc6didQng.Chungtacoth~sli'd\lng
listenernayd~xli'11khimQtagletsapdu'QCgli'itaimQtngil'canhthi
hanhkhac,khisapdu'QCrutl~itu mQtngil'canhthihanh,va khino
thl!csl!de'nmQtngil'canhthihanhmaio
43
.:.Persistencelistener: Dungchocacbie'nceSkfchho~thay t~mngu'ng.
Listenernay chophepl~ptriOOvien xii'11khi mQtagletsapbi t~m
ngu'ngva sailkhi nodu'<;1ckf hho~tl~i.
4.Me)hinhtreed6i, lien IQc
Cacagletlienl~c,traod6ib~ngcachtruy€nthongdi~p.Ti~nfchtruy~n
thongdi~pchophepcacaglett~ova traod6i cacthongdi~ptheoOOi~u
eachlinhho~t.M~cdinh,vi~ctruy~nthonggiii'acacagletkhongthuanh~n
vi~cxii'11thongdi~pcungmQthic.Di~unayconghlala tfftca cacthong
di~pphai du'<;1cxii'11tu~nW'.
Ngoaiagletva deSitu'<;1ngd£;lidi~n,cacthanhph~nsailla cacthanhph~n
quantn;mgcuamohlnhlien I£;lCgiii'acacaglet
.:. Thong di~p:la mQtd6i tu'<;1ngdu'<;1ctraod6i giii'acac aglet.No cho
phepvi~ctruy~nthongdi~pd6ngbQclingOOu'khongd6ngbQgiii'a
cac aglet.Cd che'truy~nthongdi~pco th~du'<;1cdungbdi cac aglet
d~cQnglac va traod6i thongtin trongd£;lngke'tneSikhongdu'<;1cduy
trllien t\Ic.
.:. Thong di~ph6i am sau:du'<;1cdungtrongvi~cgii'ithongdi~pkhong
d6ngbQ OOu'lamQt"thebai"chophepngu'oigii'ithongdi~pnh~n
mQth6iammQtcachkhongd6ngbQ.
.:.Tljpcacthongdi~ph6iamsau:coth~chuanhi~uthongdi~ph6iam
sailvadu'<;1cdungd~Iffyke'tquakhinaono co.Vdi deSitu'<;1ngnay,
ngu'oigii'iclingcoth~chQnIffyke'tquad~utienvaboquacacke't
quake'tie-p.
44
Agenf/(fngdl,lng :"'.'~'UI"~~~'~.>~:S""
<H61d6P I v
Hinh2.10- Traod6i thongdi$p giQaAglet- Aglet
VI. KET LU~N
MQth<%th6ngmobileagentbaag6mhaithanhphftnchinhdo la mobile
agentvamoitntangthihanhmobileagent("h<%di~uhanh"mobileagent).
Mobileagentla cacthlfcth~dichuy~nkhapnditrenm~ngsailkhiduQct~o
fa.Khi d6nm6imaytrenm~ng,nophaithongquamoitntangthihanhd~
coth~th1!Chi<%ncac lac v\l cuamlnhclingnhu'sii'd\lngcactai nguyencua
h<%th6ng.
MQtmobileagentla mQtth1!Cth~co namthuQctinh,do la: tr~ngthai,
macaid?t,giaodi<%n,dinhdanhvathanchu.CacthuQctinhtr~ngthai,ma
caid?tdungd~mobileagentcoth~thihanhl~isailkhid6nmQtmaymoi.
ThuQctinhgiaodi<%nva dinhdanhgiupchomobileagentco th~lien l~c
, duQcvoi caeagentkhacclingnhu'giupchomoitntangthi hanhquail11
chung.ThuQctinhthanchudu'Qcdungchocacvffnd~anloan.f)~dambaa
.anloanclingnhu'tinhtrongsu6tv~vi trI,cacmobileagentdu'araphftntii'
d~idi<%nd~giao ti6pvoi cacthlfCth~bell ngoai(vI d\l nhu'moi tntangthi
hanh,cacagentkhac,...).
Trongsu6tthaigiant6nt~icuamInh,mobileagentcobathaolaccdban
nhfftdo la t~o,buyva di chuy~n.Cac thaolac nayd~udu'Qcthlfchi<%ntrong
moitntangthi hanh.Nhi<%mV\lchinhcuamoi tntangthihanhla qUail11va
botIP cac mobileagenttbjbanbcungnhu's11d¥ngcaetalnsuyencuah~
45
th6ng.Moi tntangthih~lllhphaichophepnhi€u agentcungt5rit'}.ivaho'}.t
dQngd5ngthai,riengbi~tnhau;clingnhuh6tn;1vi~ctraod6i,thuangluQng
giii'acacagent.Ngoairamoitrltangthihanhconphaidambaaantoancho
caeagentruocs1;1'phaho'}.icuacacagentkhac,clingnhubaav~h~th6ng
tn1ocs1;1'phaho'}.icuacacagentghede-no
Do cac ltu di~mn6i b~tcua mlnhvoi vai tro la ngonngii'l~ptrlnht6t
nha'ttrenm'}.nghi~nnay,JavathuangduQcdungd~caid~tcach~th6ng
mobileagent.Chuangnayclingda:gioi thi~umQth~th6ngmobileagent
dl/atrenJavaduQcclingca'pbdicacnhanghienCUllIBM, Nh~tBand6la
Aglet.Dayla moitruangmalu~nvansad\lngd~xayd1;1'ngcacungd\lng
minhhQa.
cg 8D f,G)(\:Q
46