Question about simulating clock modules in Omnet++
up vote
0
down vote
favorite
Scenario:
Node 1 (Sender) has a local clock (40.000 MHz) and sends this clock signal as a continuous bit stream (01010101...) on a serial (i.e. fiberoptic) link to Node 2 (Receiver).
Node 2 has its own (local or global, e.g. 41.000 MHz) clock and must determine the phase and frequency of the local clock of Node 1 with respect to its own clock using the (clock) data it is receiving from Node 1.
Alternatively, I can think of Node 1 sending individual messages, but at a well-defined frequency of 40.000 MHz, to Node 2. Again, Node 2 (which has its own local or global 41.000 MHz clock) must determine the phase and frequency of Node 1's local clock with respect to its own clock using the arrival timing of the messages it is receiving from Node 1
Question: How would I implement either of these scenarios in OMNet++?
c++ simulation omnet++
add a comment |
up vote
0
down vote
favorite
Scenario:
Node 1 (Sender) has a local clock (40.000 MHz) and sends this clock signal as a continuous bit stream (01010101...) on a serial (i.e. fiberoptic) link to Node 2 (Receiver).
Node 2 has its own (local or global, e.g. 41.000 MHz) clock and must determine the phase and frequency of the local clock of Node 1 with respect to its own clock using the (clock) data it is receiving from Node 1.
Alternatively, I can think of Node 1 sending individual messages, but at a well-defined frequency of 40.000 MHz, to Node 2. Again, Node 2 (which has its own local or global 41.000 MHz clock) must determine the phase and frequency of Node 1's local clock with respect to its own clock using the arrival timing of the messages it is receiving from Node 1
Question: How would I implement either of these scenarios in OMNet++?
c++ simulation omnet++
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
Scenario:
Node 1 (Sender) has a local clock (40.000 MHz) and sends this clock signal as a continuous bit stream (01010101...) on a serial (i.e. fiberoptic) link to Node 2 (Receiver).
Node 2 has its own (local or global, e.g. 41.000 MHz) clock and must determine the phase and frequency of the local clock of Node 1 with respect to its own clock using the (clock) data it is receiving from Node 1.
Alternatively, I can think of Node 1 sending individual messages, but at a well-defined frequency of 40.000 MHz, to Node 2. Again, Node 2 (which has its own local or global 41.000 MHz clock) must determine the phase and frequency of Node 1's local clock with respect to its own clock using the arrival timing of the messages it is receiving from Node 1
Question: How would I implement either of these scenarios in OMNet++?
c++ simulation omnet++
Scenario:
Node 1 (Sender) has a local clock (40.000 MHz) and sends this clock signal as a continuous bit stream (01010101...) on a serial (i.e. fiberoptic) link to Node 2 (Receiver).
Node 2 has its own (local or global, e.g. 41.000 MHz) clock and must determine the phase and frequency of the local clock of Node 1 with respect to its own clock using the (clock) data it is receiving from Node 1.
Alternatively, I can think of Node 1 sending individual messages, but at a well-defined frequency of 40.000 MHz, to Node 2. Again, Node 2 (which has its own local or global 41.000 MHz clock) must determine the phase and frequency of Node 1's local clock with respect to its own clock using the arrival timing of the messages it is receiving from Node 1
Question: How would I implement either of these scenarios in OMNet++?
c++ simulation omnet++
c++ simulation omnet++
asked Nov 19 at 16:18
Minsoo
1
1
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
up vote
0
down vote
I don't know OMNet++ but if you have the ticks of both clocks, would
the_other_clocks_freq = the_other_clocks_ticks*your_own_freq/your_own_ticks
work to get the frequency? Example:
#include <iostream>
class Clock {
uint64_t m_freq;
uint64_t m_ticks;
public:
Clock(uint64_t Base) : m_freq(Base), m_ticks(0) {}
void tick() { ++m_ticks; }
operator double () const { return static_cast<double>(m_ticks)/static_cast<double>(m_freq); }
uint64_t getTicks() const { return m_ticks; }
uint64_t getOtherClockFreq(uint64_t other_ticks) {
return (other_ticks*m_freq)/m_ticks;
}
};
int main() {
Clock Node1(40000000);
Clock Node2(41000000);
// simulate 0.00075s
for(int i=0; i<40000*75/100; ++i) Node1.tick();
for(int i=0; i<41000*75/100; ++i) Node2.tick();
std::cout << Node1 << "sn"; // 0.00075s
std::cout << Node2 << "sn"; // 0.00075s
// calculate the base freq of the other clock
std::cout << Node1.getOtherClockFreq(Node2.getTicks()) << " Node2 basen";
std::cout << Node2.getOtherClockFreq(Node1.getTicks()) << " Node1 basen";
}
Output
0.00075s
0.00075s
41000000 Node2 base
40000000 Node1 base
At these speeds you may need something larger than uint64_t to store the ticks though ... and I don't know what phase is in this case.
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
I don't know OMNet++ but if you have the ticks of both clocks, would
the_other_clocks_freq = the_other_clocks_ticks*your_own_freq/your_own_ticks
work to get the frequency? Example:
#include <iostream>
class Clock {
uint64_t m_freq;
uint64_t m_ticks;
public:
Clock(uint64_t Base) : m_freq(Base), m_ticks(0) {}
void tick() { ++m_ticks; }
operator double () const { return static_cast<double>(m_ticks)/static_cast<double>(m_freq); }
uint64_t getTicks() const { return m_ticks; }
uint64_t getOtherClockFreq(uint64_t other_ticks) {
return (other_ticks*m_freq)/m_ticks;
}
};
int main() {
Clock Node1(40000000);
Clock Node2(41000000);
// simulate 0.00075s
for(int i=0; i<40000*75/100; ++i) Node1.tick();
for(int i=0; i<41000*75/100; ++i) Node2.tick();
std::cout << Node1 << "sn"; // 0.00075s
std::cout << Node2 << "sn"; // 0.00075s
// calculate the base freq of the other clock
std::cout << Node1.getOtherClockFreq(Node2.getTicks()) << " Node2 basen";
std::cout << Node2.getOtherClockFreq(Node1.getTicks()) << " Node1 basen";
}
Output
0.00075s
0.00075s
41000000 Node2 base
40000000 Node1 base
At these speeds you may need something larger than uint64_t to store the ticks though ... and I don't know what phase is in this case.
add a comment |
up vote
0
down vote
I don't know OMNet++ but if you have the ticks of both clocks, would
the_other_clocks_freq = the_other_clocks_ticks*your_own_freq/your_own_ticks
work to get the frequency? Example:
#include <iostream>
class Clock {
uint64_t m_freq;
uint64_t m_ticks;
public:
Clock(uint64_t Base) : m_freq(Base), m_ticks(0) {}
void tick() { ++m_ticks; }
operator double () const { return static_cast<double>(m_ticks)/static_cast<double>(m_freq); }
uint64_t getTicks() const { return m_ticks; }
uint64_t getOtherClockFreq(uint64_t other_ticks) {
return (other_ticks*m_freq)/m_ticks;
}
};
int main() {
Clock Node1(40000000);
Clock Node2(41000000);
// simulate 0.00075s
for(int i=0; i<40000*75/100; ++i) Node1.tick();
for(int i=0; i<41000*75/100; ++i) Node2.tick();
std::cout << Node1 << "sn"; // 0.00075s
std::cout << Node2 << "sn"; // 0.00075s
// calculate the base freq of the other clock
std::cout << Node1.getOtherClockFreq(Node2.getTicks()) << " Node2 basen";
std::cout << Node2.getOtherClockFreq(Node1.getTicks()) << " Node1 basen";
}
Output
0.00075s
0.00075s
41000000 Node2 base
40000000 Node1 base
At these speeds you may need something larger than uint64_t to store the ticks though ... and I don't know what phase is in this case.
add a comment |
up vote
0
down vote
up vote
0
down vote
I don't know OMNet++ but if you have the ticks of both clocks, would
the_other_clocks_freq = the_other_clocks_ticks*your_own_freq/your_own_ticks
work to get the frequency? Example:
#include <iostream>
class Clock {
uint64_t m_freq;
uint64_t m_ticks;
public:
Clock(uint64_t Base) : m_freq(Base), m_ticks(0) {}
void tick() { ++m_ticks; }
operator double () const { return static_cast<double>(m_ticks)/static_cast<double>(m_freq); }
uint64_t getTicks() const { return m_ticks; }
uint64_t getOtherClockFreq(uint64_t other_ticks) {
return (other_ticks*m_freq)/m_ticks;
}
};
int main() {
Clock Node1(40000000);
Clock Node2(41000000);
// simulate 0.00075s
for(int i=0; i<40000*75/100; ++i) Node1.tick();
for(int i=0; i<41000*75/100; ++i) Node2.tick();
std::cout << Node1 << "sn"; // 0.00075s
std::cout << Node2 << "sn"; // 0.00075s
// calculate the base freq of the other clock
std::cout << Node1.getOtherClockFreq(Node2.getTicks()) << " Node2 basen";
std::cout << Node2.getOtherClockFreq(Node1.getTicks()) << " Node1 basen";
}
Output
0.00075s
0.00075s
41000000 Node2 base
40000000 Node1 base
At these speeds you may need something larger than uint64_t to store the ticks though ... and I don't know what phase is in this case.
I don't know OMNet++ but if you have the ticks of both clocks, would
the_other_clocks_freq = the_other_clocks_ticks*your_own_freq/your_own_ticks
work to get the frequency? Example:
#include <iostream>
class Clock {
uint64_t m_freq;
uint64_t m_ticks;
public:
Clock(uint64_t Base) : m_freq(Base), m_ticks(0) {}
void tick() { ++m_ticks; }
operator double () const { return static_cast<double>(m_ticks)/static_cast<double>(m_freq); }
uint64_t getTicks() const { return m_ticks; }
uint64_t getOtherClockFreq(uint64_t other_ticks) {
return (other_ticks*m_freq)/m_ticks;
}
};
int main() {
Clock Node1(40000000);
Clock Node2(41000000);
// simulate 0.00075s
for(int i=0; i<40000*75/100; ++i) Node1.tick();
for(int i=0; i<41000*75/100; ++i) Node2.tick();
std::cout << Node1 << "sn"; // 0.00075s
std::cout << Node2 << "sn"; // 0.00075s
// calculate the base freq of the other clock
std::cout << Node1.getOtherClockFreq(Node2.getTicks()) << " Node2 basen";
std::cout << Node2.getOtherClockFreq(Node1.getTicks()) << " Node1 basen";
}
Output
0.00075s
0.00075s
41000000 Node2 base
40000000 Node1 base
At these speeds you may need something larger than uint64_t to store the ticks though ... and I don't know what phase is in this case.
answered Nov 19 at 17:05
Ted Lyngmo
1,447314
1,447314
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53378750%2fquestion-about-simulating-clock-modules-in-omnet%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown