Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7984487
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T11:17:07+00:00 2026-06-04T11:17:07+00:00

I have a really annoying problem that I tried to solve for a few

  • 0

I have a really annoying problem that I tried to solve for a few days.
I can’t find any information on the net.

I tried to solve it myself, consulted with the documentations.
But nothing works.

My problem is

When I assign a variable X with RandMAC() function, X should be the same every time I use it.

Like, X = RandMAC(), and let say X is now AA:BB:CC:DD:EE:FF
and when I print X for 3 times, it should be something like this.

X = AA:BB:CC:DD:EE:FF  
X = AA:BB:CC:DD:EE:FF  
X = AA:BB:CC:DD:EE:FF  

But what the code actually does is

X = AA:BB:CC:DD:EE:FF  
X = 00:0A:0B:0C:0D:0E:0F  
X = 11:22:33:44:55:66  

So it changed every time I call print X.

How can I solve this issue ?

My code is as follow.

from scapy.all import *

X = RandMAC()

print X
print X
print X

Thank you all in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T11:17:09+00:00Added an answer on June 4, 2026 at 11:17 am

    RandMAC is a class, and when you call RandMAC() what you get is an instance of that class. scapy has a whole lot of these RandXXXXX classes, and they all behave in the same way: an instance of the class is really a sort of random-thing-generator, not a fixed (but randomly chosen) thing. In this instance, a RandMac is built out of six RandBytes, and a RandByte turns into a random value from 0 to 255 every time its value is asked for.

    The idea, I think, is to make it easy to build (e.g.) an IP packet randomizer that gives you IP packets that are all the same except that a couple of fields are chosen at random for every packet.

    So, anyway, many operations on random-thing objects are effectively delegated to the results of “fixing” them (i.e., picking a particular random value); see volatile.py in the source code, class VolatileValue; the magic happens in the __getattr__ method. In particular, this applies to stringifying via __str__, which is what str() does as observed by Lycha and what print does as observed by Karun S.

    If you want to get a single random value, the nearest thing to the Right Way is probably to call the _fix method: X = RandMAC()._fix(). That happens to be the same as str for RandMAC, but e.g. if you have a random integer then _fix will give you an actual integer while str will give you its string representation.

    None of this appears to be documented. Don’t make any large bets on it still working in future versions. (But, for what it’s worth, volatile.py hasn’t changed for about two years.)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a css/html related problem that's really annoying me :( I have a
Hey I have a really annoying IE7 bug that I am trying to work
Hey guys, I have another really annoying problem in IE. I am using a
I do experience a really annoying problem with TestNG and RESTeasy. I do have
have a really annoying time developing some code for a set of UserControls that
I have a really stuburn layout, that I just can not resolve .. -
At my company we have a really annoying problem with our linker (ld 2.17).
I have a really annoying problem. My app is published in the AppStore. Everytime
I am stuck with something quite simple but really annoying: I have an xml
I have really basic question. How can I get form id by input element

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.