update
This commit is contained in:
+9
-5
@@ -68,7 +68,7 @@ func main() {
|
||||
defer f.Close()
|
||||
|
||||
writer := csv.NewWriter(f)
|
||||
writer.Write([]string{"sequence_number", "drone_send_time", "ground_recv_time", "latency_ns", "bytes_received"})
|
||||
writer.Write([]string{"message_id", "chunk_index", "total_chunks", "drone_send_time", "ground_recv_time", "latency_ns", "bytes_received"})
|
||||
writer.Flush()
|
||||
|
||||
// Mutex to protect CSV writer if multiple streams are used
|
||||
@@ -99,7 +99,7 @@ func main() {
|
||||
}
|
||||
|
||||
length := binary.BigEndian.Uint32(header)
|
||||
if length < 20 {
|
||||
if length < 36 {
|
||||
fmt.Printf("Warning: Invalid frame length %d\n", length)
|
||||
continue
|
||||
}
|
||||
@@ -114,20 +114,24 @@ func main() {
|
||||
|
||||
recvTime := time.Now().UnixNano()
|
||||
|
||||
seqNum := binary.BigEndian.Uint64(payload[0:8])
|
||||
msgId := binary.BigEndian.Uint64(payload[0:8])
|
||||
sendTime := binary.BigEndian.Uint64(payload[8:16])
|
||||
chunkIdx := binary.BigEndian.Uint64(payload[16:24])
|
||||
totalChunks := binary.BigEndian.Uint64(payload[24:32])
|
||||
latency := recvTime - int64(sendTime)
|
||||
|
||||
mu.Lock()
|
||||
writer.Write([]string{
|
||||
strconv.FormatUint(seqNum, 10),
|
||||
strconv.FormatUint(msgId, 10),
|
||||
strconv.FormatUint(chunkIdx, 10),
|
||||
strconv.FormatUint(totalChunks, 10),
|
||||
strconv.FormatUint(sendTime, 10),
|
||||
strconv.FormatInt(recvTime, 10),
|
||||
strconv.FormatInt(latency, 10),
|
||||
strconv.FormatUint(uint64(length), 10),
|
||||
})
|
||||
// Periodically flush?
|
||||
if seqNum % 1000 == 0 {
|
||||
if msgId % 1000 == 0 {
|
||||
writer.Flush()
|
||||
}
|
||||
mu.Unlock()
|
||||
|
||||
Reference in New Issue
Block a user