func (f *VolumeMeasurementFields) UnmarshalBinary(b []byte) error {
	l := len(b)
	if l < 2 {
		return io.ErrUnexpectedEOF
	}
	f.Flags = b[0]
	offset := 1
	if f.HasTOVOL() {
		if l < offset+8 {
			return io.ErrUnexpectedEOF
		}
		f.TotalVolume = binary.BigEndian.Uint64(b[offset : offset+8])
		offset += 8
	}
	if f.HasULVOL() {
		if l < offset+8 {
			return io.ErrUnexpectedEOF
		}
		f.UplinkVolume = binary.BigEndian.Uint64(b[offset : offset+8])
		offset += 8
	}
	if f.HasDLVOL() {
		if l < offset+8 {
			return io.ErrUnexpectedEOF
		}
		f.DownlinkVolume = binary.BigEndian.Uint64(b[offset : offset+8])
		offset += 8
	}
	if f.HasTONOP() {
		if l < offset+8 {
			return io.ErrUnexpectedEOF
		}
		f.TotalNumberOfPackets = binary.BigEndian.Uint64(b[offset : offset+8])
		offset += 8
	}
	if f.HasULNOP() {
		if l < offset+8 {
			return io.ErrUnexpectedEOF
		}
		f.UplinkNumberOfPackets = binary.BigEndian.Uint64(b[offset : offset+8])
		offset += 8
	}
	if f.HasDLNOP() {
		if l < offset+8 {
			return io.ErrUnexpectedEOF
		}
		f.DownlinkNumberOfPackets = binary.BigEndian.Uint64(b[offset : offset+8])
	}
	return nil
}
UnmarshalBinary parses b into IE.
package ie
import (
	"encoding/binary"
	"io"
)
func NewVolumeMeasurement(flags uint8, tvol, uvol, dvol, tpkt, upkt, dpkt uint64) *IE {
	fields := NewVolumeMeasurementFields(flags, tvol, uvol, dvol, tpkt, upkt, dpkt)
	b, err := fields.Marshal()
	if err != nil {
		return nil
	}
	return New(VolumeMeasurement, b)
}
func (i *IE) VolumeMeasurement() (*VolumeMeasurementFields, error) {
	switch i.Type {
	case VolumeMeasurement:
		fields, err := ParseVolumeMeasurementFields(i.Payload)
		if err != nil {
			return nil, err
		}
		return fields, nil
	case UsageReportWithinSessionModificationResponse,
		UsageReportWithinSessionDeletionResponse,
		UsageReportWithinSessionReportRequest:
		ies, err := i.UsageReport()
		if err != nil {
			return nil, err
		}
		for _, x := range ies {
			if x.Type == VolumeMeasurement {
				return x.VolumeMeasurement()
			}
		}
		return nil, ErrIENotFound
	default:
		return nil, &InvalidTypeError{Type: i.Type}
	}
}
type VolumeMeasurementFields struct {
	Flags                   uint8
	TotalVolume             uint64
	UplinkVolume            uint64
	DownlinkVolume          uint64
	TotalNumberOfPackets    uint64
	UplinkNumberOfPackets   uint64
	DownlinkNumberOfPackets uint64
}
func NewVolumeMeasurementFields(flags uint8, tvol, uvol, dvol, tpkt, upkt, dpkt uint64) *VolumeMeasurementFields {
	f := &VolumeMeasurementFields{Flags: flags}
	if f.HasTOVOL() {
		f.TotalVolume = tvol
	}
	if f.HasULVOL() {
		f.UplinkVolume = uvol
	}
	if f.HasDLVOL() {
		f.DownlinkVolume = dvol
	}
	if f.HasTONOP() {
		f.TotalNumberOfPackets = tpkt
	}
	if f.HasULNOP() {
		f.UplinkNumberOfPackets = upkt
	}
	if f.HasDLNOP() {
		f.DownlinkNumberOfPackets = dpkt
	}
	return f
}
func (f *VolumeMeasurementFields) HasDLNOP() bool {
	return has6thBit(f.Flags)
}
func (f *VolumeMeasurementFields) SetDLNOPFlag() {
	f.Flags |= 0x20
}
func (f *VolumeMeasurementFields) HasULNOP() bool {
	return has5thBit(f.Flags)
}
func (f *VolumeMeasurementFields) SetULNOPFlag() {
	f.Flags |= 0x10
}
func (f *VolumeMeasurementFields) HasTONOP() bool {
	return has4thBit(f.Flags)
}
func (f *VolumeMeasurementFields) SetTONOPFlag() {
	f.Flags |= 0x08
}
func (f *VolumeMeasurementFields) HasDLVOL() bool {
	return has3rdBit(f.Flags)
}
func (f *VolumeMeasurementFields) SetDLVOLFlag() {
	f.Flags |= 0x04
}
func (f *VolumeMeasurementFields) HasULVOL() bool {
	return has2ndBit(f.Flags)
}
func (f *VolumeMeasurementFields) SetULVOLFlag() {
	f.Flags |= 0x02
}
func (f *VolumeMeasurementFields) HasTOVOL() bool {
	return has1stBit(f.Flags)
}
func (f *VolumeMeasurementFields) SetTOVOLFlag() {
	f.Flags |= 0x01
}
func ParseVolumeMeasurementFields(b []byte) (*VolumeMeasurementFields, error) {
	f := &VolumeMeasurementFields{}
	if err := f.UnmarshalBinary(b); err != nil {
		return nil, err
	}
	return f, nil
}