pstavirs / ostinato

Ostinato - Packet/Traffic Generator and Analyzer
https://ostinato.org
758 stars 138 forks source link

Questions on protobuf usage inside ostinato #337

Closed salilpant27 closed 3 years ago

salilpant27 commented 3 years ago

Hello, I am trying to use Ostinato as well as understand it better to be able to write a custom protocol. I have some basic questions. I noticed that internally the protocols are defined using protobuf and there exists a .proto file for each protocol. However, the sizes of fields in the .proto files do not correspond to the sizes defined in the protocol headers. For eg. for ethernet, the mac.proto contains the Source and Dest mac definitions as below // Dst Mac optional uint64 dst_mac = 1; // Src Mac optional uint64 src_mac = 5; I see in the ip4.proto that the ip header fields are all 32 bits. How do you make sure that the packet is ultimately the right size? Also, I have been reading that protobufs uses a unique encoding mechanism for bytes on the wire so the fields defined look fairly different in memory. How does this translate to the correct values expected by the user? These are just questions, I did not find a way to tag this issue as just a question rather than an issue.

pstavirs commented 3 years ago

@salilpant27 The protobuf is just a data storage for the protocol, but doesn't define the actual size of the field or the packet format. That is defined by the C++ code. See https://ostinato.org/docs/fosdem2021 for more about how to create a new protocol builder.

salilpant27 commented 3 years ago

Thanks, I see it now !