I am a beginner to VB.Net and am about to undertake a small project in which i have to measure the bandwidth i am recieving from my ISP to see if i am recieving their advertised bandwidth.
I understand that i will have to use sockets, I have looked on the microsoft MSDN site and other sites on the net and come to the conclusion that my application will have to.
1)Perform DNS lookup of my ISP server
2)Send a large packet of data to it ECHO port (port 7) using UDP
3)Measure the time it takes to receive the echo'd packet.
Here is a sample code for DNS lookup.
DNS lookup
Imports System
Imports System.Text
Imports System.IO
Imports System.Net
Imports System.Net.Sockets
Imports Microsoft.VisualBasic
Public Class GetSocket
Private Shared Function ConnectSocket(server As String, port As Integer) As Socket
Dim s As Socket = Nothing
Dim hostEntry As IPHostEntry = Nothing
' Get host related information.
hostEntry = Dns.Resolve(server)
' Loop through the AddressList to obtain the supported AddressFamily. This is to avoid
' an exception that occurs when the host host IP Address is not compatible with the address family
' (typical in the IPv6 case).
Dim address As IPAddress
For Each address In hostEntry.AddressList
Dim endPoint As New IPEndPoint(address, port)
Dim tempSocket As New Socket(endPoint.AddressFamily, SocketType.Stream, ProtocolType.Tcp)
tempSocket.Connect(endPoint)
If tempSocket.Connected Then
s = tempSocket
Exit For
End If
Next address
Return s
End Function
I am unsure of how i am going to send the large packet of data and of how i am going to time it.
Am i going in the right direction?
if not can you guide me a little - I must stress i am a beginner and am learning the language.
Craig
I understand that i will have to use sockets, I have looked on the microsoft MSDN site and other sites on the net and come to the conclusion that my application will have to.
1)Perform DNS lookup of my ISP server
2)Send a large packet of data to it ECHO port (port 7) using UDP
3)Measure the time it takes to receive the echo'd packet.
Here is a sample code for DNS lookup.
DNS lookup
Imports System
Imports System.Text
Imports System.IO
Imports System.Net
Imports System.Net.Sockets
Imports Microsoft.VisualBasic
Public Class GetSocket
Private Shared Function ConnectSocket(server As String, port As Integer) As Socket
Dim s As Socket = Nothing
Dim hostEntry As IPHostEntry = Nothing
' Get host related information.
hostEntry = Dns.Resolve(server)
' Loop through the AddressList to obtain the supported AddressFamily. This is to avoid
' an exception that occurs when the host host IP Address is not compatible with the address family
' (typical in the IPv6 case).
Dim address As IPAddress
For Each address In hostEntry.AddressList
Dim endPoint As New IPEndPoint(address, port)
Dim tempSocket As New Socket(endPoint.AddressFamily, SocketType.Stream, ProtocolType.Tcp)
tempSocket.Connect(endPoint)
If tempSocket.Connected Then
s = tempSocket
Exit For
End If
Next address
Return s
End Function
I am unsure of how i am going to send the large packet of data and of how i am going to time it.
Am i going in the right direction?
if not can you guide me a little - I must stress i am a beginner and am learning the language.
Craig