Internet traffic?!

Für allgemeine Fragen zur Programmierung mit PureBasic.
Benutzeravatar
Buggymonkey
Beiträge: 47
Registriert: 02.09.2004 19:36
Wohnort: Löhne
Kontaktdaten:

Internet traffic?!

Beitrag von Buggymonkey »

Hallo liebe PureBasic Gemeinde,
ich möchte den traffic herraus bekommen, habe schon beim Googeln herraus bekommen, dass man das irgendwie über das internet protokoll machen muss, Wie kann ich dass internet protokoll öffnen?, und den traffic auslesen?

Danke für eure Hilfe :wink:

Gruß Nils
wenn wer rechtschreibfehler findet, kann er sie behalten, :)

Ich würde gern die Welt verändern,
doch Gott gibt mir den Quellcode nicht!

http://www.house-of-chat.de umbedingt mal vorbei schaun ^^
Benutzeravatar
Then
Beiträge: 281
Registriert: 06.09.2004 13:26
Wohnort: Siegen

Beitrag von Then »

Auf PureBasic.net ist ein Codebeispiel, dass leider nicht mehr funzt, kannst es ja evtl mal umfummeln und neu posten, ich probiere das auch gerade aus ! Wäre toll, wenn man evtl mal das CodeArchiv auf PB3.92 updaten könnte und die Codes entsprechend anpasst (oder PB an die Codes wieder anpassen würde ! /:-> )
Benutzeravatar
Buggymonkey
Beiträge: 47
Registriert: 02.09.2004 19:36
Wohnort: Löhne
Kontaktdaten:

Beitrag von Buggymonkey »

hi, danke für die antwort, ich weiß aber nicht wirklich welches bei spiel du meist ich habe schon öffters den internet&co ordner "durchwühlt" habe aber nichts wirklich brauchbares gefunden

Gruß Nils
wenn wer rechtschreibfehler findet, kann er sie behalten, :)

Ich würde gern die Welt verändern,
doch Gott gibt mir den Quellcode nicht!

http://www.house-of-chat.de umbedingt mal vorbei schaun ^^
Benutzeravatar
Then
Beiträge: 281
Registriert: 06.09.2004 13:26
Wohnort: Siegen

Beitrag von Then »

Here it is :

Code: Alles auswählen

Procedure.l GetIFInfo() 
#MAX_INTERFACE_NAME_LEN = 256 
#MAXLEN_PHYSADDR        = 8 
#MAXLEN_IFDESCR         = 256 

#ERROR_SUCCESS = 0 

#MIB_IF_TYPE_OTHER     = 1 
#MIB_IF_TYPE_ETHERNET  = 6 
#MIB_IF_TYPE_TOKENRING = 9 
#MIB_IF_TYPE_FDDI      = 15 
#MIB_IF_TYPE_PPP       = 23 
#MIB_IF_TYPE_LOOPBACK  = 24 
#MIB_IF_TYPE_SLIP      = 28 

Structure MIB_IFROW 
  wszName.b[#MAX_INTERFACE_NAME_LEN*2] 
  dwIndex.l                        ; index of the interface 
  dwType.l                         ; type of interface 
  dwMtu.l                          ; max transmission unit 
  dwSpeed.l                        ; speed of the interface 
  dwPhysAddrLen.l                  ; length of physical address 
  bPhysAddr.b[#MAXLEN_PHYSADDR]    ; physical address of adapter 
  dwAdminStatus.l                  ; administrative status 
  dwOperStatus.l                   ; operational status 
  dwLastChange.l                   ; last time operational status changed 
  dwInOctets.l                     ; octets received 
  dwInUcastPkts.l                  ; unicast packets received 
  dwInNUcastPkts.l                 ; non-unicast packets received 

  dwInDiscards.l                   ; received packets discarded 
  dwInErrors.l                     ; erroneous packets received 
  dwInUnknownProtos.l              ; unknown protocol packets received 
  dwOutOctets.l                    ; octets sent 
  dwOutUcastPkts.l                 ; unicast packets sent 
  dwOutNUcastPkts.l                ; non-unicast packets sent 
  dwOutDiscards.l                  ; outgoing packets discarded 
  dwOutErrors.l                    ; erroneous packets sent 
  dwOutQLen.l                      ; output queue length 
  dwDescrLen.l                     ; length of bDescr member 
  bDescr.b[#MAXLEN_IFDESCR]        ; interface description 
EndStructure 



IPInterfaceRow.MIB_IFROW 
Buffer.l 
BufferSize.l 
nStructSize.l 
nRows.l 
cnt.l 



BufferSize=0 
RetCode.l = GetIfTable_(#NULL,@BufferSize,#TRUE) 
If RetCode = 122 

  
  AllocateMemory(0,BufferSize,0) 
  Buffer = MemoryID() 
  
  GetIfTable_(Buffer,@BufferSize,#TRUE); = #ERROR_SUCCESS 
    nStructSize = SizeOf(IPInterfaceRow) 
    CopyMemory(Buffer,@nRows,4) 
    
    Dim ListArray.s (nRows, 20) 
    ListArray(0,0)  = "Interface Description" 
    ListArray(0,1)  = "Index of the Interface" 
    ListArray(0,2)  = "Type of interface" 
    ListArray(0,3)  = "Max transmission unit" 
    ListArray(0,4)  = "Speed of the interface" 
    ListArray(0,5)  = "Physical address of adapter"    
    ListArray(0,6)  = "Administrative status" 
    ListArray(0,7)  = "Operational status" 
    ListArray(0,8)  = "Last time operational status changed" 
    ListArray(0,9)  = "Octets received" 
    ListArray(0,10) = "Octets sent " 
    ListArray(0,11) = "Unicast packets received " 
    ListArray(0,12) = "Unicast packets sent" 
    ListArray(0,13) = "Non-unicast packets received"    
    ListArray(0,14) = "Non-unicast packets sent" 
    ListArray(0,15) = "Received packets discarded" 
    ListArray(0,16) = "Outgoing packets discarded" 
    ListArray(0,17) = "Erroneous packets received" 
    ListArray(0,18) = "Erroneous packets sent" 
    ListArray(0,19) = "Unknown protocol packets received" 
    ListArray(0,20) = "Output queue length" 

    
    For cnt = 1 To nRows 
    
      CopyMemory((Buffer +4 + (cnt - 1) * nStructSize),@IPInterfaceRow, nStructSize) 
        
        For i = 0 To (IPInterfaceRow\dwDescrLen - 1) 

          IF_Description.s 
          IF_Description = IF_Description + Chr(IPInterfaceRow\bDescr[i]) 
        
        Next 
        
        For j = 0 To (IPInterfaceRow\dwPhysAddrLen - 1) 

          IF_PhysAddress.s 
          
          If j<>(IPInterfaceRow\dwPhysAddrLen - 1)          
            IF_PhysAddress = IF_PhysAddress + Hex(IPInterfaceRow\bPhysAddr[j]) + "-" 
          Else 
            IF_PhysAddress = IF_PhysAddress + Hex(IPInterfaceRow\bPhysAddr[j]) 
          EndIf 
          
          If FindString(IF_PhysAddress,"FFFFFF",1) 
            IF_PhysAddress = RemoveString(IF_PhysAddress, "FFFFFF",1) 
          EndIf 
        
        Next 

        If Len(IF_PhysAddress) = 0 
          IF_PhysAddress = "No physical address" 
        EndIf 


        ListArray(cnt,0)  = IF_Description 
        ListArray(cnt,1)  = Str(IPInterfaceRow\dwIndex) 
        ListArray(cnt,2)  = Str(IPInterfaceRow\dwType)        
        ListArray(cnt,3)  = Str(IPInterfaceRow\dwMtu) 
        ListArray(cnt,4)  = Str(IPInterfaceRow\dwSpeed) 
        ListArray(cnt,5)  = IF_PhysAddress    
        ListArray(cnt,6)  = Str(IPInterfaceRow\dwAdminStatus) 
        ListArray(cnt,7)  = Str(IPInterfaceRow\dwOperStatus) 
        ListArray(cnt,8)  = Str(IPInterfaceRow\dwLastChange)        
        ListArray(cnt,9)  = Str(IPInterfaceRow\dwInOctets) 
        ListArray(cnt,10) = Str(IPInterfaceRow\dwOutOctets) 
        ListArray(cnt,11) = Str(IPInterfaceRow\dwInUcastPkts) 
        ListArray(cnt,12) = Str(IPInterfaceRow\dwOutUcastPkts) 
        ListArray(cnt,13) = Str(IPInterfaceRow\dwInNUcastPkts)    
        ListArray(cnt,14) = Str(IPInterfaceRow\dwOutNUcastPkts) 
        ListArray(cnt,15) = Str(IPInterfaceRow\dwInDiscards) 
        ListArray(cnt,16) = Str(IPInterfaceRow\dwOutDiscards) 
        ListArray(cnt,17) = Str(IPInterfaceRow\dwInErrors) 
        ListArray(cnt,18) = Str(IPInterfaceRow\dwOutErrors) 
        ListArray(cnt,19) = Str(IPInterfaceRow\dwInUnknownProtos) 
        ListArray(cnt,20) = Str(IPInterfaceRow\dwOutQLen) 
                
        IF_PhysAddress = "" 
        IF_Description = "" 
      
     Next 

EndIf 

ProcedureReturn nRows 
EndProcedure 




If OpenWindow(0,500,500,580,320,#PB_Window_SystemMenu|#PB_Window_ScreenCentered,"Interface List") 

  If CreateGadgetList(WindowID(0)) 
    ListIconGadget(0, 0, 0, 580, 318, "Value",192,#PB_ListIcon_GridLines) 

      nRows.l = GetIFInfo() 
      For a=1 To nRows          ; fügt weitere Spalten zum ListIcon hinzu 
        AddGadgetColumn(0,a,"Interface "+Str(a),(384/nRows)) 
      Next 

        
      For b=0 To 20          ; fügt 4 Einträge auf jeder Zeile des ListIcons hinzu 
          y=b    
          AddGadgetItem(0,b,ListArray(0,b)); + Chr(10)+LineArray(b)) 
      Next 
  EndIf 


  Repeat 

    If nRows <> GetIFInfo() 
      FreeGadget(0) 
      If CreateGadgetList(WindowID(0)) 
      ListIconGadget(0, 0, 0, 580, 318, "Value",192,#PB_ListIcon_GridLines) 

        nRows.l = GetIFInfo() 
        For a=1 To nRows          ; fügt weitere Spalten zum ListIcon hinzu 
          AddGadgetColumn(0,a,"Interface "+Str(a),(384/nRows)) 
        Next 

        
        For b=0 To 20          ; fügt 4 Einträge auf jeder Zeile des ListIcons hinzu 
          y=b    
          AddGadgetItem(0,b,ListArray(0,b)); + Chr(10)+LineArray(b)) 
        Next 
      EndIf 

    EndIf 

    nRows = GetIFInfo() 
    For b=0 To 20 
      For a=1 To nRows 
        SetGadgetItemText(0, b, ListArray(a,b) , a) 
      Next 
    Next 

    Delay(80) 
  Until WindowEvent()=#PB_Event_CloseWindow 
EndIf 
Viel Glück ! Lass mich wissen, ob Du was brauchbares geschafft hast !
Benutzeravatar
Buggymonkey
Beiträge: 47
Registriert: 02.09.2004 19:36
Wohnort: Löhne
Kontaktdaten:

Beitrag von Buggymonkey »

naja so schwer ist es ja nicht den code zum laufen zu bringen,
aber sind die werte richtig? wenn ja, wo steht wie viele bytes raus und wieviele rein kommen???

Hier noch mal der code:

Code: Alles auswählen

Procedure.l GetIFInfo()
  #MAX_INTERFACE_NAME_LEN = 256
  #MAXLEN_PHYSADDR        = 8
  #MAXLEN_IFDESCR         = 256
  
  #ERROR_SUCCESS = 0
  
  #MIB_IF_TYPE_OTHER     = 1
  #MIB_IF_TYPE_ETHERNET  = 6
  #MIB_IF_TYPE_TOKENRING = 9
  #MIB_IF_TYPE_FDDI      = 15
  #MIB_IF_TYPE_PPP       = 23
  #MIB_IF_TYPE_LOOPBACK  = 24
  #MIB_IF_TYPE_SLIP      = 28
  
  Structure MIB_IFROW
    wszName.b[#MAX_INTERFACE_NAME_LEN*2]
    dwIndex.l                        ; index of the interface
    dwType.l                         ; type of interface
    dwMtu.l                          ; max transmission unit
    dwSpeed.l                        ; speed of the interface
    dwPhysAddrLen.l                  ; length of physical address
    bPhysAddr.b[#MAXLEN_PHYSADDR]    ; physical address of adapter
    dwAdminStatus.l                  ; administrative status
    dwOperStatus.l                   ; operational status
    dwLastChange.l                   ; last time operational status changed
    dwInOctets.l                     ; octets received
    dwInUcastPkts.l                  ; unicast packets received
    dwInNUcastPkts.l                 ; non-unicast packets received
    
    dwInDiscards.l                   ; received packets discarded
    dwInErrors.l                     ; erroneous packets received
    dwInUnknownProtos.l              ; unknown protocol packets received
    dwOutOctets.l                    ; octets sent
    dwOutUcastPkts.l                 ; unicast packets sent
    dwOutNUcastPkts.l                ; non-unicast packets sent
    dwOutDiscards.l                  ; outgoing packets discarded
    dwOutErrors.l                    ; erroneous packets sent
    dwOutQLen.l                      ; output queue length
    dwDescrLen.l                     ; length of bDescr member
    bDescr.b[#MAXLEN_IFDESCR]        ; interface description
  EndStructure
  
  
  
  IPInterfaceRow.MIB_IFROW
  Buffer.l
  BufferSize.l
  nStructSize.l
  nRows.l
  cnt.l
  
  
  
  BufferSize=0
  RetCode.l = GetIfTable_(#Null,@BufferSize,#True)
  If RetCode = 122
    
    
    Buffer = AllocateMemory(BufferSize)
    
    GetIfTable_(Buffer,@BufferSize,#True); = #ERROR_SUCCESS
    nStructSize = SizeOf(IPInterfaceRow)
    CopyMemory(Buffer,@nRows,4)
    
    Dim ListArray.s (nRows, 20)
    ListArray(0,0)  = "Interface Description"
    ListArray(0,1)  = "Index of the Interface"
    ListArray(0,2)  = "Type of interface"
    ListArray(0,3)  = "Max transmission unit"
    ListArray(0,4)  = "Speed of the interface"
    ListArray(0,5)  = "Physical address of adapter"   
    ListArray(0,6)  = "Administrative status"
    ListArray(0,7)  = "Operational status"
    ListArray(0,8)  = "Last time operational status changed"
    ListArray(0,9)  = "Octets received"
    ListArray(0,10) = "Octets sent "
    ListArray(0,11) = "Unicast packets received "
    ListArray(0,12) = "Unicast packets sent"
    ListArray(0,13) = "Non-unicast packets received"   
    ListArray(0,14) = "Non-unicast packets sent"
    ListArray(0,15) = "Received packets discarded"
    ListArray(0,16) = "Outgoing packets discarded"
    ListArray(0,17) = "Erroneous packets received"
    ListArray(0,18) = "Erroneous packets sent"
    ListArray(0,19) = "Unknown protocol packets received"
    ListArray(0,20) = "Output queue length"
    
    
    For cnt = 1 To nRows
      
      CopyMemory((Buffer +4 + (cnt - 1) * nStructSize),@IPInterfaceRow, nStructSize)
      
      For i = 0 To (IPInterfaceRow\dwDescrLen - 1)
        
        IF_Description.s
        IF_Description = IF_Description + Chr(IPInterfaceRow\bDescr[i])
        
      Next
      
      For j = 0 To (IPInterfaceRow\dwPhysAddrLen - 1)
        
        IF_PhysAddress.s
        
        If j<>(IPInterfaceRow\dwPhysAddrLen - 1)         
          IF_PhysAddress = IF_PhysAddress + Hex(IPInterfaceRow\bPhysAddr[j]) + "-"
        Else
          IF_PhysAddress = IF_PhysAddress + Hex(IPInterfaceRow\bPhysAddr[j])
        EndIf
        
        If FindString(IF_PhysAddress,"FFFFFF",1)
          IF_PhysAddress = RemoveString(IF_PhysAddress, "FFFFFF",1)
        EndIf
        
      Next
      
      If Len(IF_PhysAddress) = 0
        IF_PhysAddress = "No physical address"
      EndIf
      
      
      ListArray(cnt,0)  = IF_Description
      ListArray(cnt,1)  = Str(IPInterfaceRow\dwIndex)
      ListArray(cnt,2)  = Str(IPInterfaceRow\dwType)       
      ListArray(cnt,3)  = Str(IPInterfaceRow\dwMtu)
      ListArray(cnt,4)  = Str(IPInterfaceRow\dwSpeed)
      ListArray(cnt,5)  = IF_PhysAddress   
      ListArray(cnt,6)  = Str(IPInterfaceRow\dwAdminStatus)
      ListArray(cnt,7)  = Str(IPInterfaceRow\dwOperStatus)
      ListArray(cnt,8)  = Str(IPInterfaceRow\dwLastChange)       
      ListArray(cnt,9)  = Str(IPInterfaceRow\dwInOctets)
      ListArray(cnt,10) = Str(IPInterfaceRow\dwOutOctets)
      ListArray(cnt,11) = Str(IPInterfaceRow\dwInUcastPkts)
      ListArray(cnt,12) = Str(IPInterfaceRow\dwOutUcastPkts)
      ListArray(cnt,13) = Str(IPInterfaceRow\dwInNUcastPkts)   
      ListArray(cnt,14) = Str(IPInterfaceRow\dwOutNUcastPkts)
      ListArray(cnt,15) = Str(IPInterfaceRow\dwInDiscards)
      ListArray(cnt,16) = Str(IPInterfaceRow\dwOutDiscards)
      ListArray(cnt,17) = Str(IPInterfaceRow\dwInErrors)
      ListArray(cnt,18) = Str(IPInterfaceRow\dwOutErrors)
      ListArray(cnt,19) = Str(IPInterfaceRow\dwInUnknownProtos)
      ListArray(cnt,20) = Str(IPInterfaceRow\dwOutQLen)
      
      IF_PhysAddress = ""
      IF_Description = ""
      
    Next
    
  EndIf
  
  ProcedureReturn nRows
EndProcedure




If OpenWindow(0,500,500,580,320,#PB_Window_SystemMenu|#PB_Window_ScreenCentered,"Interface List")
  
  If CreateGadgetList(WindowID(0))
    ListIconGadget(0, 0, 0, 580, 318, "Value",192,#PB_ListIcon_GridLines)
    
    nRows.l = GetIFInfo()
    For a=1 To nRows          ; fügt weitere Spalten zum ListIcon hinzu
      AddGadgetColumn(0,a,"Interface "+Str(a),(384/nRows))
    Next
    
    
    For b=0 To 20          ; fügt 4 Einträge auf jeder Zeile des ListIcons hinzu
      y=b   
      AddGadgetItem(0,b,ListArray(0,b)); + Chr(10)+LineArray(b))
    Next
  EndIf
  
  
  Repeat
    
    If nRows <> GetIFInfo()
      FreeGadget(0)
      If CreateGadgetList(WindowID(0))
        ListIconGadget(0, 0, 0, 580, 318, "Value",192,#PB_ListIcon_GridLines)
        
        nRows.l = GetIFInfo()
        For a=1 To nRows          ; fügt weitere Spalten zum ListIcon hinzu
          AddGadgetColumn(0,a,"Interface "+Str(a),(384/nRows))
        Next
        
        
        For b=0 To 20          ; fügt 4 Einträge auf jeder Zeile des ListIcons hinzu
          y=b   
          AddGadgetItem(0,b,ListArray(0,b)); + Chr(10)+LineArray(b))
        Next
      EndIf
      
    EndIf
    
    nRows = GetIFInfo()
    For b=0 To 20
      For a=1 To nRows
        SetGadgetItemText(0, b, ListArray(a,b) , a)
      Next
    Next
    
    Delay(80)
  Until WindowEvent()=#PB_Event_CloseWindow
EndIf 
Danke Nils
wenn wer rechtschreibfehler findet, kann er sie behalten, :)

Ich würde gern die Welt verändern,
doch Gott gibt mir den Quellcode nicht!

http://www.house-of-chat.de umbedingt mal vorbei schaun ^^
Benutzeravatar
Andre
PureBasic Team
Beiträge: 1765
Registriert: 11.09.2004 16:35
Computerausstattung: MacBook Core2Duo mit MacOS 10.6.8
Lenovo Y50 i7 mit Windows 10
Wohnort: Saxony / Deutscheinsiedel
Kontaktdaten:

Beitrag von Andre »

Then hat geschrieben:Auf PureBasic.net ist ein Codebeispiel, dass leider nicht mehr funzt, kannst es ja evtl mal umfummeln und neu posten, ich probiere das auch gerade aus ! Wäre toll, wenn man evtl mal das CodeArchiv auf PB3.92 updaten könnte und die Codes entsprechend anpasst (oder PB an die Codes wieder anpassen würde ! /:-> )
Ein (weitgehend) PB3.92 kompatibles CodeArchiv dauert (hoffentlich) nicht mehr lang... /:-> :wink:
Bye,
...André
(PureBasicTeam::Docs - PureArea.net | Bestellen:: PureBasic | PureVisionXP)
Benutzeravatar
Then
Beiträge: 281
Registriert: 06.09.2004 13:26
Wohnort: Siegen

Beitrag von Then »

Klar, habe jetzt den OriginalCode gepostet, aber die Frage ist richtig, wo stehen nun die "richtigen" werte ! Habe auch schon mehrfach Versuche gestartet, aber es ist nix zu Finden, oder übersehe ich da was ?? :cry:
Monstalocke
Beiträge: 12
Registriert: 04.01.2005 14:38

Beitrag von Monstalocke »

Die "richtigen" Werte für den aktuellen Traffic stehen:

Code: Alles auswählen

ListArray(cnt,9)  = Str(IPInterfaceRow\dwInOctets) 
ListArray(cnt,10) = Str(IPInterfaceRow\dwOutOctets)
in Bytes
Benutzeravatar
Then
Beiträge: 281
Registriert: 06.09.2004 13:26
Wohnort: Siegen

Beitrag von Then »

Da bin ich mir nicht so ganz sicher. Wo kommt dann die Differenz her :

Bild

Muß man was hinzuaddieren oder so ??
Benutzeravatar
Buggymonkey
Beiträge: 47
Registriert: 02.09.2004 19:36
Wohnort: Löhne
Kontaktdaten:

Beitrag von Buggymonkey »

also beim laden von internetseiten verändern sich hauptsächlich folgende zahlen:
Octets received
Octets sent
Unicast packets received
Unicast packets send

Gruß Nils
wenn wer rechtschreibfehler findet, kann er sie behalten, :)

Ich würde gern die Welt verändern,
doch Gott gibt mir den Quellcode nicht!

http://www.house-of-chat.de umbedingt mal vorbei schaun ^^
Antworten