We write custom essays and can help you with

The essay examples we publish have been submitted to us by students. The essays are the student's work and are not examples of our expert essay writers' work. READ MORE


See how we can help

We write essays!

overview of ns-network simulator project

3 OVERVIEW OF ns-NETWORK SIMULATOR

The ns-Network simulator is selected as the backbone of this project and also has the feature that it has open source code that can be changed according to the requirements. The ns-Network simulator has the following features.

Traffic generators – CBR, Exponential and Pareto.

Transport protocols-TCP, UDP.

Applications-Web cache.

Elements for network topology-Point to point links and nodes.

Routing—Hierarchical, unicast, multicast.

Queuing design-SFQ, FQ, drop-tail, CBQ, RED.

Basic mobility-mobile IP, ad hoc networks

The simulation outline is described by using OTCL; it is programming approach using a split language.

OTCL describes configuration of components and arranging events during the time of simulation. The processing code per packet that is the actual core of the simulator is written is c++.But this outline is used for fast generation and scenarios of large.OTCL is just sufficient to use the simulator but to expand the simulator both the languages are required.

3.1 OUTLINE OF THE NETWORK SIMULATIONS

The outline of the simulation in TCL scripts Network simulator is done as follows

For the simulator configuration set the options.

Form a simulator instance.

Setup the Traffic.

Arrange changes during the simulation.

Trace the events.

The strategy of queuing, delay and certain bandwidth is linked to the network nodes of the topology. The diagram of node is shown in figure 3.1.The agents must be attached to the nodes in order to exchange the packets between nodes. Agents can be two types one is sending and receiving agents and another one can be routing agents for UDP or TCP Packets. The given below is a sample script:

# using dynamic routing; usingarrays to create nodes.

Set ns [new Simulator]

$ns rtproto DV

Set nf [open out.nam w]

$ns namtrace-all $nf

#this closes the trace file and starts nam

Proc finish {} {

global ns nf

$ns flush-trace

Close $nf

exec nam out.nam &

exit 0

}

#creating 7 nodes usingan array.

for {set i 0} {$i<7} {incr i} {

set n($i) [$ns node]

}

#linking each node to the next node with a 1Mbps link,

# 10ms delay, and Drop Tail at the queue to the link.

For {set i 0} {$i<7} {incr i} {

$ns duplex-link $n($i) $n([expr ($i+1)%7]) 1Mb 10ms DropTail

}

#starting CBR traffic, with packet size 500 bytes

# at intervals 0.005 s.

set cbr0 [new Agent/CBR]

$ns attach-agent $n(0) $cbr0

$cbr0 set packet size- 500

$cbr0 set interval_ 0.005

#creating a sink

Set null0 [new Agent/Null]

$ns attach-agent $n(3) $null0

# now to connect the two agents!

$ns connect $cbr0 $null0

# now tell cbr0 when to start sending packets (and till when)

$ns at 0.5 "$cbr0 start"

$ns rtmodel-at 1.0 down $n(1) $n(2)

$ns rtmodel-at 2.0 up $n(1) $n(2)

$ns at 4.5 "$cbr0 stop"

# note: write the times in order

#call the procedure "finish" to close the trace files.

$ns at 5.0 "finish"

# Start the simulation!

$ ns run

3.2 LAYERS OF NETOWORK ON AN NETWORK SIMULATOR WIRELESS NODES

The network layers are described below

Link Layer (LL). The data link layer protocols are simulated in this layer. The Mac header of the packet contains Mac destination address that is performed by Link layer. The packets passes down and up from Mac in the LL.The IP address are resolved to hardware address by connecting ARP module to LL.

Address Resolution Protocol (ARP)

ARP is written in to Mac header of the packet if it has got the Mac address of the destination .If it has got no address of the destination then caches the packet temporarily. There is only space for single packet for each unknown destination address and the buffer space is overwritten if any packets come for the same direction.

INTERFACE QUEUE (IFQ)

This queue gives priority to the packets of routing protocols by placing them at the head of the queue so this is implemented as a priority queue. For the certain destination it can also selectively remove the packets.

MEDIUM ACCESS CONTROL (Mac) LAYER

IEEE 802.11, IEEE 802.3 are currently implemented in Network simulator and also multi hop, CSMA.

NETWORK INTERFACE (net if)

To approach the channel the mobile node uses the Network Interface. To receive packets via the radio propagation model and for collisions this interface is placed. The interface like wavelength, transmit power and all data related interfaced are kept in to the header of the packet. Whether the packet has got the enough power to receive is known by the information in the header packet.

RADIO PROPAGATION.

For the outline of wireless a sample OTCL script is shown below

# define options

Set Val (Chan) channel/Wireless channel

Set Val (prop) Propagation /Two ray ground

Set Val (net if) phy/Wirelessphy

Set Val (Mac) Mac/802-11

Set Val (ifq) Queue/Drop Tail/PriQueue

Set Val (ll) LL

Set Val (ant) Antenna/Omni Antenna

Set Val (X) 670; # dimension of the topography

Set Val (Y) 670; # dimension of the topography

Set Val (ifqlen) 50 ; # max packet in ifq

Set Val (Seed) 0.0

Set Val (adhocrouting) DSR

Set Val (nn) 3 ; # how many nodes are simulated

Set Val (Cp) !!../scene/cbr-3-test”; # traffic patterns

Set Val (Sc) !!./scene/scen-3-test” ; #movement patterns

Set Val (Stop) 400.0 ; Simulation time

# create simulator instance

Set ns-[new simulator]

# Setup topography object

Set topo [new Topography]

#create trace object for ns

Set tracefd [open~/wireless.tr w]

$ns-trace-all $tracefd

#define topology

$topo load-flatgrid $Val(x) $Val(y)

#create God

Set god_[create-god $val (nn)]

#define node setting

$ns_node-config-adhocrouting $Val (adhocrouting) \

-lltype $Val (ll) \

-macType $Val (mac) \

-ifqType $Val(ifq) \

-ifqLen $Val(ifqlen) \

-antType$Val(ant) \

-PropType $Val(Prop) \

-phyType $Val(netif) \

-channel Type $Val(chan) \

-topoInstance $topo \

-agentTrace OFF \

-routerTrace OFF \

-macTrace ON

# create the specified number of nodes [$Val (nn)] and

# “attach” them to the channel.

For {set i o} {$i < $Val (nn) } {incr i} {

Set node_($i) [$ns_node]

}

# Define node movement model

Puts “Loading connection Pattern…”

Source $Val (cp)

# define traffic model

Puts “Loading scenario file…”

Source $Val (sc)

#Tell nodes when the simulation ends

For {Set i o } { $i <$Val (nn) } {incr i} {

$ns_at $Val(Stop).0 “$node_($i) reset”;

}

$ns_at $Val(stop).0002 “Puts \NS EXITING …\ ; $ns_halt”

$ns_run.

3.3 OUTLINE OF WIRELESS- CUM- WIRED

In wired node the mobile station is attached to the base station to communicate to a fixed node. In ns –Network simulator the base station is implemented as mobile station with motion disabled and routing switched on. This is done at OTCL level ns/tcl/lib/ns-bsnode.tcl.The wired and wireless parts kept in different domains must use hierarchical routing. The mobile nodes require base station to communicate with a wired node. But mobile node can communicate themselves.

3.4 NON –ADHOC ROUTING AGENT (NOAH)

In General packet radio service (GPRS) the Mobile Station (M S) will not communicate with any Mobile Station but only communicate with Base Station (B S).The normal ad-hoc provided by the network simulator cannot be implemented .so the ad-hoc routing protocol designed by joerg widmer was used. The transmitting and receiving of the packets from a mobile node through its Base Station is routed by NOAH. The ns-Network simulator hierarchical routing is need inherently. So this points that in wireless scenarios also NOAH is used.

4 EXPANDING GPRS SIMULATIONS IN NETWORK SIMULATOR

The important factors to be focused are Medium Access Control (MAC),Radio Link Layer(RLC),Mobile Station(MS),Base Station(BS) and on the simulations of the Link Layer(LL).So recollecting all the basics of the General Packet Radio Service (GPRS).The below described are the features of the implemented simulator.

4.1 AIM OF THE SIMULATOR

Here using Hierarchical routing to simulate GPRS scenario i.e. wired nodes are interfaced with Base Station (BS).So a single cell operation is allowed here. The implementation of Hands-offs, Home Location Register (HLR),Visitor Location Register (VLR) are not supported because all these factors come under multi cell operation that is beyond the aim of our simulator. The direction of the traffic can be put in either from Base Station to Mobile Station or Mobile Station to Base Station. The user can vary the number of available frequencies in a cell by using OTCL script. By using the OTCL script the user can also vary the maximum number of mobile nodes permitted in the cell. There are 2 kinds of mobile nodes that can be arranged , the first one is Global System for Mobile communication Mobile Station (GSM MS) and the second is General Packet Radio Service Mobile Station (GPRS MS).The GSM MS continue to hold the slots till the end of call, while GPRS MS release slots when there no packet transfer. Only one frequency can be transmitted or received at time by each Mobile Station (MS).But Base Station (BS) can transmit and receive many frequencies at a time. So to obtain these the MAC, LL and RLC layers are implemented with following features.

Medium Access Control: It has eight time slots each on TDMA frames and the downlink and uplink frequencies are separated. The allocation of uplink and downlink are symmetric.

Link Layer: The Power Distribution Units are rearranged and fragmented i.e. wait and stop retransmit mechanism.

Radio Link Layer: Here it is a selective retransmit mechanism i.e. rearrangement of Link Layer Power Distribution Units.

4.2 CHANGES MADE TO NETWORK SIMULATOR

In the node structure the Radio control Layer is introduced as shown in figure.

4.2.1 CHANGES in Link Layer (L L)

The Link Layer provided by the Network Simulator has been modified to include fragmentation modes as options. Arranging the OTCL script the Link Layer can be implemented in two ways i.e. fragmented mode or unregimented mode. The packets received from the sending agent are partitioned before passing to the Radio control Layer and are rearranged at the other side in fragmentation mode. The size of the fragment can be varied by the user. In accordance with the maximum Link Layer PDU size specified in General Packet Radio Service it is currently set at a default of 1500 bytes. There are two modes that the Link Layer can be used, one is unacked mode and another is acked mode. The header of the Link Layer has been changed to adjust these changes. Ns/ll.{cc.h}.The retransmits mechanism of stop and wait is implemented.

4.2.2 CHANGES IN RADIO LINK LAYER

The mechanism in Radio Link Layer is a form of selective Retransmits. The Fragmentation and rearranging along with Radio Control Layers is included here. The Partitions and rearrangements can be set on or off. The Radio control Layer that is a new header is introduced. Ns/rlc. {cc.h}.The size of Radio control Layer fragments can be set. In acknowledged mode a Radio control Layer is dropped by Medium Access Control that is a duplicate acknowledgment for the previous received Radio Control Layer fragment is sent back to the sender and then retransmits the expected Radio Control Layer fragment. In unacknowledged mode the Radio Control Layer will not pass any fragments to Link Layer (LL), if a Radio control Layer is missing. In this case the Link Layer will let the higher Layers handle it or it would resend the Link Layer PDU. The coding scheme used will set the original size of a Radio Control Layer PDU’s payload. The average General Packet Radio Service Radio Control Layer size is set to be 200 bytes. These 200 bytes are transmitted over 4 slots in successive TDMS frames in General Packet Radio Service (GPRS).That is totaling fifty bytes per slot. To achieve this in our simulator I arrange Radio Control Layer to be 50 bytes i.e. transmitting fifty bytes in each Time Division Multiple Access slot.

4.2.3 CHANGES IN MEDIUM CONTROL ACCESS

In this one Radio Control layer fragment is transmitted per slot. The Medium Control Access is same as reservation based slotting. For signaling and broadcasting the slot 0on the both uplink and down link is reserved. A number of slots for General Packet Radio Service can be set by the user and the rest are left for Global System for Mobile communications. The Base Station randomly drops packets or marks them as deviated by a method called random error. The implementation of Medium Control Access and its details are described in the upcoming chapter. Ns/mac-gprs.{cc.h}.

5 IMPLEMENTATION OF MEDIUM ACCESS CONTROL AND ITS DETAILS

The description of the Time division Multiple Access (TDMA), the basic channel, packet transmission modeling, call handling, slot handling are explained in this chapter, that gives the overview of how I have implemented the Medium Access Control (MAC).And also the expectations like errors and collisions on the channel are also explained in this chapter. Ns/mac-gprs.{cc.h} is the relevant code in our work. In Appendix 2 the psuedocode for the implementation is given.

5.1 SLOT STRUCTURETIME DIVISION MULTIPLE ACCESS (TDMA)

Each frame has eight slots in Time division Multiple Access (TDMA). The duration of each slot is set as 577 microseconds. We transmit one Radio control Layer PDU i.e. 50 bytes in each slot. This changes the transmission of 1 General Packet Radio Service (GPRS) over 4 slots in continues frames. The time of the transmission packet is taken as packet –size/transmission –rate for packets smaller than the size of a Radio Control Layer PDU. To start and end of each slot on the uplink and downlink we use up-slots-gprs-timer and down-slot-gprs-timer and the handling of the process is done by up slot handler and down slot handler.

5.2 CHANNELS

The provided physical air interface by network simulator is used here. By using OTCL script (max-num-freq) the maximum number of frequency channels can be created for the uplink and downlink by the user. Creating separate timer to clock the Time Division Multiple Access (TDMA) frames we can separate the uplink and downlink channels. The uplink and downlink Time Division Multiple Access are always maintained by three time slots. Slot 0 is reserved for broadcasting and transmission on both uplink and downlink channels. The OTCL script can let the user to decide the number of slots to be reserved for General Packet Radio Service (GPRS) traffic on each frequency through gprs-slots-per-frame and the remaining slots are left for Global System for Mobile communications.

5.3 TIMING

At the Mobile Station (MS) and Base Station (BS) the up slot and down slot should be synchronized. But the Mobile Station (MS) and Base Station (BS) makes mismatching by the finite propagation delay. So at the Mobile Station the clock have to be advanced by the finite propagation delay to maintain the synchronism. By setting the propagation delay to 0 (in ns/wirelessphy.cc) we can work away from complexity in our simulator.

5.4 TRANSMISSION & RECEPTION OF THE PACKET

We keep timer for the transmission and reception of the packet over the air interface to keep the track of signals when transmission is over and how long the transmission should take place. At the beginning of the slot the packet transmit timer is started by tx-onto-PHY. The send handler is called, frees the packet, switch off the radio, and unlocks the IFQ when the transmit timer is expired. If a portion of packet has to send to air interface by the Mobile Station or Base station then it calls rx-from-phy. This changes the actual radio reception and also checks for collisions by starting the receive timer (RxpktGprs timer).The recv handler is called and checks whether the packet is error or it can be received and send it for processing and later forwarded to the Radio Control Layer when the receive timer is expired. Transmit and receive timer are start and end together as we take propagation delay to be zero.

5.5 SETTING AND HANDLING OF THE CALL

The messages used below are used for setting and handling of the call.

5.5.1 REQUEST OF THE RESOURCE

When the Mobile Station’s first packet is received by the Medium Control Access (MAC) , it triggers a resource request message to the Base Station (BS).To prevent it from sending down to further packets we buffer and prevent the IFQ.To keep the track of the time a wait timer is set up. To slot zero and on uplink frequency zero the resource –request message is transmitted.

5.5.2 RESOURCE REPLY

The receipt of resource request from the Mobile Station or the packet from its own IFQ for the Mobile Station, the Base Station allots a slot frequency or channel to a Mobile Station. The Medium Control Access (MAC) header of the resource reply is filled with the information about the slot frequency. To the suitable Mobile Station it is transmitted on slot zero of downlink frequency zero. The Mobile Station checks the suitable channel to it and stores it in tx-chan [] and rx-chan [] for the reference in the future. The old buffered packet is transmitted on to the suitable channel and unblocks the IFQ by ignoring the wait timer. So that the other waiting packets are transferred down from the IFQ to the Medium Access Control and transmitted. If the Base Station has a second resource reply that have to be transferred in slot zero of the upcoming frame then the second resource_reply message is stored in a temporary buffer and transmitted in the next Time Division Multiple Access frame with slot zero free.

5.5.3 RELEASE OF RESOURCE

We have to introduce slot release mechanism for General packet Radio Service (GPRS) due to burst internet traffic. When the Mobile Station holds a channel and then if no packet is received or transferred for four Time Division Multiple Access (TDMA) frames and if the IFQ of the Mobile Station is empty then we have to initiate a resource –release. The Mobile Station sends a resource release by clearing its tx-chan [] and rx-chan entries. The Base Station removes it vlr-up-table and vlr-down-table entries by receiving the resource release. The resource-release can only be initiated by Mobile Station. We can send another resource reply if the Mobile Station (MS) if the Mobile Station needs to restart transmission. This is done on same position with any other new request by the Base Station. The Base Station will distribute new resources to the Mobile Station and transmits a resource reply informing the Mobile Station in the situation of traffic from Base Station to the Mobile Station.

5.6 HANDLING OF THE SLOT

5.6.1 SLOT ALLOCATION

At the Base Station (BS), which Mobile Station (MS) has to be given to which UP slot or down slot is all recorded in a Table (in vlr-,specifically, vlr-upslot[][] and vlr-downslot[][]).The Base Station (BS) allots the first free slot to Mobile Station, when it receives a resource-request from an Mobile station or from its own IFQ. All these done in slot-allot (). If the slot is a Global System for Mobile communications (GSM) Mo bile Station (MS) then a slot is provided from the pool of GSM slots or else if it is General Packet Radio Service (GPRS) MS then a slot is provided from the pool of General Packet Radio Service (GPRS) slots. For GPRS by default, a Mobile Station (MS) is General Packet Radio Service (GPRS) and four slots on each frequency are reserved. For the Uplink and down link frequencies the allocation is symmetric. Here each Mobile Station (MS) is allotted by only one slot i.e only single slot operation is supported.

5.6.2 RELEASE OF SLOTS

General Packet Radio Service (GPRS) mobile nodes can only make possible for release of slots. Here a release timer (slot re-release timer) is maintained at the Mobile Station. The Mobile Station checks the IFQ and if the IFQ is empty after receiving the packet then it starts the slot release timer. If the four Time Division Multiple Access (TDMA) receives another packet from Mobile Station then the timer is reset or else the release handler () is called on the expiry of the timer. For the four Time Division Multiple Access (TDMA) frames, the valve for the release timer is currently based on the performance of the simulations. According to traffic generation pattern the optimal valve may changes and has to be further explored.

5.7 DEALING WITH COLLISIONS

The area the collisions can occur is during the Packet random Access channel when more than one Mobile Station sends a request at the same time, as this is based on reservation slotting system. The information of the PRACH is maintained by using chan0-0.The colliding resource request packets are dropped by rx-from-phy () at the Base Station during the time of collision. When no reply is received the Mobile Station waits on Time Division Multiple Access frames for a reply. The back off timer is set for random intervals by the Mobile Station (MS) (random: integer (k)) and calls back off handler () on expiry.

5.8 ERROR MODEL

The Network Simulator may cause errors in to packets generated by agents like TCP or UDP, but at the lower layers it cannot bring errors. A error model that brings errors in simulated PDUs is introduced to test the acknowledgement mechanism. A randomly chosen Radio Control Layer fragment is marked by the error model (in-bs-recv ()) and makes the packet to be dropped at the destination. We use random integer (error-rate) at each drop and also for the next drop. In the OTCL script the user may add this error model through rlc error. And the user can also set the error-rate from the OTCL script.

5.9 ARPS

Arp request is nothing but the first packet received at the Medium Access Control (MAC) of a Mobile Station at the start of the simulation. To prevent other Mobile Station (MS) from receiving an ARP request from a Mobile Station (MS) it it not transmitted directly even though it is a broadcast message, the ARP request is sent out only on the provided slot frequency channel. The ARP requests are broadcasted on the broadcast channel by the Base Station initially. ARP request is sent by Network simulator nodes, a packet is received at the Link Layer each time. It waits for a reply even though an ARP request is sent. We use duplicate ARPs in ms recv (), in order to avoid wasting radio resources and also to protect Multiple Access Control from transmitting such duplicate ARP requests.

5.10 OVERVIEW OF MULTIPLE ACCESS CONTROL CODING

The methods, timers used, storage structures and elements of the code are described below.

5.10.1 DIFFERENT METHODS OF MULTIPLE ACCESS CONTROL

The methods for Multiple Access Control /GPRS are

Recv (packet *p, handler *h) : For the MAC it is the entry point

Ms recv (Packet *p, Handler *h) : At the MS packet processing

bs recv (Packet *p, Handler *h) : At the BS packet processing

slot allot(int ms , int &freq, int &slot) : allot a slot to ms , return Values through &freq, &slot

Send res reply (int dst, int freq, int slot) : creating a resource reply

Packet, to be sent on slot/freq

Send res request () : creating a resource reply packet

Send let go() : creating a resource release packet

Down slot Handler(Event *e) : actions at the end of every down slot

UpslotHandler (Event *e) : actions at the end of every up slot

Send Handler (Event *e) : actions after packet has been transmitted

RecvHandler (Event *e) : actions after packet has been completely received.

Release Handler (void) : on the expiry of the slot release timer

BackoffHandler (void) : on the expiry of the back off timer

Wait Handler (void) : on the expiry of the wait timer

Radio Switch (int i) : switching the radio on/off to conserve energy.

Rx from phy(Packet* p) : remove MAC headers, check for collisions

rx from ll(Packet* p) : add MAC header

Fwd DATA to LL(Packet *p) : handle data according to type and pass to Upper layer.

TX onto PHY (Packet *p) : transmit onto air interface.

5.10.2 DIFFERENT TYPE OF TIMERS USED IN MAC

The following are the different types of timers used.

Wait timer: It is the amount of time to wait for a resource reply.

Back off timer: It is the time to back off for random intervals before retransmitting a resource request.

Up slot timer: It is the timer to clock slots on the uplink frequencies.

Down slot timer: It is the timer to clock slots on the downlink frequencies.

Packet receive timer: It is the timer that keeps track while the packets being received.

Packet transmit timer: It is the timer that times the transmission of a packet.

5.10.3 STRUCTURES OF STORAGE

The different types of storage structures are described below.

At the MS

Packet *pktTx[i]: pointer to the packet to be sent in Up slot i

Packet *pktRx[i]: pointer to the packet received in down slot i

Int tx Chan[i]: which channel should the MS transmit on in Up slot i

Int rx chan[i]: which channel should the MS listen to in Down slot i

Note: tx chan [0]= 0 for Random Access

rx chan[0]=0 for Broadcasts and other messages from BS

This structure also allows for multi-slot allocation to be included later.

At the BS

Packet *txQ[i][j]: pointer to the packet to be sent in Down slot j, frequency i

Packet *rxQ[i][j]: pointer to the packet received in Up slot j, frequency i

int vlr .hier add [i]: hierarchical address of MS with MAC index i

Int vlr .up table[i][j]: MAC index of MS allotted Upslot j on frequency i

int vlr .down table[i][j]: MAC index of MS allotted Down slot j on frequency i

Note: These structures have to be unique for each BS. Since

Ns

does not currently have

a separate BS node at the C++ level (

Ns

congures a node as BS only at the OTcl level),These structures had to be made static. This limits our simulator to supporting just one BS and consequently, just one cell

Need an essay? You can buy essay help from us today!







Request the removal of this essay.

Find out how UKEssays.com can help you with your Essays

Get help with your essay

Sign up and be the first to receive our latest offers: