6.09.2012

Network Speed Calculator with HTA

HTA版ネットワーク速度計算機

ネットワークの伝送時間を概算で得たい場合、以下の計算式をよく利用する。

bandwidth: 帯域幅(bps)
efficiency: 伝送効率(%)
datasize: データ量(バイト)
timetaken: 所要時間(秒)

image

この計算を簡単に行えるようにHTAのスクリプトを作成した。

・NetSpeed.hta

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
<html><!--
'*****************************************************************************
'*
'* NAME           : Network Speed Calculator
'*
'* DESCRIPTION    : Calculate bandwidth, data size or time taken.
'*
'* VERSION HISTORY:
'* 1.0  2012-06-09  Initial release by mogproject
'*
'*****************************************************************************
--><head>
<meta http-equiv="Content-Type" content="text/html; charset=Shift_JIS">
<title>&nbsp;</title>
 
<script language="JavaScript"><!--
resizeWindow(350, 170);
 
function resizeWindow(width, height) {
  width = Math.min(width, screen.width);
  height = Math.min(height, screen.height);
  window.resizeTo(width, height);
  window.moveTo ((screen.width - width) / 2, (screen.height - height) / 2);
}
--></script>
  
<HTA:APPLICATION
 ID             ="hta"
 APPLICATIONNAME="Network Speed Calculator"
 VERSION        ="1.0"
 ICON           =""
 BORDER         ="normal"
 BORDERSTYLE    ="normal"
 CAPTION        ="yes"
 INNERBORDER    ="yes"
 MAXIMIZEBUTTON ="yes"
 MINIMIZEBUTTON ="yes"
 SHOWINTASKBAR  ="yes"
 SINGLEINSTANCE ="yes"
 SYSMENU        ="yes"
 WINDOWSTATE    ="normal"
 SCROLL         ="no"
 SCROLLFLAT     ="yes"
 SELECTION      ="no"
 CONTEXTMENU    ="yes"
 NAVIGABLE      ="no" />
 
<script language="JavaScript"><!--
function onLoad() {
  document.title= hta.applicationName + " v" + hta.version;
 
  txtBandwidth.value = 100;
  txtEfficiency.value = 80;
  txtDataSize.value = "";
  txtTimeTaken.value = "";
  checkAvailability();
}
function onKeyPress(evt) {
  window.event.returnValue
      = (evt.keyCode >= 48 && event.keyCode <= 57) || event.keyCode == 46;
}
function onKeyUp() {
  checkAvailability();
}
function checkAvailability() {
  var elems = [txtBandwidth, txtDataSize, txtTimeTaken];
  for (var i in elems) {
    elems[i].style.backgroundColor = "white";
  }
  btnCalcBandwidth.disabled = ! (txtEfficiency.value.length
      && txtDataSize.value.length && txtTimeTaken.value.length);
  btnCalcDataSize.disabled = ! (txtEfficiency.value.length
      && txtBandwidth.value.length && txtTimeTaken.value.length);
  btnCalcTimeTaken.disabled = ! (txtEfficiency.value.length
      && txtBandwidth.value.length && txtDataSize.value.length);
}
function updateValue(elem, val) {
  elem.value = Math.round(val * 100) / 100;
  checkAvailability();
  elem.style.backgroundColor = "yellow";
}
function calcBandwidth() {
  updateValue(txtBandwidth,
      800 * txtDataSize.value * lstUnitDataSize.value
      / (txtTimeTaken.value * lstUnitTimeTaken.value * txtEfficiency.value)
      / lstUnitBandwidth.value);
}
function calcDataSize() {
  updateValue(txtDataSize,
      txtBandwidth.value * lstUnitBandwidth.value * txtEfficiency.value
      * txtTimeTaken.value * lstUnitTimeTaken.value / 800
      / lstUnitDataSize.value);
}
function calcTimeTaken() {
  updateValue(txtTimeTaken,
      800 * txtDataSize.value * lstUnitDataSize.value
      / (txtBandwidth.value * lstUnitBandwidth.value * txtEfficiency.value)
      / lstUnitTimeTaken.value);
}
--></script>
 
<style type="text/css"><!--
body {
  font-family     : Verdana, Arial, Helvetica, Sans-serif;
  font-size       : 9px;
  font-weight     : normal;
  background-color: #a9a9a9;
  color           : #000000;
  margin          : 0px 0px 0px 0px;
}
table {
  border-collapse : collapse;
  border-spacing  : 0px;
  border-width    : 0px;
  border-style    : solid;
}
table.main {
  width           : 320px;
  height          : 120px;
  font-size       : 12px;
}
input {
  font-family     : Verdana, Arial, Helvetica, Sans-serif;
  font-weight     : normal;
}
input.text {
  font-size       : 14px;
  text-align      : right;
  width           : 6em;
}
input.button {
  width           : 4em;
}
select {
  font-family     : Verdana, Arial, Helvetica, Sans-serif;
  font-size       : 12px;
  font-weight     : normal;
}
--></style>
</head>
 
<body onload="onLoad()">
<table width="100%" height="100%"><tr><td align="center">
<table class="main">
<tr>
 <td align="right">bandwidth</td>
 <td align="right">
   <input name="txtBandwidth" type="text" class="text"
    onkeypress="window.event.returnValue = onKeyPress(window.event)"
    onkeyup="onKeyUp()" onchange="onKeyUp()" />
 </td>
 <td align="left">
  <select name="lstUnitBandwidth">
   <option value="1">bps</option>
   <option value="1024">Kbps</option>
   <option value="1048576" selected="selected">Mbps</option>
   <option value="1073741824">Gbps</option>
  </select>
 </td>
 <td align="left">
  <input name="btnCalcBandwidth" type="button" class="button" value="calc"
   onclick="calcBandwidth()" />
 </td>
</tr>
<tr>
 <td align="right">efficiency</td>
 <td align="right">
   <input name="txtEfficiency" type="text" class="text"
    onkeypress="onKeyPress(window.event)"
    onkeyup="onKeyUp()" onchange="onKeyUp()" />
 </td>
 <td align="left">%</td>
 <td align="left"></td>
</tr>
<tr>
 <td align="right">data size</td>
 <td align="right">
   <input name="txtDataSize" type="text" class="text"
    onkeypress="onKeyPress(window.event)"
    onkeyup="onKeyUp()" onchange="onKeyUp()" />
 </td>
 <td align="left">
  <select name="lstUnitDataSize">
   <option value="1">Byte</option>
   <option value="1024">KB</option>
   <option value="1048576" selected="selected">MB</option>
   <option value="1073741824">GB</option>
   <option value="1099511627776">TB</option>
  </select>
 </td>
 <td align="left">
  <input name="btnCalcDataSize" type="button" class="button" value="calc""
   onclick="calcDataSize()" />
 </td>
</tr>
<tr>
 <td align="right">time taken</td>
 <td align="right">
   <input name="txtTimeTaken" type="text" class="text"
    onkeypress="onKeyPress(window.event)"
    onkeyup="onKeyUp()" onchange="onKeyUp()" />
 </td>
 <td align="left">
  <select name="lstUnitTimeTaken">
   <option value="1">seconds</option>
   <option value="60" selected="selected">minutes</option>
   <option value="3600">hours</option>
   <option value="86400">days</option>
  </select>
 </td>
 <td align="left">
  <input name="btnCalcTimeTaken" type="button" class="button" value="calc"
   onclick="calcTimeTaken()" />
  </td>
</tr>
</table>
</body>
</td></tr></table>
</html>

・画面

image

・使用方法

(1) 必要な帯域幅を算出したい場合
bandwidthの単位, efficiency, data size, time taken を設定し、bandwidth 横の「calc」ボタンを押下。

(2) 時間内に伝送可能なデータ量を算出したい場合
bandwidth, efficiency, data sizeの単位, time taken を設定し、data size 横の「calc」ボタンを押下。

(3) 所要時間を算出したい場合
bandwidth, efficiency, data size, time takenの単位 を設定し、time taken 横の「calc」ボタンを押下。

0 件のコメント:

コメントを投稿