ѧ
JOURNAL OF SOFTWARE
1999 6 10 Vol.10 No.6 1999



RPCƵݴƷϵͳʵ
Һ⽨ƽ
ժҪƷѹҵҪ.Internetҵ̵ƽҵIntranetĹ㷺չӦ,ǶƷѹԽԽ.ԼƷϵͳһҪǸЧɿ.һRPCͨŻƵݴƷϵͳFTCharge(fault-tolerant charge).ڼ˼ƷѵĻݺԭԺ,FTChargeṹͶݴƵʵ.
ؼʡ,Internet,,SNMP(simple network management protocol),Ʒѹ,RPC(remote procedure call).
ͼšTP393

Design and Implementation of an RPC-based Fault-tolerant 
Accounting Management System
YANG Jia-hai WU Jian-ping
(Department of Computer Science and Technology Tsinghua University Beijing 100084)
(Network Research Center Tsinghua University Beijing 100084)
Abstract Network accounting management is the important management function of commercialized computer network. With the commercialization of Internet and the occurrence of lots of Intranets, it's urgent to develop network accounting management system. A principal requirement of such systems is efficiency and reliability. A fault-tolerant accounting system based on RPC (remote procedure call) mechanismFTCharge(fault-tolerant charge) is proposed in this paper. After the brief discussion of the accounting principle, the design of the architecture and the fault-tolerance mechanism of FTCharge system are discussed.
Key wordsComputer network, Internet, network management, SNMP(simple network management protocol), accounting management, RPC (remote procedure call).
Ϣ̶ԽԽ,ĸЧɿйҲԽԽҪ1.绥һ,׼ķչ2.оչͱ׼,ʱ׼֯ISOInternetϵṹίԱἰĹ鶼׿гЧĹ.2070ĩ,ʱ׼֯俪ϵͳοģOSI/RM(open system interconnection reference model)ͬʱ,׼Ŀ,ϵͳ(ISO 7498-4)3,ƶӦЭ׼,Ϣ͹ϢЭCMIS/CMIP(common management information service/common management information protocol)4,5.ϵͳISO7498-4Ϊ5,ùʧЧܹƷѹͰȫ3.ڴ˿ܻ,InternetϵṹίԱӦ׼,ЭSNMPsimple network management protocol6,7.
ƷѹҵҪܣ8.Internetһѧо,ķչͺ,ǼƷѹδõӦе.Internetҵ̵ƽIntranetĹ㷺չӦ,ǶƷѹͻ9.
Ϊ,һЩܲҲпһЩƷ,ЩƷ϶ǵе,һûֹϻӸûľֲж,ͻᶪʧƷ,ֱӵľʧ.ˣȷƷϵͳĸЧɿУͳһؽ.߿ɿԵһֱӰ취ǶƷϵͳͬʱ.ڴļƷܴ,ҼƷݱǶ̬仯Ͳظֵ,α֤ݵļƷϵͳ֮ͬЭͳΪƷϵͳҪ.һRPCƵݴƷϵͳFTCharge(fault-tolerant charge).ڼ˼ƷѵĻԺ,FTChargeṹͶݴƵʵ.
1 ѵݺԭ
ƷѵĻûʹԴ,:Ϣռ·ʱ.ר˵,õķǸÿûͨʹõϢͨΪƷݣ.ƷݵĻȡַʽ,һͨ׼SNMPȡ,һͨ߼ȡ.
Internet׼ЭSNMPڶ˻ͬʱ,Ҳһϵֲ֧ĹϢMIBmanagement information base,окͼƷصMIB.ֻҪԱͨӱⲿı߽·ʵ,ܶԶ¼ͨ·Ľ.Cisco·Ϊ,¼ļƷϢ¸ʽһű:
Source IP Address
202.120.186.45
202.121.0.2
Destination IP Address
206.15.106.131
207.68.156.49
nPkts
23
19
nBytes
4 080
1 267


ÿһݰ·ͨʱ,·Ƿ֮ƥSource IP AddressDestination IP Address.ҵƥļ¼,ۼ,򴴽һ¼¼.Щ¼ͨSNMP׼.
һּƷݻȡķ̫ߵĹ㲥,ӵʵطһֻϢ豸,Ȼһֻػݰͷ.ͨݰͷйϢԵõûʹĸϢ,ܵĽ(telnet,ftp,http,mailȵ).
ּƷݻȡ,1ַǱ׼ķʽ,ͨSNMPʵ,Ҳ豸Ͷ.ַһȱǼƷȽϴ,ֻƵIP,ûֻֽ֪ͨ.2ַʽĺôûԸҪָƷݵȣԻȡͨ,֪ҵͷֱռö,⽫ûԲͬͲȡͬշѱ׼,ҲûͽʺϵԴ.ȱȱ׼,豸Ͷ,˽ṹ.ûھӦпԸҪѡеһ.
2 ϵͳṹ
FTChargeϵͳRPCͨΪķֲʽƷϵͳ.ϵͳṹͼ1ʾ.

ͼ1FTChargeϵͳṹ
FTChargeƷϵͳ1ϵͳ1Ʒϵͳ1ݼƷϵͳ.ϵͳMonitorsҪǼƷϵͳ͸ݼƷϵͳĹ.Ʒϵͳֹʱ,ϵͳԤ趨ĲԶشӶݼƷϵͳѡһϵͳ,ϵͳԽƷݵĲɼ;ƷϵͳĹѾ޸ʱ,ֻԶֹͣݼƷϵͳĹ,ȷһʱֻ1Ʒϵͳڹ.MonitorsICMPһ̼ӹӼƷϵͳӡϵͳǷ.
ƷϵͳFTChargeĺ,мƷݵĲɼͼӹ.ϽЩǿһϵͳʵֵ,ǵƷݿܴڶ,ΪάݵԺһ,ݵĲɼͺļӹֿ,רһݿӹԸļƷ.Ҳݲɼϵͳռ.ʵϣƷݲɼʵʱǺǿ.
ڼƷڱȡ֮ǰڻݴ,һһ֮,ݲд,,ݲɼϵͳڶȡ֮Ҫջ.,һʱֻһݲɼϵͳݲɼ,ݵĲԺͲһ,ʧ.
ϵͳĹƷϵͳȫһ.ֻڿУidle״̬.һϵͳֹ,յԼϵͳָ,빤active״̬.ʱƷϵͳȫһĹ.
3 ݴԵʵ
ݴԵʵ߼ƷϵͳɿԵĹؼ.ϵͳûԶ̵̹RPCremote procedure callķֲʽӺͿƻʵϵͳݴ.ԼƷϵͳļӺͿɼϵͳʵֵ.
ϵͳ߼Ϸֳ:
(1) Ʒϵͳ硢ϵͳ;
(2) Ʒϵͳʱ,ѡһõıݼƷϵͳ,;
(3) ӵǰıݼƷϵͳ;
(3.1) Ʒϵͳϻָ;
(4) ڵǰеıݼƷϵͳҲʱ,ʣµıݼƷϵͳѡһõϵͳ,;
(4.1) ƷϵͳѾָʱ,ֹͣݼƷϵͳĹ.
Ϊ˸õϵͳḶ́԰ʽʵ㷨.
Monitors㷨.
BEGIN
Ʒϵͳ:Primary;
ݼƷϵͳ:NUM;
屸ݼƷϵͳ:Backup1...NUM;
Դ:MaxRetry;
WHILE (TRUE) {  /**/
Result:=Test(Primary);/*Ʒϵͳ*/
IF (Result=ok)
THEN/*Ʒϵͳ*/
{sleep a while;/*һʱ*/
continue;
}
ELSE
{/*Result=failed:ǰʧ */
i:=0;/*һʧܲ½*/
WHILE (iMaxRetry) {
Result:=Test(Primary);
IF (Result=ok)/*˲ʱԼ,ָֻˣ*/
THEN
i:=MaxRetry+1;/*ѭ*/
ELSE
i:=i+1;/*һβ */
}
IF (i=MaxRetry+1)
THEN
{
sleep a while;
continue;
}
ELSE/*MaxRetryβԶй,Ϊϵͳȷʵ*/
{
x:=1;
WHILE (x=NUM){/*ӱϵͳѡһõ*/
IF (Backupx is OK)
THEN
{RPC-start (Backupx); /*Զ̵̹,ϵͳX*/
startmonitorB (Backupx); /*ʼXм*/
monitorP (Primary); /*Ʒϵͳ,˽޸*/
exit;
}
}
}
}
} /* END of Outer WHILE*/
END
Աıϵͳļ,ԹƷϵͳиټӵĹҲ,ֻжִеĶ෴.ƪ,Ͳظ.
4 Ʒϵͳ
ɼƷݲɼӹͳɱʵȹǼƷϵͳ.ƵļƷϵͳԹϵݿΪ,ݲɼԤƷݴͼƷϢѯȼģ.ɽṹͼ2ʾ.

ͼ2Ʒϵͳɽṹ
෽֤,Ŀǰ׶,Ǿʵֵ1ַʽݲɼ,Ϊõ2ַʽ߼ݲɼչӿ.ƷСʱΪλ,γļ.Ԥģ鶨ڽղЩļ,Ԥģ齫ļʽȷԡIPַĺϷ,ͳƣۼӣ,γݿ¼,.
ƷݴģĹǶݿеݽнһļӹʹ,ɸר,ЩԱʵʽӡ.Щݻ򱨱ɸûĲͬҪָ,ضεݻܱݻܱIPַϸͳƷϸԼƷʵ.
ƷϢѯģҪûṩͼƷصĸݵĲѯ.ڼƷϵͳбλûмƷ,ԼƷϵͳӦʵʵûѯʵλ˻IPַͨŵ.,ƷϵͳλĸϢ,¡ȷIPַϢ,ЩϢԶԱ,ͬʱҲԶԾ߱һȨ޵û.ЩͨƷϢѯģʵ.Ϊ޶ȵʵּƷϢķֲʽѯ,ƷϢѯģWEBʵ,ʹûĲѯֱͨWEB Browser,NetscapeȽ.
5 
ѾʵһƵʵϵͳ,ͶйͿмĵʵʹ,һʱ,֤ǿе,ϵͳеĿɿԱԭȵеʱ,ұ֤˼ƷݵԺһ,ﵽԤĿ.Ҫָ,һݴԵƲڼƷϵͳ,κζԿɿнϸҪϵͳԲ.
Ʒһ֮Ƕ豸ͶʵҪȽϸ.һЩС͵й˵,ھԺͿɿ֮һܺõ.ʵ,FTChargeϵͳĺܶ๦ǿԺϲһе,ݵĴݲɼ,ϵͳͱݼƷϵͳ֮ȶԺϲ.Ȼ,⽫һ̶Ӱɿ.ڽͳɱԱ㹻Ŀɿ,һĹĿ.
*оõҡ塱ƼĿ
߼顡Һ1966ڣҪоΪЭһԲԣ绥Э飬
⽨ƽ1953ڣʿʦҪоΪЭһԲԣ绥Э飬
ͨѶϵˣҺ 100084廪ѧCERNET
ߵλ廪ѧѧ뼼ϵ  100084廪ѧϢ繤оġ100084
ο
1Aronoff R et al. Network management functional requirements. Management of Networks Based on Open Systems Interconnection(OSI): Functional Requirements and Analysis. NIST Special Publication 500-175, Nov. 1989. http:csrc.nist.gov/nistpubs/sp500-175.txt
2Һ.Internet.йû,1996,(17):911
(Yang Jia-hai et al. Internet network management. China Computer User, 1996,(17):911)
3ISO/OSI. Basic Reference Model for Open System Interconnection. IS7498, Oct. 1984
4ISO/OSI. Management Information Service Definition, Part 2: Common Management Information Service. IS9595-2, ISO, Switzerland, May 1988
5ISO/OSI. Management Information Protocol Definition, Part 2: Common Management Information Protocol. IS9596-2, ISO, Switzerland, May 1988
6Jeffrey D Case, Mark Fedor et al. A Simple Network Management Protocol(SNMP). RFC1157, Internet Network Working Group, May 1990
7James M Galvin, Keith McCloghrie. Administrative Model for Version 2 of the Simple Network Management Protocol(SNMPv2). RFC1445, Internet Network Working Group, Apr. 1993
8,.Ʒѹ.ŵ˱.CERNETо뷢չ.:ͨѧ,1997
(Xu Gang, Tang Jian. Network accounting management. In: Zhang De-yun ed. The Research and Development of CERNET. Xi'an: Xi'an Jiaotong University Press, 1997)
9Cisco Systems Inc.. Cisco Enterprise Accounting for Netflow. Version 2.0, Cisco Enterprise Accounting for ISDN, Version 2.0. on-line, URL http:www.cisco.com
1998-02-17յԭ壬1998-07-01յ޸ĸ
