日常の記録 (2024 年 4月)
前月 、翌月 | 一覧 |
トップページ
2024/4/29 (月)
- I have completed introducing the Apache's function to log all access information, such as global IP address and FQDN, to prepare for future DDoS attacks.
I want to learn more about how the real Internet works via hands-on training.
|
|
The part of yesterday's access logs. .
|
2024/4/28 (日)
- Here, this is one of the simplest codes for verifying the results of Fig. 5 in the paper written by G. Ramezan et al.
|
|
gained from the below source codes(Python3).
|
simVal.py
import simpy
import numpy as np
import sys
def process(env, lamb, mu, D, maxNum):
np.random.seed(0)
meanWT, curProcNum = 0, 0
queue = []
for i in range(maxNum):
# サービス実行開始(以降、waitQueueに貯まる)
srvTime = np.random.exponential(1/mu)
exeTime = srvTime + env.now
while True:
arvTime = np.random.exponential(1/lamb)
if env.now + arvTime < exeTime:
# キューにTxを入れる
queue.append(env.now + arvTime)
yield env.timeout(arvTime)
elif env.now + arvTime >= exeTime and len(queue) < D:
# Queueを無理やりDまで増やしてサービス実行。PoWは考慮していない)
yield env.timeout(exeTime - env.now)
# DまでQを増やす、時間も経過
while len(queue) < D:
arvTime = np.random.exponential(1/lamb)
yield env.timeout(arvTime) # 平均1/1000秒待機
queue.append(env.now)
procTime = env.now
# 平均処理時間を計算
meanWT = (np.mean(procTime - np.array(queue)) * len(queue) + meanWT * curProcNum) / (len(queue) + curProcNum)
curProcNum += len(queue)
# Queue情報の更新
queue = []
break
else:
# queueがD個以上で、サービスを即実行
yield env.timeout(exeTime - env.now)
# 平均処理時間を計算
meanWT = (np.mean(exeTime - np.array(queue)) * len(queue) + meanWT * curProcNum) / (len(queue) + curProcNum)
curProcNum += len(queue)
# Queue情報の更新
queue = []
break
print(meanWT)
plotVals.py
import matplotlib.pyplot as plt
import numpy as np
def calcN0(lamb, mu, D):
den = D * (lamb + mu) / lamb + (lamb + mu) / mu * np.power(lamb / (lamb + mu), D)
return 1 / den
def calcAveL(lamb, mu, D):
N0 = calcN0(lamb, mu, D)
term = (lamb + mu) / lamb * (D * (D - 1)) / 2 + lamb / mu * (lamb / mu + D) * np.power(lamb / (lamb + mu), D - 1)
return N0 * term
def main():
# データの準備
lamb, mu = 1000, 1
x = np.linspace(1, 2000, 100)
y = calcAveL(lamb, mu, x) * mu / lamb
x1 = np.array([1, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500, 1600, 1700, 1800, 1900, 2000])
y1 = np.array([0.9975690907442448, 0.9905734288416077, 0.9816150305985084, 0.9850361091339387, 0.9478050715571071, 0.9540101248803657, 0.9084462285183247,
0.9073192404072165, 0.8976292031050388, 0.9098063513863652, 0.9036150641522788, 0.9068923298319815, 0.9320381920990181, 0.9351002615154222,
0.9630543412957223, 0.9758201499136501, 1.006384431635652, 1.0329673620743782, 1.0545567690515925, 1.0911256312581148, 1.1211433826940767])
# グラフの描画
plt.figure(figsize=(8, 6))
plt.plot(x, y, '-', color="orange")
plt.plot(x1, y1, 'o', color="blue")
plt.xlim(0, 2000)
plt.ylim(0.8, 1.2)
plt.xlabel('$D$')
plt.ylabel('$\mu \\bar{W}$')
plt.title('Normalized average waiting time.')
plt.grid(True)
plt.show()
main()
2024/4/24 (水)
- Today, I have changed the URL on these diary pages.