Skip to content

Wrong final Broadcast packet size after changes from extra BasePacketLayer #1063

Description

@am1goo

Unity Version: 6000.2.6f2
Fish-Networking Version: V4, commit 2742f2379a8fbcfe6c38f788f3354bbdd806284f (the latest)
Troubleshooting link in Discord: no link, according to https://fish-networking.gitbook.io/docs/guides/troubleshooting/creating-bug-reports

Description:
If any extra BasePacketLayer is in use and it change the resulting size of packet (in bytes) like "packet padding" technique, the final value of data length still equals packet.Size before any modifications.
Here the existing code of SendBroadcast method:

broadcastSuccess = _udpSocketv4.SendTo(packet.RawData, 0, packet.Size, SocketFlags.None, new IPEndPoint(IPAddress.Broadcast, port)) > 0;

if (_udpSocketv6 != null)
{
    multicastSuccess = _udpSocketv6.SendTo(packet.RawData, 0, packet.Size, SocketFlags.None, new IPEndPoint(MulticastAddressV6, port)) > 0;
}

Expected behavior:
The resulting size of data to send must equals the calculated data length from extra BasePacketLayer.
Here what it should be:

extraPacketLayer.ProcessOutBoundPacket(ref emptyEp, ref packet.RawData, ref checksumComputeStart, ref packetSize);

broadcastSuccess = _udpSocketv4.SendTo(packet.RawData, 0, packetSize, SocketFlags.None, new IPEndPoint(IPAddress.Broadcast, port)) > 0;

if (_udpSocketv6 != null)
{
    multicastSuccess = _udpSocketv6.SendTo(packet.RawData, 0, packetSize, SocketFlags.None, new IPEndPoint(MulticastAddressV6, port)) > 0;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions