Returns (TotalBytesSent, TotalBytesReceived, TotalPacketsSent, TotalPacketsReceived, Layer1DownstreamMaxBitRate, Uptime)
198252
async def x_get_ics_statistics(self) -> Tuple[int, int, int, int, str, str]:
        """"""
        return await self.gateway.commands.X_GetICSStatistics()
713771
def bytes()
			return [
				(@addr >> 56 & 0xff).to_s(16).rjust(2, "0"),
				(@addr >> 48 & 0xff).to_s(16).rjust(2, "0"),
				(@addr >> 40 & 0xff).to_s(16).rjust(2, "0"),
				(@addr >> 32 & 0xff).to_s(16).rjust(2, "0"),
				(@addr >> 24 & 0xff).to_s(16).rjust(2, "0"),
				(@addr >> 16 & 0xff).to_s(16).rjust(2, "0"),
				(@addr >> 8 & 0xff).to_s(16).rjust(2, "0"),
				(@addr & 0xff).to_s(16).rjust(2, "0"),
				]
		end
298522
def bytes(self):
        """"""
        flagByte = 0x00
        messageType = 0
        if self._messageType is not None:
            messageType = self._messageType << 5
        extendedBit = 0 if self._extended is None else self._extended << 4
        hopsMax = 0 if self._hopsMax is None else self._hopsMax
        hopsLeft = 0 if self._hopsLeft is None else (self._hopsLeft << 2)
        flagByte = flagByte | messageType | extendedBit | hopsLeft | hopsMax
        return bytes([flagByte])
1353820
def getUptime(self):
        
        try:
            fp = open(uptimeFile, 'r')
            line = fp.readline()
            fp.close()
        except:
            raise IOError('Failed reading stats from file: %s' % uptimeFile)
        return float(line.split()[0])
531725
public byte[] getStreamAsBytearray() throws IOException {
		byte[] result = null;
		try {
			result = IOUtils.toByteArray(getStream());
		}
		catch (NullPointerException npex) {
			throw new IOException("Timeout has been forced by CommonHttpClient", npex);
		}
		return result;
	}
45177
function Stream_getBytes(length) {
      var bytes = this.bytes;
      var pos = this.pos;
      var strEnd = this.end;

      if (!length) {
        return bytes.subarray(pos, strEnd);
      }
      var end = pos + length;
      if (end > strEnd) {
        end = strEnd;
      }
      this.pos = end;
      return bytes.subarray(pos, end);
    }
269127
def bitrate(self):
        """"""

        assert self.parsed_frames, "no frame parsed yet"

        if self._samples == 0:
            return 0

        return (8 * self._payload * self.frequency) // self._samples
833124
public Packet decodePacket(RTMPConnection conn, RTMPDecodeState state, IoBuffer in) {
        final int position = in.position();
        //if (log.isTraceEnabled()) {
            //log.trace("decodePacket - state: {} buffer: {}", state, in);
            //log.trace("decodePacket: position {}, limit {}, {}", position, in.limit(), Hex.encodeHexString(Arrays.copyOfRange(in.array(), position, in.limit())));
            //log.trace("decodePacket: position {}, limit {}", position, in.limit());
            //int lastTs = lastTimestamp.get() != null ? lastTimestamp.get() : 0;
            //if (lastTs == 0 || lastTs >= (MEDIUM_INT_MAX - 100)) {
                //log.trace("decodePacket:{}\n{}", lastTs, Hex.encodeHexString(Arrays.copyOfRange(in.array(), position, in.limit())));
            //}
        //}
        // get RTMP state holder
        RTMP rtmp = conn.getState();
        // read the chunk header (variable from 1-3 bytes)
        final ChunkHeader chunkHeader = ChunkHeader.read(in);
        // represents "packet" header length via "format" only 1 byte in the chunk header is needed here
        int headerLength = RTMPUtils.getHeaderLength(chunkHeader.getFormat());
        headerLength += chunkHeader.getSize() - 1;
        if (in.remaining() < headerLength) {
            state.bufferDecoding(headerLength - in.remaining());
            in.position(position);
            return null;
        }
        final Header header = decodeHeader(chunkHeader, state, in, rtmp);
        // get the channel id
        final int channelId = header != null ? header.getChannelId() : chunkHeader.getChannelId();
        if (header == null || header.isEmpty()) {
            if (log.isTraceEnabled()) {
                log.trace("Header was null or empty - chh: {}", chunkHeader);
            }
            // clear / compact the input and close the channel
            in.clear();
            in.compact();
            // send a NetStream.Failed message
            StreamService.sendNetStreamStatus(conn, StatusCodes.NS_FAILED, "Bad data on channel: " + channelId, "no-name", Status.ERROR, conn.getStreamIdForChannelId(channelId));
            // close the channel on which the issue occurred, until we find a way to exclude the current data
            conn.closeChannel(channelId);
            return null;
        }
        // store the header based on its channel id
        rtmp.setLastReadHeader(channelId, header);
        // ensure that we dont exceed maximum packet size
        int size = header.getSize();
        if (size > MAX_PACKET_SIZE) {
            // Reject packets that are too big, to protect against OOM when decoding has failed in some way
            log.warn("Packet size exceeded. size={}, max={}, connId={}", header.getSize(), MAX_PACKET_SIZE, conn.getSessionId());
            // send a NetStream.Failed message
            StreamService.sendNetStreamStatus(conn, StatusCodes.NS_FAILED, "Data exceeded maximum allowed by " + (size - MAX_PACKET_SIZE) + " bytes", "no-name", Status.ERROR, conn.getStreamIdForChannelId(channelId));
            throw new ProtocolException(String.format("Packet size exceeded. size: %s", header.getSize()));
        }
        // get the size of our chunks
        int readChunkSize = rtmp.getReadChunkSize();
        // check to see if this is a new packet or continue decoding an existing one
        Packet packet = rtmp.getLastReadPacket(channelId);
        if (packet == null) {
            // create a new packet
            packet = new Packet(header.clone());
            // store the packet based on its channel id
            rtmp.setLastReadPacket(channelId, packet);
        }
        // get the packet data
        IoBuffer buf = packet.getData();
        //if (log.isTraceEnabled()) {
            //log.trace("Source buffer position: {}, limit: {}, packet-buf.position {}, packet size: {}", new Object[] { in.position(), in.limit(), buf.position(), header.getSize() });
        //}
        // read chunk
        int length = Math.min(buf.remaining(), readChunkSize);
        if (in.remaining() < length) {
            //log.debug("Chunk too small, buffering ({},{})", in.remaining(), length);
            // how much more data we need to continue?
            state.bufferDecoding(in.position() - position + length);
            // we need to move back position so header will be available during another decode round
            in.position(position);
            return null;
        }
        // get the chunk from our input
        byte[] chunk = Arrays.copyOfRange(in.array(), in.position(), in.position() + length);
        //if (log.isTraceEnabled()) {
            //log.trace("Read chunkSize: {}, length: {}, chunk: {}", readChunkSize, length, Hex.encodeHexString(chunk));
        //}
        // move the position
        in.skip(length);
        // put the chunk into the packet
        buf.put(chunk);
        if (buf.hasRemaining()) {
            //if (log.isTraceEnabled()) {
                //log.trace("Packet is incomplete ({},{})", buf.remaining(), buf.limit());
            //}
            return null;
        }
        // flip so we can read / decode the packet data into a message
        buf.flip();
        try {
            // timebase + timedelta
            final int timestamp = header.getTimer();
            // store the last ts in thread local for debugging
            //lastTimestamp.set(header.getTimerBase());
            final IRTMPEvent message = decodeMessage(conn, packet.getHeader(), buf);
            // flash will send an earlier time stamp when resetting a video stream with a new key frame. To avoid dropping it, we give it the 
            // minimal increment since the last message. To avoid relative time stamps being mis-computed, we don't reset the header we stored.
            message.setTimestamp(timestamp);
            if (log.isTraceEnabled()) {
                log.trace("Decoded message: {}", message);
            }
            packet.setMessage(message);
            if (message instanceof ChunkSize) {
                ChunkSize chunkSizeMsg = (ChunkSize) message;
                rtmp.setReadChunkSize(chunkSizeMsg.getSize());
            } else if (message instanceof Abort) {
                log.debug("Abort packet detected");
                // client is aborting a message, reset the packet because the next chunk will start a new packet
                Abort abort = (Abort) message;
                rtmp.setLastReadPacket(abort.getChannelId(), null);
                packet = null;
            }
            // collapse the time stamps on the last header after decode is complete
            Header lastHeader = rtmp.getLastReadHeader(channelId);
            lastHeader.setTimerBase(timestamp);
            // clear the delta
            //lastHeader.setTimerDelta(0);
            if (log.isTraceEnabled()) {
                log.trace("Last read header after decode: {}", lastHeader);
            }
        } finally {
            rtmp.setLastReadPacket(channelId, null);
        }
        return packet;
    }
716482
def get_stream_duration(stream):
    
    epoch = lal.LIGOTimeGPS(stream.epoch.gpsSeconds,
                            stream.epoch.gpsNanoSeconds)
    # loop over each file in the stream cache and query its duration
    nfile = stream.cache.length
    duration = 0
    for dummy_i in range(nfile):
        for dummy_j in range(lalframe.FrFileQueryNFrame(stream.file)):
            duration += lalframe.FrFileQueryDt(stream.file, 0)
            lalframe.FrStreamNext(stream)
    # rewind stream and return
    lalframe.FrStreamSeek(stream, epoch)
    return duration
55490
def to_bytes(self):
        '''
        
        '''
        hdr = struct.pack(RIPv2._PACKFMT, self.command.value, 2)
        routes = b''.join([r.to_bytes() for r in self._routes])
        return hdr + routes
247187
def get_bytes(self):
        """"""

        ret = struct.pack("<I16s16sQ", client_DH_inner_data.constructor, self.nonce, self.server_nonce,
                           self.retry_id)

        bytes_io = BytesIO()
        bytes_io.write(ret)
        serialize_string(bytes_io, self.g_b)

        return bytes_io.getvalue()
728729
private long getTotalBytes(String bucketName,
                               AmazonCloudWatch client) {
        long totalBytes = 0;
        totalBytes += getMetricData(bucketName,
                                    "BucketSizeBytes",
                                    "StandardStorage",
                                    client);
        totalBytes += getMetricData(bucketName,
                                    "BucketSizeBytes",
                                    "StandardIAStorage",
                                    client);
        totalBytes += getMetricData(bucketName,
                                    "BucketSizeBytes",
                                    "ReducedRedundancyStorage",
                                    client);
        return totalBytes;
    }
540505
@JmxGetter(name = "avgFetchEntriesNetworkTimeMs", description = "average time spent on network, for streaming operations")
    public double getAvgFetchEntriesNetworkTimeMs() {
        return networkTimeCounterMap.get(Operation.FETCH_ENTRIES).getAvgEventValue()
               / Time.NS_PER_MS;
    }
33673
def maxLinkBitrates()
            joinThread()
            up, down = 0, 0
            begin
                up_p = MiniUPnP.new_uintp()
                down_p = MiniUPnP.new_uintp()
                if MiniUPnP.UPNP_GetLinkLayerMaxBitRates(@urls.controlURL_CIF,
                                                         @data.servicetype_CIF,
                                                         down_p,up_p) != 0 then
                    raise UPnPException.new, "Error while retriving maximum link bitrates."
                end
                up = MiniUPnP.uintp_value(up_p)
                down = MiniUPnP.uintp_value(down_p)
            rescue
                raise
            ensure
                MiniUPnP.delete_uintp(up_p)
                MiniUPnP.delete_uintp(down_p)
            end
            return down,up
        end
501902
private long getRemainingBytes() {
        if (in != null) {
            if (!useLoadBuf) {
                return in.remaining();
            }
            try {
                if (channel.isOpen()) {
                    return channelSize - channel.position() + in.remaining();
                } else {
                    return in.remaining();
                }
            } catch (Exception e) {
                log.error("Error getRemainingBytes", e);
            }
        }
        return 0;
    }
1278685
private int receivePacket() throws IOException {
    eventStartReceivePacket();
    
    long startTime = System.currentTimeMillis();
    
    // The packet format is documented in DFSOuputStream.Packet.getBuffer().
    //
    int payloadLen = readNextPacket();
    
    if (payloadLen <= 0) {
      return payloadLen;
    }
    
    buf.mark();
    //read the header
    buf.getInt(); // packet length
    int packetVersion;
    if (pktIncludeVersion) {
      packetVersion = buf.getInt();
    } else {
      packetVersion = DataTransferProtocol.PACKET_VERSION_CHECKSUM_FIRST;
    }
    offsetInBlock = buf.getLong(); // get offset of packet in block
    long seqno = buf.getLong();    // get seqno
    
    byte booleanFieldValue = buf.get();
    boolean lastPacketInBlock = ((booleanFieldValue &
    DataNode.isLastPacketInBlockMask) == 0 ) ?
    false : true;

    boolean forceSync = ((booleanFieldValue & DataNode.forceSyncMask) == 0 ) ?
    false : true;

    int endOfHeader = buf.position();
    buf.reset();
    
    if (LOG.isDebugEnabled()){
      LOG.debug("Receiving one packet for block " + block +
                " of length " + payloadLen +
                " seqno " + seqno +
                " offsetInBlock " + offsetInBlock +
                " lastPacketInBlock " + lastPacketInBlock);
    }
    
    eventEndReceivePacketStartForward();
    
    // First write the packet to the mirror:
    if (mirrorOut != null && !mirrorError) {
      try {
        long mirrorWriteStartTime = System.currentTimeMillis();
        mirrorOut.write(buf.array(), buf.position(), buf.remaining());
        mirrorOut.flush();
        long mirrorWritePacketDuration = System.currentTimeMillis() - mirrorWriteStartTime;
        datanode.myMetrics.mirrorWritePacketLatency.inc(mirrorWritePacketDuration);
        if (mirrorWritePacketDuration > slowPacketThreshold) {
          LOG.info("operationTooSlow : mirrorPacket for block " + block +
              " of length " + payloadLen +
              " seqno " + seqno +
              " offsetInBlock " + offsetInBlock +
              " lastPacketInBlock " + lastPacketInBlock +
              " to mirror : " + mirrorAddr +
              " took : " + mirrorWritePacketDuration);
          datanode.myMetrics.slowMirrorWritePacketNumOps.inc(1);
        }
      } catch (IOException e) {
        handleMirrorOutError(e);
      }
    }

    buf.position(endOfHeader);        
    int len = buf.getInt();
    
    if (len < 0) {
      throw new IOException("Got wrong length during writeBlock(" + block + 
                            ") from " + inAddr + " at offset " + 
                            offsetInBlock + ": " + len); 
    }
    
    eventEndForwardStartEnqueue();

    Packet ackPacket = null;
    if (responder != null) {
      ackPacket = ((PacketResponder) responder.getRunnable()).enqueue(seqno,
          lastPacketInBlock, offsetInBlock + len, profileForCurrentPacket);
    }
    
    eventEndEnqueueStartSetPostion();

    if (len == 0) {
      LOG.debug("Receiving empty packet for block " + block);
    } else {
      setBlockPosition(offsetInBlock);  // adjust file position
      int firstChunkOffset = (int) (offsetInBlock % bytesPerChecksum);

      long expectedBlockCrcOffset = offsetInBlock;
      offsetInBlock += len;
      this.replicaBeingWritten.setBytesReceived(offsetInBlock);
      
      int numChunks = ((firstChunkOffset + len + bytesPerChecksum - 1) / bytesPerChecksum);
      
      if (buf.remaining() != (numChunks * checksumSize + len)) {
        throw new IOException("Data remaining in packet does not match "
            + "sum of checksumLen and dataLen buf.remaining() "
            + buf.remaining() + " numChunks " + numChunks + " len " + len
            + " offsetInBlock " + offsetInBlock);
      }
      int checksumOff = buf.position();
      int dataOff;
      if (packetVersion == DataTransferProtocol.PACKET_VERSION_CHECKSUM_FIRST) {
        int checksumLen = numChunks * checksumSize;
        dataOff = checksumOff + checksumLen;
      } else if (packetVersion == DataTransferProtocol.PACKET_VERSION_CHECKSUM_INLINE) {
        dataOff = checksumOff;
      } else {
        throw new IOException("Packet version " + packetVersion + " not supported.");
      }
      byte pktBuf[] = buf.array();
      
      buf.position(buf.limit()); // move to the end of the data.

      eventEndSetPositionStartVerifyChecksum();

      
      /* skip verifying checksum iff this is not the last one in the 
       * pipeline and clientName is non-null. i.e. Checksum is verified
       * on all the datanodes when the data is being written by a 
       * datanode rather than a client. Whe client is writing the data, 
       * protocol includes acks and only the last datanode needs to verify 
       * checksum.
       */
      if (mirrorOut == null || clientName.length() == 0) {
        verifyChunks(pktBuf, dataOff, len, pktBuf, checksumOff,
           firstChunkOffset, packetVersion);
      }
      
      eventEndVerifyChecksumStartUpdateBlockCrc();
            
      if (datanode.updateBlockCrcWhenWrite) {
        // update Block CRC.
        // It introduces extra costs in critical code path. But compared to the
        // total checksum calculating costs (the previous operation),
        // this costs are negligible. If we want to optimize, we can optimize it
        // together with the previous operation to hide the latency from disk
        // I/O latency.
        int chunkOffset = (int) (expectedBlockCrcOffset % bytesPerChecksum);
        int crcCalculateOffset = checksumOff;
        for (int i = 0; i < numChunks; i++) {
          int bytesInChunk;
          if (i != numChunks - 1) {
            bytesInChunk = bytesPerChecksum - chunkOffset;
          } else {
            bytesInChunk = (len + chunkOffset) % bytesPerChecksum;
            if (bytesInChunk == 0) {
              bytesInChunk = bytesPerChecksum;
            }
          }
          if (packetVersion == DataTransferProtocol.PACKET_VERSION_CHECKSUM_INLINE) {
            // Needs to skip the data chunk for the checksum
            crcCalculateOffset += bytesInChunk;
          }
          replicaBeingWritten.updateBlockCrc(expectedBlockCrcOffset,
              bytesInChunk,
              DataChecksum.getIntFromBytes(pktBuf, crcCalculateOffset));
          crcCalculateOffset += checksum.getChecksumSize();
          expectedBlockCrcOffset += bytesInChunk;
          
          chunkOffset = 0;
        }
      }

      eventEndUpdateBlockCrcStartWritePacket();

      try {
        long writeStartTime = System.currentTimeMillis();

        blockWriter.writePacket(pktBuf, len, dataOff, checksumOff, numChunks,
            packetVersion);

        datanode.myMetrics.bytesWritten.inc(len);
        
        eventEndWritePacketStartFlush();

        // / flush entire packet before sending ack
        this.bufSizeSinceLastSync += len;
        flush(forceSync);

        attemptFadvise(len);
        if (forceSync) {
          this.bufSizeSinceLastSync = 0;
        } else if (this.flushKb > 0
            && this.bufSizeSinceLastSync >= this.flushKb * 1024) {
          long syncStartOffset = offsetInBlock - this.bufSizeSinceLastSync;
          if (syncStartOffset < 0) {
            syncStartOffset = 0;
          }
          long bytesToSync = offsetInBlock - syncStartOffset;
          long startFileRangeSync = System.currentTimeMillis();
          fileRangeSync(bytesToSync, syncFileRange);
          long syncFileRangeDuration = System.currentTimeMillis() - startFileRangeSync;
          datanode.myMetrics.syncFileRangeLatency.inc(syncFileRangeDuration);
          if (syncFileRangeDuration > slowPacketThreshold) {
            LOG.info("operationTooSlow : syncFileRange for block " + block +
                " of length " + payloadLen +
                " seqno " + seqno +
                " offsetInBlock " + offsetInBlock +
                " lastPacketInBlock " + lastPacketInBlock +
                " took : " + syncFileRangeDuration);
          }
          this.bufSizeSinceLastSync = 0;
        }
        this.replicaBeingWritten.setBytesOnDisk(offsetInBlock);

        // Record time taken to write packet
        long writePacketDuration = System.currentTimeMillis() - writeStartTime;
        datanode.myMetrics.writePacketLatency.inc(writePacketDuration);
        if (writePacketDuration > slowPacketThreshold) {
          LOG.info("operationTooSlow : writePacket for block " + block +
              " of length " + payloadLen +
              " seqno " + seqno +
              " offsetInBlock " + offsetInBlock +
              " lastPacketInBlock " + lastPacketInBlock +
              " took : " + writePacketDuration);
          datanode.myMetrics.slowWritePacketNumOps.inc(1);
        }

        eventEndFlush();
      } catch (ClosedByInterruptException cix) {
        LOG.warn(
            "Thread interrupted when flushing bytes to disk. Might cause inconsistent sates",
            cix);
        throw cix;
      } catch (InterruptedIOException iix) {
        LOG.warn(
            "InterruptedIOException when flushing bytes to disk. Might cause inconsistent sates",
            iix);
        throw iix;
      } catch (IOException iex) {
        datanode.checkDiskError(iex);
        throw iex;
      }
    }
    if (ackPacket != null) {
      ackPacket.setPersistent();
    }
    
    if (throttler != null) { // throttle I/O
      throttler.throttle(payloadLen);
    }

    long receiveAndWritePacketDuration = System.currentTimeMillis() - startTime;
    datanode.myMetrics.receiveAndWritePacketLatency.inc(receiveAndWritePacketDuration);
    
    eventEndCurrentPacket();

    return payloadLen;
  }
844048
def decode(self):
        

        fmt, _, stream, uuid, sent_timestamp, reading_timestamp, reading_value = unpack("<BBHLLLL", self.raw_report)
        assert fmt == 0

        # Estimate the UTC time when this device was turned on
        time_base = self.received_time - datetime.timedelta(seconds=sent_timestamp)

        reading = IOTileReading(reading_timestamp, stream, reading_value, time_base=time_base)
        self.origin = uuid
        self.sent_timestamp = sent_timestamp

        return [reading], []