CSE247 on YouTube

Update behavioral design of network implemented in Layered Architecture Assignment OMNet

Computer Networks Lab · OMNeT++ · The LNMIIT
Layered Architecture — Packet Loss, ACK & Timeout
10% packet loss · ACK-based retransmission · Timeout handling
Network Layer Data Link Layer PDU Encapsulation Retransmission OMNeT++ Simulation
Overview
This post presents the corrected solution for the OMNeT++ Layered Architecture Lab — implementing a two-layer (Network Layer + Data Link Layer) simulation with 10% packet loss, ACK-based retransmission, and timeout handling.
Task Summary
a
Network Layer: Define number of packets as a state variable using par()
b
Data Link Layer: Simulate 10% packet loss at the destination
c
Data Link Layer: Retransmit on timeout; reset timeout after each transmission; cancel on ACK
Bugs Fixed — Summary
✓ 10% loss fix ✓ decapsulate() memory leak ✓ ACK leak on drop ✓ copy_message nullptr ✓ old copy_message deleted ✓ self-event leak fixed ✓ unused cGate* in removed
# Bug Wrong Code Fixed Code
1 Packet loss % wrong uniform(0,1) <= 0.8 → 80% drop uniform(0,1) < 0.1 → 10% drop
2 decapsulate() memory leak Return value ignored; outer wrapper sent inner = decapsulate(); send inner; delete outer
3 ACK leak in drop case ACK created but never deleted on drop ACK created only when packet is accepted
4 copy_message garbage init copy_message = new Dll_pkt() — empty packet copy_message = nullptr with null-check guard
5 Old copy_message not deleted Memory leak on every new packet delete copy_message before storing new one
6 Self-event not deleted (NL) cMessage event leaked after use delete msg after every self-message
7 Unused variable cGate* in Declared in nl_node.h but never used Removed from header and .cc file
How to Run in OMNeT++
1
Create a new OMNeT++ project and add all files above.
2
Compile packets.msg first — it auto-generates nl_pkt_m.h and dll_pkt_m.h.
3
Build the project and run with omnetpp.ini.
4
Open the Event Log to see packet flow, ACKs, timeouts, and retransmissions.
Source Code
NED nldll.ned
simple Nl_node
{
    parameters:
        int nl_id;
        int remaining_packets;
        int source;

    gates:
        input  nl_in;
        output nl_out;
}

simple Dll_node
{
    parameters:
        int dll_id;

    gates:
        input  dlln_in;
        output dlln_out;
        input  dllc_in;
        output dllc_out;
}

module Comp
{
    parameters:
        int c_id;

    gates:
        input  c_in;
        output c_out;

    submodules:
        Nl:  Nl_node  { nl_id  = c_id; }
        Dll: Dll_node { dll_id = c_id; }

    connections:
        Nl.nl_in   <-- Dll.dlln_out;
        Nl.nl_out  --> Dll.dlln_in;
        Dll.dllc_in  <-- c_in;
        Dll.dllc_out --> c_out;
}

network Comp_network
{
    parameters:
        int source;
        int dest;

    submodules:
        C1: Comp { c_id = 1; }
        C2: Comp { c_id = 2; }

    connections:
        C1.c_out --> { delay = 100ms; } --> C2.c_in;
        C2.c_out --> { delay = 100ms; } --> C1.c_in;
}

No comments:

Powered by Blogger.