Skip to content
/ f1udp Public

parse, visualize, analyze f1 2021 game data by udp

Notifications You must be signed in to change notification settings

Ariyn/f1udp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

62 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

[WIP] F1 UDP 패킷 파서

F1 시리즈(2025) UDP 텔레메트리 패킷을 파싱하고, 모션/일반 텔레메트리 분석에 활용하기 위한 라이브러리입니다. 패킷 스펙에 대응하는 구조체와 파서, 그리고 UDP 리스너를 분리해 외부에서 쉽게 재사용할 수 있도록 구성했습니다.

현재 구조

  • cmd/telemetry/
    • 실행 엔트리포인트
  • packet/
    • 패킷 스펙 구조체 및 파서 (순수 패킷 정의)
  • pkg/model/
    • 도메인 모델 (앱/분석에서 사용하는 타입)
  • internal/mapper/
    • packet → model 변환 로직
  • pkg/udp/
    • UDP 리스너/로거 인터페이스 (외부에서 사용 가능)
  • specs/
    • 참고 문서 및 패킷 스펙
  • proto/
    • 패킷별 protobuf 스키마

Protobuf codegen

proto/ 아래에 패킷별 .proto 스키마를 관리합니다. Go 코드 생성은 protocprotoc-gen-go를 사용합니다.

사전 준비

  • Protocol Buffers 컴파일러(protoc) 설치
  • Go 플러그인 설치
go install google.golang.org/protobuf/cmd/protoc-gen-go@latest

생성 명령

프로젝트 루트에서 실행합니다.

protoc \
	--go_out=. \
	--go_opt=paths=source_relative \
	proto/*.proto

생성된 파일은 proto/ 아래에 .pb.go 형태로 저장됩니다.

사용 예시

아래는 UDP 리스너로 패킷을 수신하고, 패킷 타입별로 로그를 출력하는 간단한 예시입니다.

package main

import (
	"context"
	"log"
	"sync"

	"github.com/ariyn/f1udp/packet"
	"github.com/ariyn/f1udp/pkg/udp"
)

type PrintLogger struct {
	ch    <-chan packet.Data
	rawCh <-chan []byte
}

func (l *PrintLogger) Writer(ctx context.Context, wg *sync.WaitGroup) (chan<- packet.Data, context.CancelFunc, error) {
	ch := make(chan packet.Data, 256)
	l.ch = ch
	return ch, func() {}, nil
}

func (l *PrintLogger) RawWriter(ctx context.Context, wg *sync.WaitGroup) (chan<- []byte, context.CancelFunc, error) {
	ch := make(chan []byte, 256)
	l.rawCh = ch
	return ch, func() {}, nil
}

func (l *PrintLogger) Run() {
	for data := range l.ch {
		name := packet.NamesById[data.Id()]
		log.Printf("packet=%s id=%d", name, data.Id())
	}
}

func main() {
	ctx := context.Background()
	listener, err := udp.NewListener(ctx, udp.DefaultNetwork, udp.DefaultAddress, &PrintLogger{})
	if err != nil {
		log.Fatal(err)
	}
	if err := listener.Run(); err != nil {
		log.Fatal(err)
	}
}

About

parse, visualize, analyze f1 2021 game data by udp

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •  

Languages