【正文】
tem)進(jìn)行的。迄今為止對IP路由器測試大都采用ISO 9646規(guī)定的兩種抽象測試法,即回繞測試法(LTM Loopback Test Method)和穿越測試法(TTM Transverse Test Method) [6]。后者直接在數(shù)據(jù)鏈路層之上實(shí)現(xiàn)IPv6協(xié)議及其上層協(xié)議,代表全新的一代產(chǎn)品,國際上有代表的大型系統(tǒng)包括歐美合作的MoonV6 [5],我國八部委宣布在2005年聯(lián)合建設(shè)我國的基于IPv6的試驗(yàn)網(wǎng)也屬于這類新一代的網(wǎng)絡(luò)。前者借助于已有的IPv4平臺(tái),將IPv6協(xié)議分組包裝在IPv4報(bào)文之中。 國內(nèi)外IPv6路由器測試技術(shù)現(xiàn)狀路由器作為Internet的核心設(shè)備,在網(wǎng)絡(luò)產(chǎn)業(yè)的發(fā)展和網(wǎng)絡(luò)建設(shè)中占有舉足輕重的地位,因此對以IPv6為基礎(chǔ)的路由器產(chǎn)品的測試技術(shù)的研究就具有特殊的意義。目前我國正進(jìn)行下一代Internet的建設(shè),并進(jìn)行了大量的基于IPv6的產(chǎn)品開發(fā)工作,迫切需要對相關(guān)網(wǎng)絡(luò)產(chǎn)品的檢驗(yàn)手段和網(wǎng)絡(luò)檢測與維護(hù)手段。國際標(biāo)準(zhǔn)化組織ISO并于80年代中期制訂了“OSI協(xié)議測試框架”標(biāo)準(zhǔn),即ISO IS 9646[3]。對于重要的網(wǎng)絡(luò)設(shè)備如路由器等,還需要對其性能指標(biāo)進(jìn)行測試。以IPv6為基礎(chǔ)的網(wǎng)絡(luò)即被視為下一代Internet(NGI)。為了解決Internet目前和將來可能遇到的問題,Internet Engineering Task Force (IETF)定義了新的網(wǎng)絡(luò)層協(xié)議“IPv6”[2]。鑒于研究中的多端口并發(fā)測試必須依賴雙端口測試器作為基本測試單元,使其能夠集中于對多端口并發(fā)測試的控制問題,而本文反映的工作主要是雙端口測試系統(tǒng)支撐工具的研究與開發(fā),也是下一階段的多端口并發(fā)測試系統(tǒng)的基礎(chǔ)。由于TTCN3編譯器是雙端口測試系統(tǒng)的支撐工具,因此與測試系統(tǒng)相關(guān)。第二遍遍歷第一遍輸出的語法樹,結(jié)合符號表來生成目標(biāo)C代碼。由于最終的可執(zhí)行代碼將由C編譯器完成,因此在TTCN3/C的編譯過程中沒有考慮代碼生成的優(yōu)化問題。TTCN3的編譯過程與傳統(tǒng)的編譯過程類似,包括詞法分析、語法分析、語義分析和代碼生成4個(gè)階段。目前已有的測試系統(tǒng)中采用解釋方式的較多,即“邊解釋邊執(zhí)行”的測試方法。本論文反映的工作是該項(xiàng)目的子系統(tǒng)“雙端口測試系統(tǒng)”(TPT – Two Port Tester)中的“測試支撐工具研究”,即如何將用TTCN3語言描述的測試控制數(shù)據(jù)轉(zhuǎn)變?yōu)闇y試系統(tǒng)中的可執(zhí)行測試數(shù)據(jù)。 西 南 交 通 大 學(xué)研 究 生 學(xué) 位 論 文TTCN3編譯技術(shù)研究與實(shí)現(xiàn)申請學(xué)位級別 碩 士 專 業(yè) 計(jì)算機(jī)應(yīng)用技術(shù) Classified Index: TP314: Southwest Jiaotong UniversityMaster Degree ThesisRESEARCH ON TTCN3 COMPILING TECHNIQUES AND IMPLEMENTATION 摘 要本論文的研究背景是:①IPv6協(xié)議集的測試,特別是對IPv6路由器設(shè)備的測試技術(shù)已經(jīng)成為從現(xiàn)有Internet向基于IPv6的NGI(Next Generation Internet)過渡的關(guān)鍵技術(shù)之一;②現(xiàn)代路由器以多端口和高速化為特征,對路由器產(chǎn)品的符合協(xié)議標(biāo)準(zhǔn)的測試、性能測試難度增加。為了能夠模擬路由器的真實(shí)工作環(huán)境,對路由器的功能與性能指標(biāo)進(jìn)行全面的測試,四川省網(wǎng)絡(luò)通信重點(diǎn)實(shí)驗(yàn)室開展了對多端口路由器并發(fā)測試技術(shù)的研究和測試系統(tǒng)的開發(fā)工作。傳統(tǒng)上這一轉(zhuǎn)換過程可以采用兩種方式:解釋與編譯。 筆者及其同事在分析了現(xiàn)代高速路由器的測試需要的基礎(chǔ)上,在存儲(chǔ)空間的占用量和可執(zhí)行代碼修改的方便性,與測試實(shí)時(shí)性要求的矛盾中,選擇了“縮短聯(lián)機(jī)處理時(shí)間”優(yōu)先的策略,采用對TTCN3描述的測試控制數(shù)據(jù)進(jìn)行編譯的技術(shù)路線。為了與測試系統(tǒng)中其它部件整合,編譯器采用兩步編譯的方式,第一步將TTCN3語言轉(zhuǎn)換成C語言代碼,第二步將C代碼與測試系統(tǒng)的其它組成部分聯(lián)合編譯,最終生成可執(zhí)行代碼。編譯器采用兩遍掃描,第一遍掃描讀入TTCN3源程序,并對其進(jìn)行詞法分析、語法分析和語義分析。筆者的工作涉及詞法、語法和語義分析,但研究重點(diǎn)在于代碼生成部分的設(shè)計(jì)與實(shí)現(xiàn)。編譯后的C代碼將與單測試?yán)闅v軟件(Traverser)和編解碼器(E/D – Encoder/Decoder)聯(lián)合進(jìn)行C編譯,最終形成可執(zhí)行的單測試?yán)郎y試代碼,因此TTCN3/C編譯器還需要充分考慮與二者的結(jié)合問題。關(guān)鍵詞:編譯器;TTCN3;語法分析;代碼生成AbstractThe background of the research work presented in this dissertation include: A) Testing of IPv6 protocol stack, especially IPv6 routers, has bee one of the key technologies to migrate from the existing Internet to the emerging Next Generation Internet, and B) Existing techniques in conformance and performance testing for modern highspeed routers with multiple ports are inadequate. In order to test a router thoroughly, it is prerequisite to emulate its external real working conditions. However, existing testing techniques are not fledged for this purpose. Sichuan Network Communication Key Laboratory (SCNETCOM LAB) has been researching on the techniques for multiport concurrent test and developing the Concurrent MultiPort Test System (CMPTS), of which the Two Port Tester (TPT) forms an important part. The work presented in this dissertation is dedicated to TTCN3 translation techniques for TPT, which translates the test control data in TTCN3 to executable codes. There are two typical approaches in translating specifications in programming languages: interpreting or piling, of which interpreting approach is most widely used in handling TTCN3 specifications. In view that modern routers are highspeed devices with multiports, therefore short online processing time should have higher priority in system design pared with other features such as storage requirements and flexibility in modification of executable codes, and consequently the piling approach is adopted.Compiling of test specifications in TTCN3 is similar to other piling processes, which involve lexical analysis, syntax analysis, semantic analysis, and code generation. In order to incorporate the piled codes with other parts in TPT, a twostage piling approach is designed: first the specifications in TTCN3 is piled into “C” and then to pile into machine executable codes. No codeoptimization has been considered in TTCN3/C piling and left it for the “C” piler. The TTCN3/C piler first scans the source code in TTCN3, performs syntax analysis and semantic analysis, and finally generates the C code via scanning through the syntax tree in conjunction with symbol tables.The author’s work involves lexical analysis, syntax analysis, and semantic analysis, and an emphasis has been given to techniques of code generation. As the TTCN3/C piler is the support tool for TPT, to some extent it is testerdependent. Therefore, the resultant “C” code for test control data has to be jointly piled into machine code with “C” code for the traverser (which traverses through a single test case) and with the E/D (Encoder/Decoder) of PDU (Protocol Data Units) of the protocol under test. The significance of work presented in the dissertation not only provides an important tool for TPT but also provides a basis for CMPTS under development, which leaves the burden of control of a pair of ports to TPT.Key words: piler, TTCN3, syntax analysis, code generation目 錄摘要 IAbstract III目錄 V第1章 緒論 1 本論文的研究背景 1 研究IPv6網(wǎng)絡(luò)協(xié)議測試技術(shù)的意義 1 國內(nèi)外IPv6路由器測試技術(shù)現(xiàn)狀 1 IPv6路由器并發(fā)多端口測試系統(tǒng) 2 傳統(tǒng)路由器測試技術(shù)與系統(tǒng)的局限性 2 并發(fā)多端口測試技術(shù)與測試系統(tǒng) 3 測試控制管理器與測試支撐工具 4 本論文反映的研究與開發(fā)工作及主要特點(diǎn) 5 論文組織結(jié)構(gòu) 6第2章 TTCN3/C編譯程序總體設(shè)計(jì) 7 TTCN3的發(fā)展及特點(diǎn) 7 國內(nèi)外相關(guān)編譯技術(shù)研究現(xiàn)狀 8 TTCN3/C編譯程序的總體設(shè)計(jì) 8 TTCN3編譯階段劃分 8 TTCN3/C編譯程序設(shè)計(jì)范圍的界定 9 TTCN3/C編譯程序的階段 9 編譯過程的“遍數(shù)” 10第3章 詞法、語法與語義分析 12 詞法分析 12 詞法分析簡介 12 用LEX構(gòu)造詞法分析器 12 詞法分析器的輸出結(jié)果 13 詞法分析的錯(cuò)誤處理 15 語法分析 15 語法分析簡介 15 用YACC工具構(gòu)造語法分析器 15 與詞法分析的結(jié)合 16 語法規(guī)則的沖突處理 17 語法樹 20 語法分析的錯(cuò)誤處理 24 語義分析 24 語義分析簡介 24 在YACC中實(shí)現(xiàn)語義分析 24 符號表 25 語義分析的輸出 27 語義分析的錯(cuò)誤處理 28第4章 代碼生成 29 代碼生成簡介 29 目標(biāo)代碼的形式 29 代碼生成的基本思路 30 與編解碼器的接口 31 與單測試?yán)?qū)動(dòng)程序的接口問題 32 語法結(jié)構(gòu)的實(shí)現(xiàn) 33 TTCN3類型的實(shí)現(xiàn) 33 TTCN3聲明的實(shí)現(xiàn) 35 TTCN3函數(shù)和可選步的實(shí)現(xiàn) 37 TTCN3程序語句和操縱的實(shí)現(xiàn) 38 TTCN3預(yù)定義函數(shù)的實(shí)現(xiàn) 43 語法規(guī)則的篩選 45第5章 編譯程序的調(diào)試 46 詞法和語法調(diào)試 46 編譯程序調(diào)試 49 編譯程序的執(zhí)行 50第6章 總結(jié)與展望 51 論文工作總結(jié) 51 后續(xù)工作展望 51致謝 53參考文獻(xiàn) 54攻讀碩士學(xué)位期間發(fā)表的論文及科研成果 57第1章 緒論 本論文的研究背景