public void BeforeSend(object sender, Gurux.Communication.GXPacket packet)
 {
     GXClient client = sender as GXClient;
     if (client.MediaType == "Net")
     {
         if (++PacketID == UInt16.MaxValue)
         {
             PacketID = 1;
         }
         //The Unit Identifier
         packet.InsertData((byte)((GXModbusDevice)client.Owner).Address, 0, 0, 0);
         //Count data size and update it to the packet before send.
         int PackSize = packet.GetSize(PacketParts.Data);
         packet.InsertData((UInt16)PackSize, 0, 0, 0);
         //Protocol ID. (Always 0x0)
         packet.InsertData((UInt16)0, 0, 0, 0); 
         //PacketID
         packet.InsertData(PacketID, 0, 0, 0); 
     }
 }