def menu_return():
     if self.menu_special!=0:
         self.menu_special=0
         self.menu_deepth+=1
         self.menu_special_method=0
     if self.menu_deepth==1:
         IPs = Draw_Graph_0_0_1.draw()
         self.Rank(IPs)
         self.menu_deepth = 0
         self.control_title.config(text="选择连通子图")
         self.control_tip.config(text='IP节点                                    点的度')
     elif self.menu_deepth==2 or self.menu_deepth==3:
         self.control_title.config(text="第"+str(self.subgraph_num+1)+"连通子图")
         self.control_tip.config(text='IP节点                                    点的度')
         self.inform_Text1.config(text=0)
         self.inform_Text3.config(text=0)
         self.inform_Text5.config(text=0)
         self.inform_Text7.config(text=0)
         self.inform_Text9.config(text=0)
         Draw_Graph_0_0_1.change_subgraph(self.subgraph_num)
         self.img = Image.open('test.png')  # 打开图片
         self.photo = ImageTk.PhotoImage(self.img)  # 用PIL模块的PhotoImage打开
         self.Label_Image.config(image=self.photo)
         self.Label_Image.image = self.photo
         IPs = list(Draw_Graph_0_0_1.degree(0))
         self.Rank(IPs)
         self.menu_deepth = 1
 def menu_select():
     if self.menu_special==0:
         if self.menu_deepth==0:
             self.subgraph_num=self.ip_listbox.curselection()[0]
             self.control_title.config(text="第"+str(self.subgraph_num+1)+"连通子图")
             Draw_Graph_0_0_1.change_subgraph(self.subgraph_num)
             self.img = Image.open('test.png')  # 打开图片
             self.photo = ImageTk.PhotoImage(self.img)  # 用PIL模块的PhotoImage打开
             self.Label_Image.config(image=self.photo)
             self.Label_Image.image = self.photo
             IPs=list(Draw_Graph_0_0_1.degree(0))
             self.Rank(IPs)
             self.menu_deepth=1
         elif self.menu_deepth==1 or self.menu_deepth==2:
             string = str(self.ip_listbox.get(self.ip_listbox.curselection()[0]))
             string_part = string.split()
             nodes = Draw_Graph_0_0_1.draw_SingleIP(string_part[0])
             self.img = Image.open('test.png')  # 打开图片
             self.photo = ImageTk.PhotoImage(self.img)  # 用PIL模块的PhotoImage打开
             self.Label_Image.config(image=self.photo)
             self.Label_Image.image = self.photo
             IPs=Analyser.Node_Links_Analyse(nodes)
             self.Rank(IPs)
             self.control_title.config(text=string_part[0])
             self.control_tip.config(text="IP节点                                连接数")
             self.IP_details(string_part[0])
             self.menu_deepth=2
     elif self.menu_special==1:
         self.Choose_Ip_wrong_matched()
         self.menu_special=0
         self.menu_deepth=1
     elif self.menu_special==2:
         self.DH_Mode()
         self.menu_special = 0
         self.menu_deepth = 1
 def IP_details(self, IP):
     #print(IP+"*")
     mode = 0
     if self.all_node_flag == 1:
         mode = 0
     else:
         mode = 1
     IPs = Draw_Graph_0_0_1.degree(mode)
     for IP_degree in IPs:
         flag = cmp(IP, IP_degree[0])
         if flag == 0:
             self.inform_Text1.config(text=IP_degree[1])
             break
     IPs = Draw_Graph_0_0_1.betweeness(mode)
     for IP_betweeness in IPs:
         flag = cmp(IP, IP_betweeness[0])
         if flag == 0:
             self.inform_Text3.config(text=round(IP_betweeness[1], 5))
             break
     IPs = Draw_Graph_0_0_1.degree_centrality(mode)
     for IP_centrality in IPs:
         flag = cmp(IP, IP_centrality[0])
         if flag == 0:
             self.inform_Text5.config(text=round(IP_centrality[1], 5))
             break
     IP_list = []
     IP_list.append(IP)
     self.inform_Text7.config(
         text=Analyser.Node_Links_Analyse(IP_list)[0][1])
     self.inform_Text9.config(
         text=round(Analyser.Node_Length_Analyse(IP_list)[0][1], 5))
 def All_Node_Analyse():
     if self.load_in_flag == 1:
         global IPs
         self.control_title.config(text="所有节点")
         IPs = list(Draw_Graph_0_0_1.draw_all())
         img = Image.open('test.png')  # 打开图片
         photo = ImageTk.PhotoImage(img)  # 用PIL模块的PhotoImage打开
         self.Label_Image.config(image=photo)
         self.Label_Image.image = photo
         self.Rank(Draw_Graph_0_0_1.degree(0))
         self.menu_deepth = 1
         self.all_node_flag = 1
 def radCall():
     radSelect = self.radVar.get()
     if self.menu_special == 0 and self.menu_deepth != 0:
         if radSelect == 0:
             #self.control_title.config(text="度排序")
             self.control_tip.config(
                 text="IP节点                                点的度")
             IPs = list(Draw_Graph_0_0_1.degree(0))
             self.Rank(IPs)
         elif radSelect == 1:
             self.control_tip.config(
                 text="IP节点                                介数中心性")
             IPs = list(Draw_Graph_0_0_1.betweeness(0))
             self.Rank(Draw_Graph_0_0_1.betweeness(0))
         elif radSelect == 2:
             self.control_tip.config(
                 text="IP节点                                点度中心性")
             IPs = list(Draw_Graph_0_0_1.degree_centrality(0))
             self.Rank(Draw_Graph_0_0_1.degree_centrality(0))
         elif radSelect == 3:
             self.control_tip.config(
                 text="IP节点                                连接数")
             IPs = Draw_Graph_0_0_1.transfer_nodes()
             self.Rank(Analyser.Node_Links_Analyse(IPs))
         elif radSelect == 4:
             self.control_tip.config(
                 text="IP节点                                小包占比")
             IPs = Draw_Graph_0_0_1.transfer_nodes()
             self.Rank(Analyser.Node_Length_Analyse(IPs))
示例#6
0
        def menu_return():
            if self.menu_deepth == 1:
                IPs = Draw_Graph_0_0_1.draw()
                self.Rank(IPs)
                self.menu_deepth = 0
                self.control_title.config(text="选择连通子图")
                self.control_tip.config(
                    text='IP节点                                    点的度')

            elif self.menu_deepth == 2:
                self.control_title.config(text="第" +
                                          str(self.subgraph_num + 1) + "连通子图")
                self.control_tip.config(
                    text='IP节点                                    点的度')
                Draw_Graph_0_0_1.change_subgraph(self.subgraph_num)
                self.img = Image.open('test.png')  # 打开图片
                self.photo = ImageTk.PhotoImage(
                    self.img)  # 用PIL模块的PhotoImage打开
                self.Label_Image.config(image=self.photo)
                self.Label_Image.image = self.photo
                IPs = list(Draw_Graph_0_0_1.degree(0))
                self.Rank(IPs)
                self.menu_deepth = 1
 def Load_In():
     IPs = Draw_Graph_0_0_1.draw()
     self.Rank(IPs)
     self.load_in_flag = 1
     self.menu_deepth = 0
 def menu_select():
     if self.menu_special == 0:
         if self.Section_for_Analyse == 1 or self.Section_for_Analyse == 0:
             if self.menu_deepth == 0:
                 self.subgraph_num = self.ip_listbox.curselection()[0]
                 self.control_title.config(
                     text="第" + str(self.subgraph_num + 1) + "连通子图")
                 Draw_Graph_0_0_1.change_subgraph(self.subgraph_num)
                 self.img = Image.open('test.png')  # 打开图片
                 self.photo = ImageTk.PhotoImage(
                     self.img)  # 用PIL模块的PhotoImage打开
                 self.Label_Image.config(image=self.photo)
                 self.Label_Image.image = self.photo
                 IPs = list(Draw_Graph_0_0_1.degree(0))
                 self.Rank(IPs)
                 self.menu_deepth = 1
             elif self.menu_deepth == 1 or self.menu_deepth == 2:
                 string = str(
                     self.ip_listbox.get(
                         self.ip_listbox.curselection()[0]))
                 string_part = string.split()
                 nodes = Draw_Graph_0_0_1.draw_SingleIP(string_part[0])
                 self.img = Image.open('test.png')  # 打开图片
                 self.photo = ImageTk.PhotoImage(
                     self.img)  # 用PIL模块的PhotoImage打开
                 self.Label_Image.config(image=self.photo)
                 self.Label_Image.image = self.photo
                 IPs = Analyser.Node_Links_Analyse(nodes)
                 self.Rank(IPs)
                 self.control_title.config(text=string_part[0])
                 self.control_tip.config(
                     text="IP节点                                连接数")
                 self.IP_details(string_part[0])
                 self.menu_deepth = 2
         elif self.Section_for_Analyse == 2:
             string = str(
                 self.ip_listbox.get(self.ip_listbox.curselection()[0]))
             IP = re.split(r"->| ", string)
             Draw_Graph_0_0_1.draw_Line(IP[0], IP[1])
             self.img = Image.open('Line.png')  # 打开图片
             self.photo = ImageTk.PhotoImage(
                 self.img)  # 用PIL模块的PhotoImage打开
             self.Label_Image.config(image=self.photo)
             self.Label_Image.image = self.photo
             '''
             protocols=Analyser.Link_Protocol_Analyse(IP[0], IP[1],0)
             protocol_proper=[]
             for protocol in protocols:
                 string = str(protocol)
                 IP = re.split(r"/|", string)
                 protocol_proper.append(IP[1])
             Draw_Graph_0_0_1.draw_pie(protocol_proper)
             self.img = Image.open('pie.png')  # 打开图片
             self.photo = ImageTk.PhotoImage(self.img)  # 用PIL模块的PhotoImage打开
             self.Label_Image.config(image=self.photo)
             self.Label_Image.image = self.photo
             '''
     elif self.menu_special == 1:
         self.Choose_Ip_wrong_matched()
         self.menu_special = 0
         self.menu_deepth = 1
     elif self.menu_special == 2:
         self.DH_Mode()
         self.menu_special = 0
         self.menu_deepth = 1
        self.ip_listbox.insert('end', IP[0])
        self.ip_listbox.insert('end', IP[1])
        self.control_tip.config(text="IP节点                                   ")
        self.ip_listbox.select_set(0)
    def DH_Mode(self):
        if self.menu_special_method==0:
            string = str(self.ip_listbox.get(self.ip_listbox.curselection()[0]))
            IP = re.split(r"->| ", string)
            self.ip_listbox.delete(0, 'end')
            self.ip_listbox.insert('end', IP[0])
            self.ip_listbox.insert('end', IP[1])
            self.ip_listbox.insert('end', IP[2])
            self.control_tip.config(text="IP节点                                   ")
            self.ip_listbox.select_set(0)
        elif self.menu_special_method==1:
            string = str(self.ip_listbox.get(self.ip_listbox.curselection()[0]))
            IP = re.split(r"->| ", string)
            self.ip_listbox.delete(0, 'end')
            self.ip_listbox.insert('end', IP[0])
            self.control_tip.config(text="IP节点                                   ")
            self.ip_listbox.select_set(0)

IPs = Draw_Graph_0_0_1.draw()
root = Tk()
root.title("APP")
app = App(root)
app.Rank(IPs)
root.mainloop()

# string = str(self.ip_listbox.get(self.ip_listbox.curselection()[0]))
# string_part=string.split();