Added test to Packets and more

This commit is contained in:
Pablu23
2023-12-06 17:13:37 +01:00
parent 38876f6577
commit 5ccd83c9da
7 changed files with 68 additions and 7 deletions

View File

@@ -120,6 +120,21 @@ func GetFile(path string, address string) {
var recvPackets bitmap.Bitmap
dataReceived := 0
go func() {
last := 0
fmt.Print("\033[s")
for {
fmt.Print("\033[u\033[K")
fmt.Printf("Throughput: %v Mbit/s\n", ((dataReceived-last)*8)/1024/1024)
last = dataReceived
time.Sleep(1 * time.Second)
}
}()
for {
pck := ReceivePacket(key, conn)
if pck.Flag == common.End {
@@ -132,13 +147,13 @@ func GetFile(path string, address string) {
}
recvPackets.Set(pck.Sync)
offset := (int64(pck.Sync) - int64(ackPck.Sync+1)) * int64(common.MaxDataSize)
_, err = file.WriteAt(pck.Data, offset)
if err != nil {
panic(err)
}
dataReceived += int(pck.DataLength)
}
lostPackets := make([]uint32, 0)