【正文】
處理,僅當(dāng)網(wǎng)絡(luò)事件發(fā)生時(shí),由UIP內(nèi)核喚起應(yīng)用程序處理。其中UIP提供了3個(gè)函數(shù)給底層系統(tǒng):uip— init()39。uip— buf[O])uip—len=ethemet—devicedriver— poll();//接收以太網(wǎng)數(shù)據(jù)包(設(shè)備驅(qū)動(dòng)程序)if(uip— len0){ //收到數(shù)據(jù)if(BUF一type: :HTONS(UIP—ETHTYPE— IP)){//是IP包嗎?uip— arp—ipin(); //去除以太網(wǎng)頭結(jié)構(gòu),更新ARP表uip— input(); //IP包處理if(uip— len0){ //有帶外回應(yīng)數(shù)據(jù)uiparp out(); //加以太網(wǎng)頭結(jié)構(gòu),在主動(dòng)連接時(shí)可能要構(gòu)造ARP請(qǐng)求ethemet—devieedriver— send();//發(fā)送數(shù)據(jù)到以太網(wǎng)(設(shè)備驅(qū)動(dòng)程序)}}elseif(sot一type==HTONS(U1PETHTYPEARP)){//是ARP請(qǐng)求包uip— arp—arpin();//如是是ARP回應(yīng),更新ARP表;如果是請(qǐng)求,構(gòu)造回應(yīng)數(shù)據(jù)包if(uip— len0){//是ARP請(qǐng)求,要發(fā)送回應(yīng)ethernet—devicedriver— send();//發(fā)ARP回應(yīng)到以太網(wǎng)上另一個(gè)UIP內(nèi)核直接提供給底層設(shè)備驅(qū)動(dòng)程序的函數(shù)是uip— periodic(conn)。同時(shí)設(shè)置結(jié)構(gòu)體UIP— eonn指針指向當(dāng)前連接。define LED1_OFF() GPIO_ResetBits(GPIOB, GPIO_Pin_5)。 uint8_t led3_readvalue。 if(led3_readvalue == 0)myudp_send(LED3 亮\n,8)。 len = uip_datalen()。 } else if(strncmp(nptr,ledon 3,7)==0){ LED3_ON()。 } else if(strncmp(nptr,ledpoll,7)==0) led_poll()。 GPIO_Init(GPIOA, amp。 struct timer t。 //基本時(shí)鐘 clock_arch_init()。 /* 初始化網(wǎng)絡(luò)設(shè)備以及UIP協(xié)議棧,配置IP地址 */ //應(yīng)用層MAC初始化 for (i = 0。 /* 創(chuàng)建一個(gè)TCP監(jiān)聽端口和監(jiān)聽端口,端口號(hào)為1200,80 */ uip_listen(HTONS(1200))。 GPIO_WriteBit(GPIOA, GPIO_Pin_1, Bit_RESET)。 //發(fā)送數(shù)據(jù)到以太網(wǎng)(設(shè)備驅(qū)動(dòng)程序) } } if UIP_UDP /* 輪流處理每個(gè)UDP連接, UIP_UDP_CONNS缺省是10個(gè) */ for(i = 0。 uip_arp_timer()。 //發(fā)送數(shù)據(jù)到以太網(wǎng)(設(shè)備驅(qū)動(dòng)程序) } } /* 處理arp報(bào)文 */ else if (BUFtype == htons(UIP_ETHTYPE_ARP)) //是ARP請(qǐng)求包 { uip_arp_arpin()。 if 1 printf(uip ip address : 192,168,1,8\r\n)。 //設(shè)置網(wǎng)絡(luò)掩碼 uip_setnetmask(ipaddr)。 (led_flag == 0x00) GPIO_WriteBit(GPIOA, GPIO_Pin_1, Bit_SET) 。 //加以太網(wǎng)頭結(jié)構(gòu),在主動(dòng)連接時(shí)可能要構(gòu)造ARP請(qǐng)求 tapdev_send()。arp_timer)。 //加以太網(wǎng)頭結(jié)構(gòu),在主動(dòng)連接時(shí)可能要構(gòu)造ARP請(qǐng)求 tapdev_send()。單擊,對(duì)所有的程序進(jìn)行編譯和連接,結(jié)果在“Build”里, 編譯和連接 燒寫代碼下載在“project”中選擇“options for target target1”,在界面中選擇“Debug”,設(shè)置“CortexM3 JLink”之后創(chuàng)建,將燒寫速度選擇2MHZ 。其間,查找資料,老師指導(dǎo),與同學(xué)交流,反復(fù)修改,每一個(gè)過(guò)程都是對(duì)自己能力的一次檢驗(yàn)和充實(shí)。這次實(shí)踐是對(duì)自己大學(xué)四年所學(xué)的一次大檢閱,使我明白自己知識(shí)還很淺薄,雖然馬上要畢業(yè)了,但是自己的求學(xué)之路還很長(zhǎng),以后更應(yīng)該在工作中學(xué)習(xí),努力使自己成為一個(gè)可以參與工作能獨(dú)立完成設(shè)計(jì)的人。我要感謝大學(xué)期間所有結(jié)識(shí)的朋友,是你們使我擁有了美好的大學(xué)時(shí)光! 參考文獻(xiàn)[1] ,模擬部分5版[M]. 等教育出版社, [3][J].中國(guó)高新技術(shù)企業(yè), [4] (第4版)[M].北京:清華大學(xué)出版社,[5] (第2版) [M].北京航空航天大學(xué)出版社,[6] :基于8051+Proteus仿真[M].電子工業(yè)出版社,[7][D].青島大學(xué)碩士, [8][J].計(jì)算機(jī)光盤軟件與應(yīng)用,[9][J].電子世界, [10][D].杭州電子科技大學(xué),附錄一:STM32電路原理圖DM9000電路原理圖和驅(qū)動(dòng)電路原理圖附錄二:英文資料和譯文英文資料: Rainbow: ArchitectureBased SelfAdaptation with Reusable InfrastructureHua Liu and Manish ParasharThe Applied Software Systems LaboratoryDept of Electrical and Computer Engineering, Rutgers University, Piscataway, NJ08854, USAEmail:{marialiu, parashar}Salim HaririDepartment of Electrical and Computer Engineering, University of Arizona, AZ, USAEmail:hariri Abstract The Rainbow framework uses software architectures and a reusable infrastructure to support selfadaptation of software systems. The use of external adaptation mechanisms allows the explicit specification of adaptation strategies for multiple system concerns. 1. Introduction Softwarebased systems today increasingly operate in changing environments with variable user needs, resulting in the continued increase in administrative overhead for managing these systems. To reduce these costs, systems are increasingly expected todynamically selfadapt to acmodate resource variability, changing user needs, and system that support selfadaptation currently exist in the form of programming language features such as exceptions and in algorithms such as faulttolerant protocols. But these mechanisms are often highly specific to the application and tightly bound to the code. As a result, selfadaptation in today’s systems is costly to build, difficult to modify, and usually provides only localized treatment of system contrast to these internal mechanisms, recent work uses external models and mechanisms in a closedloop control fashion to achieve various goalsby monitoring and adapting system behavior at runtime. 1,2 As illustrated in Figure 1, control of system adaptation bees the responsibility of ponents outside the system that is being principle, external control mechanisms provide a more effective engineering solution than internal mechanisms for selfadaptation because they localize the concerns of problem detection andre solution in separable modules that can be analyzed, modified, extended, and reused across different systems. Additionally, developers can use this approach to add selfadaptation to legacy systems for which the source code may not be external approach requires using an appropriate model to reason about the system’s dynamic behavior. Several researchers have proposed using architectural models, 3 which represent the systemas a gross position of ponents, their interconnections, and their properties of interest. 4 Such an architecturebased selfadaptation approach offers many benefits. Most significantly, an abstract architectural model can provide a global perspective of the system and expose important systemlevel properties and integrity attractive in principle, architecturebasedselfadaptation raises a number of research and engineering challenges. First, the ability to handle a wide variety of systems must be addressed. Since different systems have radically different architecural styles, properties of interest, and mechanisms supporting dynamic modification, it is critical that the architectural control model and modification strategies be tailored to the specific system. Second,the need to reduce costs in adding external control to a system must be addressed. Creating the monitoring, modeling, and problemdetection mechanisms from scratch for each new system would render the approach prohibitively Rainbow framework attempts to address both problems. By adopting an architectu