/// <summary> /// Sends a netgram out of this port /// </summary> /// <param name="netgram">The netgram to send</param> public void SendNetgram(OutboundNetgram netgram) { IPEndPoint ep = null; byte[] buffer = new byte[1500]; int offset = 0; BvlcHeader header = new BvlcHeader(); IBvlcMessage message = null; if (netgram.Destination.IsBroadcast()) { ep = IPUtils.MacToIPEndPoint(_bbmdMac); header.Function = FunctionCode.OriginalUnicastNpdu; //header.Function = FunctionCode.OriginalBroadcastNpdu; header.Length = 0; message = new OriginalBroadcastNpduMessage(); } else { ep = IPUtils.MacToIPEndPoint(netgram.Destination); header.Function = FunctionCode.OriginalUnicastNpdu; header.Length = 0; message = new OriginalUnicastNpduMessage(); } offset = header.Serialize(buffer, offset); offset = message.Serialize(buffer, offset); offset = netgram.Content.Serialize(buffer, offset); // patch the length buffer[2] = (byte)(offset << 8); buffer[3] = (byte)(offset); lock(this._lock) { if (_server != null) { _server.Send(ep, buffer, offset); } } }