<commit_before>// Module included in the following assemblies:
//
// * networking/openshift_sdn/enabling-multicast.adoc
// * networking/ovn_kubernetes_network_provider/enabling-multicast.adoc

ifeval::["{context}" == "openshift-sdn-enabling-multicast"]
:namespace: netnamespace
:annotation: netnamespace.network.openshift.io/multicast-enabled=true
endif::[]
ifeval::["{context}" == "ovn-kubernetes-enabling-multicast"]
:namespace: namespace
:annotation: k8s.ovn.org/multicast-enabled=true
endif::[]

[id="nw-enabling-multicast_{context}"]
= Enabling multicast between Pods

You can enable multicast between Pods for your project.

.Prerequisites

* Install the OpenShift Command-line Interface (CLI), commonly known as `oc`.
* You must log in to the cluster with a user that has the `cluster-admin` role.

.Procedure

* Run the following command to enable multicast for a project. Replace `<namespace>` with the namespace for the project you want to enable multicast for.
+
[source,terminal,subs="attributes+"]
----
$ oc annotate {namespace} <namespace> \
    {annotation}
----

.Verification steps

To verify that multicast is enabled for a project, complete the following procedure:

. Change your current project to the project that you enabled multicast for. Replace `<project>` with the project name.
+
[source,terminal]
----
$ oc project <project>
----

. Create a Pod to act as a multicast receiver:
+
[source,terminal]
----
$ cat <<EOF| oc create -f -
apiVersion: v1
kind: Pod
metadata:
  name: mlistener
  labels:
    app: multicast-verify
spec:
  containers:
    - name: mlistener
      image: registry.access.redhat.com/ubi8
      command: ["/bin/sh", "-c"]
      args:
        ["dnf -y install socat hostname && sleep inf"]
      ports:
        - containerPort: 30102
          name: mlistener
          protocol: UDP
EOF
----

. Create a Pod to act as a multicast sender:
+
[source,terminal]
----
$ cat <<EOF| oc create -f -
apiVersion: v1
kind: Pod
metadata:
  name: msender
  labels:
    app: multicast-verify
spec:
  containers:
    - name: msender
      image: registry.access.redhat.com/ubi8
      command: ["/bin/sh", "-c"]
      args:
        ["dnf -y install socat && sleep inf"]
EOF
----

. Start the multicast listener.

.. Get the IP address for the Pod:
+
[source,terminal]
----
$ POD_IP=$(oc get pods mlistener -o jsonpath='{.status.podIP}')
----

.. To start the multicast listener, in a new terminal window or tab, enter the following command:
+
[source,terminal]
----
$ oc exec mlistener -i -t -- \
    socat UDP4-RECVFROM:30102,ip-add-membership=172.16.31.10:$POD_IP,fork EXEC:hostname
----

. Start the multicast transmitter.

.. Get the Pod network IP address range:
+
[source,terminal]
----
$ CIDR=$(oc get Network.config.openshift.io cluster \
    -o jsonpath='{.status.clusterNetwork[0].cidr}')
----

.. To send a multicast message, enter the following command:
+
[source,terminal]
----
$ oc exec msender -i -t -- \
    /bin/bash -c "echo | socat STDIO UDP4-DATAGRAM:172.16.31.10:30102,range=$CIDR"
----
+
If multicast is working, the previous command returns the following output:
+
----
mlistener
----

ifeval::["{context}" == "openshift-sdn-enabling-multicast"]
:!annotation:
:!namespace:
endif::[]
ifeval::["{context}" == "ovn-kubernetes-enabling-multicast"]
:!annotation:
:!namespace:
endif::[]<commit_msg>Fix multicast SDN example.<commit_after>// Module included in the following assemblies:
//
// * networking/openshift_sdn/enabling-multicast.adoc
// * networking/ovn_kubernetes_network_provider/enabling-multicast.adoc

ifeval::["{context}" == "openshift-sdn-enabling-multicast"]
:namespace: netnamespace
:annotation: netnamespace.network.openshift.io/multicast-enabled=true
endif::[]
ifeval::["{context}" == "ovn-kubernetes-enabling-multicast"]
:namespace: namespace
:annotation: k8s.ovn.org/multicast-enabled=true
endif::[]

[id="nw-enabling-multicast_{context}"]
= Enabling multicast between Pods

You can enable multicast between Pods for your project.

.Prerequisites

* Install the OpenShift Command-line Interface (CLI), commonly known as `oc`.
* You must log in to the cluster with a user that has the `cluster-admin` role.

.Procedure

* Run the following command to enable multicast for a project. Replace `<namespace>` with the namespace for the project you want to enable multicast for.
+
[source,terminal,subs="attributes+"]
----
$ oc annotate {namespace} <namespace> \
    {annotation}
----

.Verification steps

To verify that multicast is enabled for a project, complete the following procedure:

. Change your current project to the project that you enabled multicast for. Replace `<project>` with the project name.
+
[source,terminal]
----
$ oc project <project>
----

. Create a Pod to act as a multicast receiver:
+
[source,terminal]
----
$ cat <<EOF| oc create -f -
apiVersion: v1
kind: Pod
metadata:
  name: mlistener
  labels:
    app: multicast-verify
spec:
  containers:
    - name: mlistener
      image: registry.access.redhat.com/ubi8
      command: ["/bin/sh", "-c"]
      args:
        ["dnf -y install socat hostname && sleep inf"]
      ports:
        - containerPort: 30102
          name: mlistener
          protocol: UDP
EOF
----

. Create a Pod to act as a multicast sender:
+
[source,terminal]
----
$ cat <<EOF| oc create -f -
apiVersion: v1
kind: Pod
metadata:
  name: msender
  labels:
    app: multicast-verify
spec:
  containers:
    - name: msender
      image: registry.access.redhat.com/ubi8
      command: ["/bin/sh", "-c"]
      args:
        ["dnf -y install socat && sleep inf"]
EOF
----

. Start the multicast listener.

.. Get the IP address for the Pod:
+
[source,terminal]
----
$ POD_IP=$(oc get pods mlistener -o jsonpath='{.status.podIP}')
----

.. To start the multicast listener, in a new terminal window or tab, enter the following command:
+
[source,terminal]
----
$ oc exec mlistener -i -t -- \
    socat UDP4-RECVFROM:30102,ip-add-membership=172.16.31.10:$POD_IP,fork EXEC:hostname
----

. Start the multicast transmitter.

.. Get the Pod network IP address range:
+
[source,terminal]
----
$ CIDR=$(oc get Network.config.openshift.io cluster \
    -o jsonpath='{.status.clusterNetwork[0].cidr}')
----

.. To send a multicast message, enter the following command:
+
[source,terminal]
----
$ oc exec msender -i -t -- \
    /bin/bash -c "echo | socat STDIO UDP4-DATAGRAM:172.16.31.10:30102,range=$CIDR,ip-multicast-ttl=64"
----
+
If multicast is working, the previous command returns the following output:
+
----
mlistener
----

ifeval::["{context}" == "openshift-sdn-enabling-multicast"]
:!annotation:
:!namespace:
endif::[]
ifeval::["{context}" == "ovn-kubernetes-enabling-multicast"]
:!annotation:
:!namespace:
endif::[]
{'fraction_non_alphanumeric': 0.14319702602230483, 'fraction_numerical': 0.012490706319702602, 'mean_word_length': 3.4929859719438876, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 4, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7229470', 'n_tokens_mistral': 2317, 'n_tokens_neox': 2176, 'n_words': 656}