Font Size: a A A

An Extension Of NS2 For CAN Protocol Simulation

Posted on:2011-10-12Degree:MasterType:Thesis
Country:ChinaCandidate:Y ZhaoFull Text:PDF
GTID:2178360305954412Subject:Computer application technology
Abstract/Summary:PDF Full Text Request
As the unique filed bus which has international standard, CAN bus has a very important application in the field of automotive electronic. In recent years, the number of automotive control units has been increasing and network control system has been more complex, CAN network always need a viable real-time scheduling policy which designed to meet the real-time requirement of system. This paper aims to extend NS2, add a module for simulating CAN protocol, that a CAN network can be simulated closing to reality in project development, which is used to research the Can network scheduling algorithm.First, discuss the characteristics of CAN protocol is analyzed in detail. CAN protocol adopts a lot of unique technologies, CAN node do not have network ID, CAN bus identifies the node through node identifier. Bus communication interface integrated physical layer and data link layer, can process date of frame, such as arbitration, information routing, fault confinement.Based on analysis, the functional framework of the CAN module summarized based on the mechanism of NS2, the design requirements of the module is proposed. Then, set up mathematical module for CAN protocol, ignore the details which are useless for simulation, grasp the essence of the protocol, simplify the protocol approach by equivalent simulation. Sending frequency module, arbitration equivalent module and ignored details are proposed. Finite state machine is used to set up module for the application layer, date link layer and physical layer. State set and input set are modeling for every layer of CAN protocol. Theoretical support is provided for the design of the CAN module, which can keep the authenticity and integrity of the design.Based on the design requirements and the finite state machine, five sub modules is designed to simulate the characteristics of CAN protocol from the perspective of the network layer.1,Node Module (Node)Node module of NS2 is used to simulate CAN node. This module is achieved through the node class, which is a basic element of NS2. Node module contains some data packet classifiers, which are used to determine the next receive object of the data packet. Node module and CanAgent module coordinate to simulate the sender and the receiver of the CAN node.2,Application Layer Module (CanAgent)The application layer of CAN protocol is used to simulate both the sending behavior and the receiving behavior of the CAN node. This module is designed as a class, which inherits the Agent class of NS2. Due to the producer of the data frame and remote frame, CAN frame is simulated in the CanAgent module. Then, the sender and the receiver are simulated. At the sender, data frame and remote frame are sanded, at the same time, some attributes have to be set, such as the priority of the node, send pattern, send interval, the deadline of the frame, node identifier, frame type, and so on. At the receiver, the date packet is received, and the remote frame can be responded. CanAgent module and CanMac module coordinate to simulate the addressing pattern and the fault confinement.3,Logical Link Control Layer Module (LL)LL module of NS2 is used to simulate the logical link control layer of CAN protocol, which contains message filtering, overload Notification, Recovery Management. To reduce design complexity, these functions are simulated through the CanMac module. From the perspective of network simulation, the design can not affect the simulation results. LL module contains the Queue module of NS2, which is used to simulate the function of congestion control, all the packets from CanAgent should wait in the Queue, and the Queue keep only one packet send to the CanMac module each time.4,Medium Access Control Layer Module (CanMac)CanMac module is the mainly part of the simulation of CAN protocol, which is use to simulate the medium access control layer. Most of the functions of CAN protocol are simulated in CanMac sub module. This module is designed as a class, which inherits the Mac class of NS2, and used to simulate the medium access control layer. CanMac contains some classes, which are used to simulate the packet sending and receiving, resending mechanism. And a class specifically designed for simulating the space of frame. CanMac module and up layer modules cooperate to simulate the addressing pattern, the fault confinement and message filtering.5,Physical Layer Module (Channel)The channel module of NS2 is used to simulate the physical layer of CAN protocol. In order to simulate the arbitration mechanism of the CAN protocol, two functions are needed to add to the channel class. One is used to probe competition of the CAN bus, the other is used to make arbitrating. When the CanMac module sends the packet to the Channel module, the bus resources is allocated through the two functions. In the arbitration function, scheduling algorithm can be embedded, which is used to simulate CAN network with arbitration strategy.Finally, CAN module are embedded into the NS2 kernel through extension method of NS2, and then test simulations. The trace file of NS2 which is used to record the results of simulation and three tools which are used to analyze the results of simulation are introduced. The three tools are NAM, Awk, Gnuplot. Furthermore, some tests are carried to test the main function of the CAN module of NS2 by designing simple scripts, including the frame space, addressing pattern, remote frame simulation, sending data. These tests proved that the modules designed in this paper can simulate the key characteristics of CAN protocol. Then a test is taken to test the entire simulation performance of CAN module. First configure a CAN network simulated environment through the script, in order to make stress to the system and increase the apparent of result, the senders have a high frequency of sending. Compare the results between the module which is not joined the arbitration algorithm and which is joined the arbitration algorithm EDF through the test. After analyzing the results, the overall real-time performance of CAN network has been greatly improved after adding EDF.That shows the NS2 which is expanded can meet the requirement of simulation of CAN protocol, and it can achieve the effective assessment of arbitration algorithm.
Keywords/Search Tags:CAN Protocol, NS2, Network Simulation, Arbitration, Extension
PDF Full Text Request
Related items