-
Notifications
You must be signed in to change notification settings - Fork 0
[feat] : 스프린트2 탐색 개발에 따른 ICD 추가 + icd_id.h에 새로운 ICD에 대한 enum 추가 + comm_header.h 파일에서 uint32_t reliable_key 추가 #45
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
8a6469a
436fcee
3e47058
95d5cf2
f46947e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| #ifndef PIN_CONTROL_MAIN_COMMAND_H | ||
| #define PIN_CONTROL_MAIN_COMMAND_H | ||
|
|
||
| #include <cstdint> | ||
|
|
||
| #include "../enum/icd_id.h" | ||
|
|
||
| #pragma pack(push, 1) | ||
| struct PinControlMainCommand { | ||
| IcdId message_id; | ||
| int32_t a_motor_theta; | ||
| int32_t b_motor_theta; | ||
| }; | ||
| #pragma pack(pop) | ||
|
|
||
| #endif // PIN_CONTROL_MAIN_COMMAND_H |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,14 +9,16 @@ enum class CommType : uint8_t { | |
| RELIABLE_DATA = 0x02, | ||
| ACK = 0x03 | ||
| }; | ||
|
|
||
| #pragma pack(push, 1) | ||
| struct CommHeader { | ||
| CommType type; | ||
| DeviceId src_device_id; | ||
| DeviceId dst_device_id; | ||
| uint8_t sequence_number; // 신뢰성 있는 통신에서 사용 | ||
| CommType type; // 통신 유형 (일반 데이터, 신뢰성 있는 데이터, ACK) | ||
| DeviceId src_device_id; // 신뢰성 통신을 위한 출발지 디바이스 ID | ||
| DeviceId dst_device_id; // 신뢰성 통신을 위한 목적지 디바이스 ID | ||
| uint32_t reliable_unique_key; // 신뢰성 있는 통신을 위한 디바이스 고유키 | ||
| uint8_t sequence_number; // 신뢰성 통신을 위한 시퀀스 넘버 | ||
| uint16_t total_length; // 헤더 + 데이터의 총 길이 (최대 65535) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 헤더의 길이는 저 구조체 (CommHeader.h) 길이로 고정되어 있기 때문에 total_length 혹은 data_length 중 1개만 있어도 될 것 같습니다.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. recvfrom의 반환값이 항상 패킷(comm_header + comm_paylod)로 나온다는 보장은 없습니다. 유저 버퍼와 커널 버퍼가 충분히 큰 경우는 udp인 경우 대부분은 -1 아니면 패킷 크기이겠지만 이를 확신 할 수 없기 때문에 헤더에 넣어서 정상적으로 수신 되었는지까지 확인 할 수 있습니다.(일종의 간단한 Checksum) |
||
| uint16_t data_length; // 데이터의 길이 (최대 65535) | ||
| }; | ||
| #pragma pack(pop) | ||
|
|
||
| #endif // COMM_HEADER_H | ||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
디바이스 고유키를 매번 패킷에 넣어보내면 전체 패킷이 4byte가 증가하고, 이는 통신을 1000번 하면 4kb만큼의 통신 부하 증가를 만들게 됩니다.
해당 정보는 재부팅과 같은 특정 상황에서만 필요한 값임에도 불구하고 매번 모든 데이터에 영향을 미치게 되는 문제가 있습니다.
차라리 디바이스 고유키 대신 재부팅 시(혹은 최초 통신 시)에 재부팅한 측에서 hello를 보내서 이를 받은 수신자가 시퀀스 테이블에 있는 seq id를 초기화하는 방식이 어떨까요?
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
말씀하시는 부하가 어떤 부하인지 잘 모르겠습니다만, 신뢰성 통신외에는 보낼 필요없는 데이터를 위해서 4바이트 공간을 차지하여 매번 보내는 것이 비 효율적으로 보이신다는 것으로 이해가 됩니다.
이것이 성능에 병목을 만들어내는 것이라면 분명 잘못된 것이겠지만 성능에 병목은 없습니다.
또한 hello 전송의 경우 아래의 경우의 수를 보셔야 합니다.
여기서 GCU는 next_seq가 20이기 때문에 ACT에 패킷을 보내도 ACT는 패킷을 받을 수 없음
때문에 ACT의 Hello를 받으면 GCU가 Hello_Ack를 보내서 ACT의 expected_seq를 20으로 바꿔야함
마찬가지로 Hello_ACK 패킷은 상대방의 상태를 초기화하는 중요 패킷이기 때문에 Hello_Ack에 대한 ACK를 기다려야지 정상적인 통신을 수행할 수 있음
결국 3Way-handshake임
제 목표는 udp위의 신뢰성 통신에서 handshake 절차를 안하려고 하는 것이고
제가 구현한 방법으로 하시면 hello없이 id가 바뀌어도 바로 통신을 이어갈 수 있습니다.
또한 id 32비트는 일종의 보드 상태의 식별자로 사용할 수 있기 때문에 확장성에서도 도움이 될 수 있습니다.