Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions bin/RDTEchoServer.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ local RDT = require("netRDT")

require("logUtils")
local logID = _LogUtil.newLogger("rdtDebug",_LogLevel.info,_LogLevel.trace,_LogLevel.noLog)
_LogUtil.clearAllFiles()

local port = 15;

Expand Down
1 change: 1 addition & 0 deletions bin/RDTTest.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ local RDT = require("netRDT")

require("logUtils")
local logID = _LogUtil.newLogger("rdtDebug",_LogLevel.debug,_LogLevel.trace,_LogLevel.noLog)
_LogUtil.clearAllFiles()

local dest = "3ae67331-1f18-49ea-866b-e8bd3e02cb8f";
local port = 15;
Expand Down
37 changes: 37 additions & 0 deletions lib/dataQue.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@

require("logUtils")
local serial = require("serialization")
local que = require("que")
local logID = _LogUtil.newLogger("dataQue",_LogLevel.error,_LogLevel.trace,_LogLevel.noLog)

local dataQue = {}

function dataQue.QueueData(que,data)

return que
end

function dataQue.NextInWin(que)
end

function dataQue.StartOfWin(que)
end

function dataQue.winHasNext(que)
end

function dataQue.AckPacket(que,ackNum)
end

function dataQue.DataQue(max)
local dq={}
dq.q = que.Queue(max)
dq.winSize = 0
dq.winSent = 0
dq.seqNum = 0
dq.ackNum = 0
return dq
end


return dataQue
6 changes: 5 additions & 1 deletion lib/fileUtils.lua
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,9 @@ if (_FileUtil == nil) then
end
end


function _FileUtil.rm(file)
if(fs.exists(file)) then
fs.remove(file)
end
end
end
20 changes: 16 additions & 4 deletions lib/logUtils.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ if (_LogUtil == nil) then
_LogUtil = {
loggerCount = 0
}
local _MaxLogSize = 1000000
local _MaxLogSize = 50000
_LogLevel = {
trace = 1,
info = 2,
Expand Down Expand Up @@ -42,7 +42,8 @@ if (_LogUtil == nil) then
local _utilLoggers = {
broadcastLog = function (...)end,
fileLog = function (...)end,
printLog = function (...)end
printLog = function (...)end,
clearAllFiles= function (...)end
}

function _utilLoggers.printLog(str)
Expand Down Expand Up @@ -107,6 +108,11 @@ if (_LogUtil == nil) then
loggers[logID].cl = level
end

function _LogUtil.clearAllFiles()
_utilLoggers.clearAllFiles()
end


function _LogUtil.logFailures(logID,callback,...)
local results
local arguments = {...}
Expand All @@ -130,14 +136,18 @@ if (_LogUtil == nil) then
end

if not (_FileUtil == nil) then
local logsDir = "/logs"
function _utilLoggers.fileLog(str,name)
local fileName = "/logs/"..name..".log"
local fileName = logsDir.."/"..name..".log"
if(_FileUtil.size(fileName) > _MaxLogSize) then
_FileUtil.clear(fileName)
end
_FileUtil.append(fileName,str,"\n")
end
_FileUtil.ensureDir("/logs/")
function _utilLoggers.clearAllFiles()
_FileUtil.rm(logsDir)
_FileUtil.ensureDir(logsDir.."/")
end
end

if(_NetUtil == nil) then
Expand All @@ -152,4 +162,6 @@ if (_LogUtil == nil) then
_NetUtil.broadcast(_NetDefs.portEnum.logger,str,_NetDefs.HostName)
end
end


end
73 changes: 69 additions & 4 deletions lib/netDefs.lua
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,77 @@ if(_NetDefs == nil) then
RDT = 1,
UDP = 2,
}
local maxWinSz = 32
_NetDefs.rdtConst = {
maxWindowSize = maxWinSz,
bufferSize = (maxWinSz) * 2,
}

_NetDefs.timming = {
serviceInterval = 0.1, -- Time between service calls (seconds)
sendRate = 0.5, -- Time between sending packets from the que
resendInterval = 2, -- Time since last Ack before resending Que (seconds)
sendHBInterval = 3, -- Time since last transmuit before sending proof of life (seconds)
coldInterval = 10, -- Time since last Ack before resending Que (seconds)
sendRateInc = -0.1, -- Time change when increacing the rate general sending (seconds)
sendRateDec = 0.1, -- Time change when decreasing the rate general sending (seconds)
}

function _NetDefs.reCalcTimeouts()
--timming measured in units of serviceInterval
_NetDefs.timeOut = {
genSend = _NetDefs.timming.sendRate/_NetDefs.timming.serviceInterval,
resend = _NetDefs.timming.resendInterval/_NetDefs.timming.serviceInterval,
sendHB = _NetDefs.timming.sendHBInterval/_NetDefs.timming.serviceInterval,
cold = _NetDefs.timming.coldInterval /_NetDefs.timming.serviceInterval,
}
end

function _NetDefs.incSendRate()
local t = _NetDefs.timming
t.sendRate = t.sendRate + t.sendRateInc
if t.sendRate < t.serviceInterval then
t.sendRate = t.serviceInterval
end
_NetDefs.timming = t
_NetDefs.reCalcTimeouts()
end

_NetDefs.timeOut = {
resend = 10,
sendHB = 10,
cold = 50,
function _NetDefs.decSendRate()
local t = _NetDefs.timming
t.sendRate = t.sendRate + t.sendRateDec
if t.sendRate < t.serviceInterval then
t.sendRate = t.serviceInterval
end
_NetDefs.timming = t
_NetDefs.reCalcTimeouts()
end
_NetDefs.reCalcTimeouts()
-- these values may be adjusted over the course of opperation
_NetDefs.congestionControl = {
lossScaleDownFactor = 0.5,
scaleUpRate = 0.25,
maxPkt = 10
}

function _NetDefs.queTimeout()
local cc = _NetDefs.congestionControl
cc.maxPkt = cc.maxPkt * cc.lossScaleDownFactor
if(cc.maxPkt < 1) then
cc.maxPkt = 1
end
_NetDefs.congestionControl = cc
_NetDefs.reCalcTimeouts()
end

function _NetDefs.ackedPacket()
local cc = _NetDefs.congestionControl
cc.maxPkt = cc.maxPkt + cc.scaleUpRate
_NetDefs.congestionControl = cc
_NetDefs.reCalcTimeouts()
end


_NetDefs.events = {
syncResponse = "NetSynResponse"
}
Expand Down
Loading