Ejemplo n.º 1
0
 public static bool TryCreateFrameOrLogWarning(IEmulationElement source, byte[] data, out EthernetFrame frame, bool addCrc)
 {
     if (EthernetFrame.TryCreateEthernetFrame(data, addCrc, out frame))
     {
         return(true);
     }
     source.Log(LogLevel.Warning, "Insufficient data to create an ethernet frame, expected {0} bytes but got {1} bytes.",
                EthernetFrame.MinFrameSizeWithoutCRC + (addCrc ? 0 : EthernetFrame.CRCLength), data.Length);
     return(false);
 }
Ejemplo n.º 2
0
        public void SendFrame(string bytes)
        {
            var data = HexStringToBytes(bytes);

            if (iface is IMACInterface macIface)
            {
                if (!EthernetFrame.TryCreateEthernetFrame(data, false, out var frame))
                {
                    throw new ArgumentException("Couldn't create Ethernet frame.");
                }
                var vts = new TimeStamp(default(TimeInterval), EmulationManager.ExternalWorld);
                iface.GetMachine().HandleTimeDomainEvent(macIface.ReceiveFrame, frame, vts);
            }
            else if (iface is IRadio)
            {
                throw new NotImplementedException("Sending frames is not implemented for Radio interfaces.");
            }
            else
            {
                throw new NotImplementedException("Sending frames is not implemented for this peripheral.");
            }
        }