L1
L1
TicToc Project in
OMNeT++
1.Computer Network:
Computer networks are complex systems connecting
numerous devices like computers, servers, and other
equipment through various communication channels.
► Events: Data packet arrival, router forwarding, link
failure constantly occur, dictating the flow of
information.
► Simulation: You can evaluate network
performance, optimize routing protocols, and test
new technologies.
https://en.wikipedia.org/wiki/Computer_network_diagram
2.Traffic Network:
► Events: Vehicle arrival, lane change, traffic
light change.
► Simulation: You can test different traffic
management strategies, predict
congestion, and evaluate infrastructure
improvements.
tictoc1.ned
https://doc.omnetpp.org/omnetpp/api/classomnetpp_1_1cSimpleModule.html#a517a5ef252044
90292b84fa5bdd12288
The activity() function normally contains an infinite loop, with at least a wait() or receiv
The most important functions that can be used in activity() are :
► receive() -- to receive messages (events)
► wait() -- to suspend execution for some time (model time)
► send() family of functions -- to send messages to other modules
► scheduleAt() -- to schedule an event (the module "sends a message to itself")
► cancelEvent() -- to delete an event scheduled with scheduleAt()
► end() -- to finish execution of this module (same as exiting the activity() function)
https://doc.omnetpp.org/omnetpp/manual/#sec:simple-modules:activity
https://doc.omnetpp.org/omnetpp/api/classomnet
pp_1_1cSimpleModule.html#a97c57271ca2fc95225
ed8514750cac27
https://doc.omnetpp.org/omnetpp/api/classomnetpp_1_1cModule.html#a527d7dc09
12da702a9bdaaf2bf3c067a
https://doc.omnetpp.org/omnetpp/api/classomnet
pp_1_1cSimulation.html#ad21862849b0933a7550b5
5aa90d8620c
https://doc.omnetpp.org/omnetpp/api/group__Log
ging.html#ga650ef3eff8a2900bef69dae29c05d2dd
1. cMessage:
► Base class for messages in OMNeT++
► Used for simple messages, control signals, and timers
2. cPacket (inherits from cMessage):
► Represents network packets/frames
https://docs.omnetpp.org/tutorials/tictoc/part3/
•Use EV << for simple •Log when sending •Open separate log
logging in C++ code. initial message and windows for Tic and
receiving/resending Toc in GUI.
messages.
https://docs.omnetpp.org/tutorials/tictoc/part3/
Dr. Mohammed Al-Hubaishi
50
3.6 Modeling Processing Delay
► we'll add some timing: tic and toc will hold the message for 1
simulated second before sending it back
► Introduce a delay (e.g., 1 simulated second) before replying to
messages
► Implement delay using self-messages (scheduleAt function)
► Distinguish between arrival of a new message and a returning
self-message in handleMessage()
► Simulates processing delays typical in real systems
Self-Messages
Scheduling
Handling
• Set distribution in
Configuration omnetpp.ini.
Dr. Mohammed Al-Hubaishi
56
Random Numbers and
Parameters codes
► Model a stop-and-wait protocol where tic starts a timer after sending a message
► Use self-messages as timers; if timeout occurs, resend the message
► Cancel the timer upon receipt of a reply using cancelEvent()
► Visual feedback with bubble() calls to indicate events (e.g., message drop)
Message
• Simulate message loss in Toc.
Loss
► https://omnetpp.org/
► https://docs.omnetpp.org/tutorials/tictoc/part3/
► https://doc.omnetpp.org/omnetpp/manual/
► https://doc.omnetpp.org/omnetpp/api/classomnetpp_1_1cModule.html