Routing Simulation - Declaration of Class Design

zhaozj2021-02-16  47

Routing Simulation System Design (1) Interface Description Part 2004-3-21

1. All global variables and functions in the global name spatial routing system are implemented in a namespace.

NetSource Name Space Internal Variable: #define Null 0 // Network Device Type Table ENUM NETELEMENTTYPE {Fiber = 1, Centralrout}; // Route IP Address Length const IP_address_length = 32; // Routing Table Maximum length const INT MAX_ROUT_TABLE_SIZE = 100; // Router port largest data package capacity const INT MAX_DATA_QUE_LENGTH = 20; Name Space Function: // Determine whether two IP addresses are equal BOOL AddRequal (const unsigned int * addr1, const unsigned int * addr2);

Second, class design routing simulation system class according to the predetermined document class diagram design. The constructor of all classes is omitted with the description function interface.

1, network element class name: NETELEMENT class Nature: Pure Virtual Class Parental Class: Uncalar Primary Attribute: // Network Device Type NetlementType NetlementType; Class's primary interface: // Get the type of network device < Public> Virtual NetlementType GetType (Void) = 0;

2, network cable class name: the nature of the Absline class: Pure vain category parent class: The main attribute of the public inherits the NetElement class: inheritance attributes;

// The length of the network line int LENGTH; the primary interface of the class: virtual void setlength (int _length) = 0; virtual int getLength (void) = 0;

3, fiber class name: Nature of the Fiber class: can be instantiated by the child class: the main attribute of the public inheritance Absline class: Inheritance Property omitted; the primary interface of the class: // Get the type of network device NetlementType Gettype (Void ); // Set line physical length Virtual void setLength (int _Length); // Get line physical length Virt Getlength (Void);

4, Router Class: The nature of the Absrout class: Pure Virtual Class Parental Class: The main attribute of the public inherits the NetElement class: inherited attributes; // Router Self-address int SELFADDRESS [ip_address_length]; // Routing Table RoutTable; // Current IP Packet NetData currtpdata; // Data port std :: list datainlist; std :: list DataOutlist; std :: List :: item data port data volume int DataListLength; class primary interface: // Router Send data to port virtual void sendData (void) = 0; // Router from Port Receive Data Virtual Void ReceiveData (Void) = 0; // Network Write Data to Router Port Write Virtual Bool NetWriteData (NetData & _netData) = 0; // Receive data from the router port Virtual NetData * NetReadData () = 0; // Set the routing table virtual void settable (void); // Routing calculation: Function pointer void (* routCompute) (int ** _ netArray, int ** _ valarray, Int * * & results, int routnum, int index; // Routing the current packet void DataroutCompute (Void); // Setting the routing method void setcomputeMethods (void _routcompute (int **, int)); // Setting your own address virtual void setselfaddress (unsigned int addr [ip_address_length]); // Get your own address Virtual unsigned int * getselfaddress (void); // Empty Virtual void setNetinfor (int ** _netArray, int ** valarray, int _routnum); // Generate data void Makedata (NetData & netdata); 5, the center router class name: CENTRALROUT Class Nature: Can be instantiated by Parental Class: The main attribute of the public inheritance AbsrOut class: Inheritability slightly; // Network information <

Private> int ** NetArray, ** Valarray; // Send Packet Tracker Double ID; Primary Interface: // Get Device Type Virtual NetlementType GetType (Void); // Send to port Data Virtual Bool NetWriteData (NetData & _netData); // Network Receive Data from Router Ports Virtual NetData * NetReadData (); // Set Routing Table Virtual Void SetRoutTable (Void); // Hong Pow Procedure Get Network Information Virtual Void SetNetinFor (int ** _netAtarray, int ** _valarray, int _routnum); // Router Send data virtual void sendData (void) to port; // The router receives data from the port < Protected> Virtual Void ReceiveData (Void); 6, Network Node Class Name: NetNode Class Nature: Accent Class Parental Class: Uncalar Primary Properties: // Router Absrout * PROUT; // Network Circuit < PUBLIC> ABSLINE * PLINE;

NetNode * pnextNode; the main interface of the class: no

7. Nature of the NET class: Nature of the NET class: Make instantiate parental class: Uncommitted primary property: // Network router bit int routnum; // Number of network lines in network int Linenum ; // Network data structure: Adjacent table NetNode * pnodeArray; // network adjacent matrix and dissipation matrix int ** NetArray; int ** valarray; // Router Type Vector NetlementType * ROUTTYPES; // Type of // Network line type Vector NetlementTyPe * Linetypes; // Introduction Static Bool First; Class's primary interface: // Creating an air network Void Create (int _ROUTNUM); // Create a backbone network void create (int ** _netArray, int ** _valarray, int _routnum); // Create any type of network void create (int ** _netArray, int ** _Valarray, INT _ROUTNUM, INT _LINENUM, NETELEMENTTYPE * R, NETELEMENTTYPE * L); // Get Network Information Void getNetinFor (Void); / / Determine whether the network changes BOOL ISCHANGED (Void); // Release Resource < Private> Void Clear (Void); // Create a network void recreate (void); // Depending on the site to get the subscript of the router sequence int getRoutId (Unsigned Intdr [ip_address_length); // Get pnodeArray NetNode * & getPnodeArray (); // Generate network-transmitted data packet int Makedata (Void); // Generate network-transmitted packet int Makedata (NetData & _IPData); / / Route calculation build Void RoutComputeBuilder (Void);

8, routing tabletalog: TABLENODE class Nature: Make instantiated parent class: Uncaracted primary property: // destination address unsigned int addressTo [ip_address_length]; // Next relay route address < public> unsigned int addressNextHop [IP_ADDRESS_LENGTH]; main interface class: // Sets the destination address void SetAddressTo (unsigned int _addressTo [IP_ADDRESS_LENGTH]); // address of the next hop router void SetAddressNextHop (unsigned int _addressNexthop [ip_address_length]);

9, routing table class name: Table class's nature: can be instantiated, parental class: uncommitted primary attribute: // Router number int routnum; // Routing table Tablenode Table [MAX_ROUT_TABLE_SIZE]; class Main interface: // Set the number of routers void setnum (int _routnum); // Set the routing table void settable (TABLENODE _TABLE [MAX_ROUT_TABLE_SIZE]); // Get the next relay routing address int * GetDrNexthop (int AddRTO [IP_ADDRESS_LENGTH]); // Get the number of routers int gamenum (void); 10, network data packet name: NetData class's nature: can instantiate the parent class: Uncalar primary properties: / / Network Packet Source Address Unsigned Int AddressFrom [ip_address_length]; // Network Packet Target Address Unsigned Int AddresSsto [ip_address_length]; // Web Packet Before Relay Address Unsigned Int Prehop [Ip_address_length]; // Relay address after // Network Packet Unsigned INT NEXTHOP [IP_ADDRESS_LENGTH]; // Whether it is a message BOOL BMESSAGE; // Packet Tracking Counter: Message and IP Packet One Double ID; // Network Packet Data Information int ipdata [ip_address_length]; class of primary interface: // Judgment whether to answer message bool ismessage (void); // Judgment network packet whether The same Bool Operator == (NetData & NetData); // Setting Web Packet Source Address void setaddressFrom (unsigned int addrFrom [ip_address_length]); // Set network packet target address void setaddressto (unsigned INT AddRTO [ip_address_length]); // Get network data package source address unsigned int * getaddressFrom (void); // Get network packet target address unsigned int * getaddresSsto (Void); // Set network data Package Before Relay Address void setprehop (const unsigned int _prehop [ip_address_length]); // Set the network packet after the relay address

Void setnexthop (const unsigned int _nexthop [ip_address_length]); // Receive address unsigned int * getprehop (void) before the network packet; // After obtaining network packets, relay addresses unsigned int * getNextHop (void); // Set the data content of the IP packet void setipdata (const INT _IPDATA [ip_address_length]); // Get the data content of the IP packet int * getipdata (void); 11, communication class Nature of the COMMUNICATION class: Make-instantiated class parent class: Uncaracted major attributes: // Network simulation Net & Net; // Network data structure NetNode * & pnodeaRray; class main interface: // Single packet routing Void SingleDatarout (Void); <2004-4-10 Modification>

转载请注明原文地址:https://www.9cbs.com/read-25387.html

New Post(0)