내 응용 프로그램의 경우 사용자에게 네트워크 대역폭을 보여주고 싶습니다. 그래서, 다운로드 지연은 사용자에게 알려지게 될 것입니다. 보여줄 수 있습니까?C에서 네트워크 대역폭 측정 #
4
A
답변
2
시도해보십시오. How to calculate network bandwidth speed in c#
using System;
using System.Net.NetworkInformation;
using System.Windows.Forms;
namespace InterfaceTrafficWatch
{
/// <summary>
/// Network Interface Traffic Watch
/// by Mohamed Mansour
///
/// Free to use under GPL open source license!
/// </summary>
public partial class MainForm : Form
{
/// <summary>
/// Timer Update (every 1 sec)
/// </summary>
private const double timerUpdate = 1000;
/// <summary>
/// Interface Storage
/// </summary>
private NetworkInterface[] nicArr;
/// <summary>
/// Main Timer Object
/// (we could use something more efficient such
/// as interop calls to HighPerformanceTimers)
/// </summary>
private Timer timer;
/// <summary>
/// Constructor
/// </summary>
public MainForm()
{
InitializeComponent();
InitializeNetworkInterface();
InitializeTimer();
}
/// <summary>
/// Initialize all network interfaces on this computer
/// </summary>
private void InitializeNetworkInterface()
{
// Grab all local interfaces to this computer
nicArr = NetworkInterface.GetAllNetworkInterfaces();
// Add each interface name to the combo box
for (int i = 0; i < nicArr.Length; i++)
cmbInterface.Items.Add(nicArr[i].Name);
// Change the initial selection to the first interface
cmbInterface.SelectedIndex = 0;
}
/// <summary>
/// Initialize the Timer
/// </summary>
private void InitializeTimer()
{
timer = new Timer();
timer.Interval = (int)timerUpdate;
timer.Tick += new EventHandler(timer_Tick);
timer.Start();
}
/// <summary>
/// Update GUI components for the network interfaces
/// </summary>
private void UpdateNetworkInterface()
{
// Grab NetworkInterface object that describes the current interface
NetworkInterface nic = nicArr[cmbInterface.SelectedIndex];
// Grab the stats for that interface
IPv4InterfaceStatistics interfaceStats = nic.GetIPv4Statistics();
// Calculate the speed of bytes going in and out
// NOTE: we could use something faster and more reliable than Windows Forms Tiemr
// such as HighPerformanceTimer http://www.m0interactive.com/archives/2006/12/21/high_resolution_timer_in_net_2_0.html
int bytesSentSpeed = (int)(interfaceStats.BytesSent - double.Parse(lblBytesSent.Text))/1024;
int bytesReceivedSpeed = (int)(interfaceStats.BytesReceived - double.Parse(lblBytesReceived.Text))/1024;
// Update the labels
lblSpeed.Text = nic.Speed.ToString();
lblInterfaceType.Text = nic.NetworkInterfaceType.ToString();
lblSpeed.Text = nic.Speed.ToString();
lblBytesReceived.Text = interfaceStats.BytesReceived.ToString();
lblBytesSent.Text = interfaceStats.BytesSent.ToString();
lblUpload.Text = bytesSentSpeed.ToString() + " KB/s";
lblDownload.Text = bytesReceivedSpeed.ToString() + " KB/s";
}
/// <summary>
/// The Timer event for each Tick (second) to update the UI
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
void timer_Tick(object sender, EventArgs e)
{
UpdateNetworkInterface();
}
}
}
+0
이것이 정확한지, 전체 네트워크 어댑터 대역폭을 보여 주며, 특정 다운로드가 아닙니다. –
0
당신은 당신이 무엇을 할 수 있는지 다음 스트림을 통해 다운로드하는 것입니다 경우 스트림으로부터 상속의 요약입니다 속성을 노출 "m"의 종류를 확인하는 것입니다 읽히거나 읽힌 바이트는 기본 스트림 객체입니다. 미터기가 다운로드하고 미터기 오브젝트에서 읽는 데 사용하는 스트림 오브젝트를 캡슐화하십시오. 그러면 너무 자주 소비 된 대역폭 속도를 계산하기 위해 시간이 지남에 따라 읽은 바이트 수를 확인할 수 있습니다.
관련 문제
- 1. C에서 네트워크 성능 측정 도구
- 2. 초보자를위한 앱 대역폭 측정
- 3. 최소 데이터 전송으로 대역폭 측정
- 4. 측정 네트워크 트래픽을 별도로
- 5. WCF 네트워크 트래픽 측정
- 6. WCF 및 네트워크 대역폭 조절
- 7. 네트워크 연결 대역폭 감지 (Android)
- 8. 내 (SAMP) 서버의 대역폭 사용을 어떻게 측정 할 수 있습니까?
- 9. 네트워크 트래픽을 어떻게 측정 할 수 있습니까?
- 10. iPhone에서 프로그래밍 방식으로 네트워크 트래픽 측정
- 11. C에서 네트워크 사용률 가져 오기
- 12. C에서 네트워크 계층 프로토콜 개발
- 13. 파이썬에서 대역폭 조절
- 14. API가있는 모든 무료/저가형 대역폭 형성 또는 네트워크 손상 소프트웨어?
- 15. 보내는 방법, 바이트 및 네트워크 대역폭 사용량 수신
- 16. mapreduce 중간 키 정렬을위한 네트워크 대역폭 병목 현상이 있습니까?
- 17. C#에서 네트워크 연결 속도 및 대역폭 사용 감지
- 18. 대역폭 형성 및 가상 네트워크 계층/인터페이스 - Windows + .NET
- 19. 방법 : Silverlight의 대역폭 계산기
- 20. CUDA 이론상의 대역폭 대 유효 대역폭
- 21. howto는 C에서 네트워크 장치 상태를 확인 하시겠습니까?
- 22. 대역폭 관리?
- 23. iOS에서 보낸 네트워크 시간의 분석을 어떻게 측정 할 수 있습니까?
- 24. 단일 웹 사이트의 대역폭 소비량을 모니터링하십시오.
- 25. iOS 기기의 3G/Wi-Fi 네트워크 트래픽을 추적하는 방법은 무엇인가요?
- 26. 네트워크 시뮬레이터?
- 27. Windows에서 메모리 대역폭 사용률을 측정하는 방법은 무엇입니까?
- 28. 응용 프로그램/스레드에서 측정 된 측정 시간
- 29. Qt를 통한 대역폭 조절
- 30. 대역폭 제한 및 HttpWebRequest
@ RomanoZumbé 그 질문은 7 년이 넘었습니다. 그 당시 사람들은 upvote에 mcve를 찾지 않을 것입니다. 이것이 초기 단계입니다. 제발 사이트의 시작 단계에서 기여하고있는 사람들을 남용하지 마세요 –
@SagarV 나는 아무도 "학대하지 않는다". 이 질문은 "Close Votes"리뷰 대기열에 나타났습니다. 우리의 품질 기준을 충족시키지 못하는 항목이 오늘 게시되었을 때 품질 기준을 충족하더라도 삭제해야한다고 생각합니다. 그러나 나는 그것이 왜 처음부터 위로 upvoted 얻었는지 이해합니다. –