- How do we initialize the packet? What if we didn't initialize packet, what will happened?
- How do we deallocate a packet?
- What is the purpose of having packet header, and who is responsible for configuring the packet header?
- What is the actual data type of enum?
- Who is responsible for packet construction?
- What are two main parts of protocol specific header?
4 comments:
(Hasanain/106000)
1) In packet allocation we use the function alloc() which follows two steps (a) allocation (b) initialization (which is done using the function init(p) to clear the space in bits_
2) we deallocate the packet by using function free().
3) Some time we do not need to send the entire packet and only need to tell the packet length and Bit error rate, so in these cases we only send the header which contain these information and no need to send the payload.
4) Actually packet is allocated from the free packet list so if the packet is not available in the list, then we create a new one using the command (e.g. “p=new Packet;”)
5) 1st is the composition of PSH and 2nd is the c++ struct data type containing PSH
1. How do we initialize the packet? What if we didn't initialize packet, what will happened?
-In function alloc() : we call function init(p) to clear bits_ to zero, sets fflag_ tobe true to indicating that the packet is now use in, sets the pointer p->next to be zero and initialize the common header.
-If we didn't initialize packet, the packet is cann't work.
2. How do we deallocate a packet?
-We call function free(p) to free the packet.
3. What is the purpose of having packet header, and who is responsible for configuring the packet header?
-to contains packet attributes such as packet unique ID and IP address and
Agent is responsible for configuring the packet header.
4. What is the actual data type of enum?
-The actual data type of enum is integer but is map to string.
5. Who is responsible for packet construction?
-Agent is responsible for packet construction.
6. What are two main parts of protocol specific header?
-First,C++ class to struct data type and store packet info.Second, Mapping class to map C++ class to OTcl interface.
Ans:1) We initialize the packet as :
init(p); // Initialize bits_[]
(HDR_CMN(p))->next_hop_ = -2; // -1 reserved for IP_BROADCAST
(HDR_CMN(p))->last_hop_ = -2; // -1 reserved for IP_BROADCAST
p->fflag_ = TRUE;
(HDR_CMN(p))->direction() = hdr_cmn::DOWN;
/* setting all direction of pkts to be downstream as default;
until channel changes it to +1 (upstream) */
p->next_ = 0;
return (p);
2)When a packet *p is no longer in use, NS2 deallocates the packet by using function free(p).
3)The purpose of having a packet header is to contains all packet attributes such as packet
unique ID, and IP address, control flags , error flags etc. An OTcl class (e.g., PacketHeader/Common or PacketHeader/IP): acts
as an interface to the OTcl domain. NS2 uses this class to configure packet header from the OTcl domain.
4) NS2 stores a packet type in a member variable ptype_ of a common
packet header. The type of the variable ptype_ is enum packet_t, the members of enum are integers which are mapped to strings.
5) Packet are created by an Agent and function allocpkt() is the main packet construction function. It creates a packet by invoking function alloc() of class Packet.
6)COMMON HEADER and IP HEADER are the two main part of the protocol specific header.
-A C++ class (e.g., hdr_cmn or hdr_ip): provides a sturcture to store packet attributes.
– An OTcl class (e.g.,PacketHeader/Common or PacketHeader/IP): acts as an interface to the OTcl domain. NS2 uses this class to configure
packet header from the OTcl domain.
– A mapping class (e.g.,CommonHeaderClass or IPHeaderClass): binds
a C++ class to an OTcl class.
Thein Tun Aung/st108032
An Angent object creates and initializes a packet
using its function allocpkt().
(or)a packet is created using function alloc() of class Packet,and initialized
using function initpkt(p) of class Agent.
If we didn't initialize packet, it can not assign default values to packet attributes such as packet unique ID, packet type,and packet size.
NS2 deallocates the packet by using function free(p).
The purpose of having packet header is to stores packet attributes.
OTcl class PacketHeaderManager is responsible for configuring the packet header.
Members of enum are integers which are mapped to strings.
To setup variable offset_ of all active protocol is responsible for packet construction.
Two main parts of protocol specific header are Common Header and IP Header.
Post a Comment