P2Psim Analysis notes (4)-Topology and Network

Source: Internet
Author: User

In the analysis section above, the third step of taskmain is to enable the Topology class to analyze topology_file and start the Network object. This time, I will mainly introduce the detailed process of this part. The main content includes the Mechanism Analysis of the Topology class and sub-class Euclidian Topology class, Failure Model class and Network Class interaction. After understanding this, We will basically clarify the P2PSim startup mechanism. By convention, I have provided a general flowchart of the process involved here. 650) this. width = 650; "onclick = 'window. open (" http://blog.51cto.com/viewpic.php?refimg= "+ This. src) 'style = "border-bottom: 0px; border-left: 0px; border-top: 0px; border-right: 0px "title =" "border =" 0 "alt =" "src =" http://www.bkjia.com/uploads/allimg/131228/1R2163944-0.jpg "Height =" 788 "1011? = ""/> This part of the call is caused by Topology: parse (topology_file) in taskmain function. In the pase function, the name of topology is first read from topology_file, such as the Euclidian topology and the corresponding failure model. As for the failure model, it seems that it is used to set the packet loss policy in data transmission. This is not my interest, so I am too lazy to analyze it carefully. If this parameter is not specified in topology_file, an nullfailure model without packet loss is provided by default. In topology and failure models, their constructors do nothing special. The top and fm objects are used as parameters to construct Network object instances. In the structure of the Network object, the topology and failure models are saved to the Network object. In the future, only Network instances will be available for access. Finally, thread is called in the Network object structure to run the run function as a task. In this function, the Network instance opens a mechanism for communication between tasks in channellibtask), and then continuously reads the Node (peer) information from the topology object from this channel. Save it to your _ nodes member. This member is a map of IPaddress and Node pointer. Finally, Topology: parse) calls the parse of the topology object to complete the parsing of the remaining part of topology_file. Note that the top pointer of the toplogy object is a subclass object of the Topology class, such as an object of the Euclidian class. Next, we will take the Euclidian topology as an example.
IPaddress x, y
To parse the location of the peer in the space, and use ipaddress to identify the peer. Parse each record and construct the object of a Node class subclass in the factory mode. Besides saving it in the _ nodes member, it is also a map from IPaddress to node ), the run function sent to the Network object through the channel. The yellow and green arrows in the figure indicate the contact.

This article is from the Nathan technical space blog, please be sure to keep this source http://nathanxu.blog.51cto.com/50836/247545

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.