⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 bgp.frm

📁 网络路由震荡模拟器
💻 FRM
📖 第 1 页 / 共 2 页
字号:
VERSION 5.00
Begin VB.Form bgp 
   Caption         =   "路由反射震荡模拟"
   ClientHeight    =   6075
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   8475
   ClipControls    =   0   'False
   ControlBox      =   0   'False
   BeginProperty Font 
      Name            =   "MS Sans Serif"
      Size            =   13.5
      Charset         =   0
      Weight          =   400
      Underline       =   0   'False
      Italic          =   0   'False
      Strikethrough   =   0   'False
   EndProperty
   LinkTopic       =   "Form1"
   ScaleHeight     =   6075
   ScaleWidth      =   8475
   StartUpPosition =   3  'Windows Default
   Begin VB.Timer Timer1 
      Enabled         =   0   'False
      Interval        =   500
      Left            =   360
      Top             =   5520
   End
   Begin VB.CommandButton rturnCmd 
      Caption         =   "返    回"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   495
      Left            =   6720
      TabIndex        =   3
      Top             =   5400
      Width           =   1335
   End
   Begin VB.CommandButton stopCmd 
      Caption         =   "停    止"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   495
      Left            =   4140
      TabIndex        =   2
      Top             =   5400
      Width           =   1335
   End
   Begin VB.CommandButton bgpSimulateCmd 
      Caption         =   "路由反射模拟"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   495
      Left            =   1560
      TabIndex        =   1
      Top             =   5400
      Width           =   1335
   End
   Begin VB.PictureBox Picture1 
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   12
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   4695
      Left            =   480
      ScaleHeight     =   4635
      ScaleWidth      =   7635
      TabIndex        =   0
      Top             =   360
      Width           =   7695
   End
End
Attribute VB_Name = "bgp"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Option Compare Text
Dim flashTag As Boolean
Dim stopSimulate As Boolean
Dim dot As String
Dim path1 As Integer
Dim path2 As Integer
Dim path3 As Integer
Dim flashnum As Integer
Dim pOptimize As Integer
Dim lOptimize As Integer
Dim pPath() As String  'p的路由表
Dim lPath() As String  'l的路由表
'Public Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)


Private Sub bgpSimulateCmd_Click()
'Public Declare Function SleepEx Lib "kernel32" (ByVal dwMilliseconds As Long, ByVal bAlertable As Long) As Long

Dim dt As Variant
Dim i As Integer
Do
    dt = DoEvents()
    If stopSimulate = True Then
       Exit Sub
    End If
        dot = "l"
        path1 = lPath(1, 0)
        path2 = lPath(2, 0)
        path3 = lPath(3, 0)
        flashnum = 0
        flashTag = False
        Timer1.Enabled = True
        flashRotue dot, path1, path2, path3

       lOptimize = SelectPath(lPath)  'l从路由表中选取最优路由
       drawOptimizeRouter "l", lOptimize
        
       
    insertPathTo pPath, lPath, lOptimize, "l"              'l从路由表中选取最优路由通告给p
    DoEvents
    Sleep (2000)
    
    dot = "p"
        path1 = pPath(1, 0)
        path2 = pPath(2, 0)
        path3 = pPath(3, 0)
        flashnum = 0
        flashTag = False
        Timer1.Enabled = True
        Timer1.Enabled = True
        flashRotue dot, path1, path2, path3

        pOptimize = SelectPath(pPath)  'p从路由表中选取最优路由
        drawOptimizeRouter "p", pOptimize
     
    insertPathTo lPath, pPath, pOptimize, "p"               'p从路由表中选取最优路由通告给p
    DoEvents
    Sleep (2000)
        'dot = "p"
        'path1 = 1
       ' path2 = 0
       ' path3 = 3
       ' flashnum = 0
       ' Timer1.Enabled = True
If (lOptimize = pOptimize And lOptimize <> 0 And pOptimize <> 0) Then
   Exit Do
End If
Loop
End Sub


Private Sub drawOptimizeRouter(ByVal dot As String, ByVal p1 As String)
 If dot = "l" Then
        
          If p1 = 1 Then
                Picture1.Line (60, 55)-(80, 35), RGB(255, 128, 128) 'n-l
                Picture1.Line (60, 65)-(60, 115), RGB(255, 128, 128) 'n-o
                Picture1.Line (160, 165)-(60, 125), RGB(255, 128, 128) 'k-o
        
          End If
          If p1 = 2 Then
                Picture1.Line (100, 55)-(80, 35), RGB(255, 128, 128) 'm-l
                Picture1.Line (100, 65)-(150, 115), RGB(255, 128, 128)  'm-s
                Picture1.Line (160, 165)-(150, 125), RGB(255, 128, 128)  'k-s
        
          End If
          If p1 = 3 Then
               Picture1.Line (175, 30)-(85, 30), RGB(255, 128, 128)  'p-l
               Picture1.Line (180, 35)-(180, 55), RGB(255, 128, 128)  'p-r
               Picture1.Line (180, 65)-(150, 115), RGB(255, 128, 128)  'r-s
               Picture1.Line (160, 165)-(150, 125), RGB(255, 128, 128)  'k-s
        
          End If
        End If
        
        If dot = "p" Then
        
          If p1 = 1 Then
                Picture1.Line (175, 30)-(85, 30), RGB(255, 128, 128)  'p-l
                Picture1.Line (60, 55)-(80, 35), RGB(255, 128, 128) 'n-l
                Picture1.Line (60, 65)-(60, 115), RGB(255, 128, 128) 'n-o
                Picture1.Line (160, 165)-(60, 125), RGB(255, 128, 128) 'k-o
        
          End If
          If p1 = 2 Then
                Picture1.Line (175, 30)-(85, 30), RGB(255, 128, 128)  'p-l
                Picture1.Line (100, 55)-(80, 35), RGB(255, 128, 128) 'm-l
                Picture1.Line (100, 65)-(150, 115), RGB(255, 128, 128)  'm-s
                Picture1.Line (160, 165)-(150, 125), RGB(255, 128, 128)  'k-s
        
          End If
          If p1 = 3 Then
               
               Picture1.Line (180, 35)-(180, 55), RGB(255, 128, 128)  'p-r
               Picture1.Line (180, 65)-(150, 115), RGB(255, 128, 128)  'r-s
               Picture1.Line (160, 165)-(150, 125), RGB(255, 128, 128)  'k-s
        
          End If
          
        End If
        
End Sub


'///////////转告路由///////////
Private Sub insertPathTo(ByRef p() As String, ByRef p1() As String, ByVal opt As Integer, ByVal dot As String)
Dim router As Integer
Dim i As Integer


For i = 3 To 1 Step -1
      If p1(i, 0) = opt Then
        router = i
        Exit For
      End If
    Next i
'/////////先判断路由表中有没有从p1得到的路由,有的话先撤销

    For i = 3 To 1 Step -1
      If p(i, 5) = dot Then
        p(i, 0) = 0
        If dot = "l" Then pOptimize = SelectPath(pPath)  'p从路由表中选取最优路由
        If dot = "p" Then lOptimize = SelectPath(lPath)
        Exit For
      End If
    Next i


'////////在判断有没有和 opt 相同的路由,没有的话在插入
For i = 1 To 3
      If p(i, 0) = opt Or p(i, 0) = 0 Then
      
            p(i, 0) = opt
            p(i, 1) = p1(router, 1)
            p(i, 2) = p1(router, 2)
            p(i, 3) = p1(router, 3)
            p(i, 4) = p1(router, 4)
            p(i, 5) = p1(router, 5)
            If p1(router, 5) = "p" And dot = "l" Then
                 p(i, 5) = "r"
                 p(i, 4) = "0'"
            End If
            If p1(router, 5) = "m" And dot = "l" Then
                 p(i, 5) = "l"
                 p(i, 4) = "5"
             End If
             If p1(router, 5) = "n" And dot = "l" Then
                 p(i, 5) = "l"
                 p(i, 4) = "7"
             End If
             
             
             
              If p1(router, 5) = "r" And dot = "p" Then
                 p(i, 5) = "p"
                 p(i, 4) = "11"
            End If
            If p1(router, 5) = "l" And dot = "p" Then
                 If p1(router, 1) = "2" Then
                    p(i, 5) = "n"
                    p(i, 4) = "6"
                 Else
                   p(i, 5) = "m"
                   p(i, 4) = "4"
                 End If
             End If
             'If p1(router, 5) = "n" And dot = "p" Then
             '    p(i, 5) = "l"
            ' End If
             
             Exit For
      End If
    Next i
    
  
        
    
    






End Sub
'///////////选择路由///////////
Private Function SelectPath(ByRef p() As String) As Integer
Dim i, j, k As Integer
Dim opt As Integer
Dim path As Integer
opt = 10000
For i = 3 To 1 Step -1
  If p(i, 0) <> 0 Then
    k = i
    Exit For
  End If
Next i
If k = 1 Then
  SelectPath = p(k, 1)
  Exit Function
End If
  path = k
  For i = k - 1 To 1 Step -1
     
     
     If Val(p(i, 1)) = Val(p(k, 1)) And p(i, 2) = p(k, 2) Then
        If Val(p(i, 3)) < Val(p(k, 3)) Then
              path = p(i, 0)
        Else
             'path = p(k, 0)
        End If
     Else
        If Val(p(i, 4)) < Val(p(k, 4)) Then
        
              path = p(i, 0)
         Else
             path = p(k, 0)
        End If
     
     End If
     
     
  Next i
  SelectPath = path
End Function
Private Sub Form_Load()
Init_BoXing
'flashRotue "p", 1, 2, 3
lOptimize = 0
pOptimize = 0
ReDim pPath(1 To 3, 0 To 5) As String 'p的路由表

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -