def open (filename, mode='r', **options):
    """Returns an instance of a :class:`PCapStream` class which contains
    the ``read()``, ``write()``, and ``close()`` methods.  Binary mode
    is assumed for this module, so the "b" is not required when
    calling ``open()``.

    If the optiontal ``rollover`` parameter is True, a
    :class:`PCapRolloverStream` is created instead.  In that case
    ``filename`` is treated as a ``strftime(3)`` format string and
    ``nbytes``, ``npackets``, ``nseconds``, and ``dryrun`` parameters
    may also be specified.  See :class:``PCapRolloverStream`` for more
    information.

    NOTE: :class:`PCapRolloverStream` is always opened in write mode
    ("wb") and supports only ``write()`` and ``close()``, not
    ``read()``.
    """
    mode = mode.replace('b', '') + 'b'

    if options.get('rollover', False):
        stream = PCapRolloverStream(filename,
                                    options.get('nbytes'  , None),
                                    options.get('npackets', None),
                                    options.get('nseconds', None),
                                    options.get('dryrun'  , False))
    else:
        stream = PCapStream( __builtin__.open(filename, mode), mode )

    return stream