diff --git a/pyof/v0x01/common/header.py b/pyof/v0x01/common/header.py
index 1e62b87..c0489e5 100644
--- a/pyof/v0x01/common/header.py
+++ b/pyof/v0x01/common/header.py
@@ -73,7 +73,7 @@ class Header(GenericStruct):
     length = UBInt16()
     xid = UBInt32()
 
-    def __init__(self, message_type=None, length=None, xid=randint(0, MAXID)):
+    def __init__(self, message_type=None, length=None, xid=None):
         """The constructor takes the optional parameters below.
 
         Args:
@@ -84,4 +84,4 @@ class Header(GenericStruct):
         super().__init__()
         self.message_type = message_type
         self.length = length
-        self.xid = xid
+        self.xid = randint(0, MAXID) if xid is None else xid

Fix Header's random xid
One single random value is used during all code execution.
diff --git a/tests/v0x01/test_common/test_header.py b/tests/v0x01/test_common/test_header.py
index 003621c..3c01fd8 100644
--- a/tests/v0x01/test_common/test_header.py
+++ b/tests/v0x01/test_common/test_header.py
@@ -1,6 +1,7 @@
 """Testing Header structure."""
 import os
 import unittest
+from unittest.mock import patch
 
 from pyof.v0x01.common.header import Header, Type
 
@@ -43,3 +44,9 @@ class TestHeader(unittest.TestCase):
         self.assertEqual(self.message.version, 1)
 
         f.close()
+
+    @patch('pyof.v0x01.common.header.randint')
+    def test_random_xid(self, m):
+        """Each Header instantiations without xid should call randint."""
+        Header(), Header()  # noqa
+        self.assertEqual(m.call_count, 2)

pip install -e .[dev]
parse_log_pytest
requirements.txt
pytest coverage
3.9
requirements.txt
pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning
coverage==7.8.0
exceptiongroup==1.2.2
iniconfig==2.1.0
packaging==24.2
pluggy==1.5.0
pytest==8.3.5
-e git+https://github.com/kytos/python-openflow.git@7185bc685a1e11d159eb4aba5384b795c373567f#egg=python_openflow
tomli==2.2.1

name: python-openflow
channels:
  - defaults
  - https://repo.anaconda.com/pkgs/main
  - https://repo.anaconda.com/pkgs/r
  - conda-forge
dependencies:
  - _libgcc_mutex=0.1=main
  - _openmp_mutex=5.1=1_gnu
  - ca-certificates=2025.2.25=h06a4308_0
  - ld_impl_linux-64=2.40=h12ee557_0
  - libffi=3.4.4=h6a678d5_1
  - libgcc-ng=11.2.0=h1234567_1
  - libgomp=11.2.0=h1234567_1
  - libstdcxx-ng=11.2.0=h1234567_1
  - ncurses=6.4=h6a678d5_0
  - openssl=3.0.16=h5eee18b_0
  - pip=25.0=py39h06a4308_0
  - python=3.9.21=he870216_1
  - readline=8.2=h5eee18b_0
  - setuptools=75.8.0=py39h06a4308_0
  - sqlite=3.45.3=h5eee18b_0
  - tk=8.6.14=h39e8969_0
  - tzdata=2025a=h04d1e81_0
  - wheel=0.45.1=py39h06a4308_0
  - xz=5.6.4=h5eee18b_1
  - zlib=1.2.13=h5eee18b_1
  - pip:
      - coverage==7.8.0
      - exceptiongroup==1.2.2
      - iniconfig==2.1.0
      - packaging==24.2
      - pluggy==1.5.0
      - pytest==8.3.5
      - tomli==2.2.1
prefix: /opt/conda/envs/python-openflow

tests/v0x01/test_common/test_header.py::TestHeader::test_random_xid
tests/v0x01/test_common/test_header.py::TestHeader::test_pack tests/v0x01/test_common/test_header.py::TestHeader::test_size tests/v0x01/test_common/test_header.py::TestHeader::test_unpack
pyof/v0x01/common/header.py
pyof/v0x01/common/header.py