Miscellaneous questions
=======================


How can I open a UDP or TCP port in SLC5 or SLC6?
-------------------------------------------------

There are two options. However, they are incompatible (at least in SLC5). Either use always one method or the other, but not both:

* Modify /etc/sysconfig/iptables and restart the iptables service (open port 4241):

  .. code-block:: sh

    -A INPUT -m state --state NEW -m tcp -p tcp --dport 4241 -j ACCEPT
    sudo /sbin/service iptables restart

* Install xsudo, and then open a TCP port using the Redhat firewall configuration GUI:

  .. code-block:: sh

    wget http://cmsdaq0/cmscdb/cmsswrep/i386_slc4/xsudo-2.0.2-0.noarch.rpm
    sudo rpm -iv xsudo-2.0.2-0.noarch.rpm
    xsudo /usr/bin/system-config-firewall



How can I simulate deterministic and non-deterministic packet loss and delay?
-----------------------------------------------------------------------------

It is very easy, just use the ``tc`` command. see `examples in stackoverflow <http://stackoverflow.com/a/615757>`_.
Common examples (for ``eth0``):

* Drop 0.1% of outgoing packets:

  * If other rules have already been applied to ``eth0`` : ``sudo /sbin/tc qdisc add dev eth0 root netem loss 0.1%``
  * Otherwise : ``sudo /sbin/tc qdisc change dev eth0 root netem loss 0.1%``

* Find out what rules are applied already : ``sudo /sbin/tc -s qdisc ls dev eth0``
* Remove rules : ``sudo /sbin/tc qdisc del dev eth0 root``

N.B. The ``tc`` command with netem only applies these rules (e.g. packet dropping) to **outgoing** packets ...
 * See the ''How can I use netem on incoming traffic?'' FAQ section `here <http://www.linuxfoundation.org/collaborate/workgroups/networking/netem>`__ for details on how to also apply rules to the incoming traffic.

Another useful resource (also contains instructions for doing same thing with ``iptables``) can be found `here <http://sandilands.info/sgordon/dropping-packets-in-ubuntu-linux-using-tc-and-iptables>`__.