 Welcome back, so first I will get into the details of today's lab which is based on this network simulator 2. In fact, there is NS3 which is where people are migrating to, but since I am more familiar with NS2 I have used this here by all means welcome to use NS3 as well it has a slightly different interface, but conceptually both simulate various protocols you can use either of them for learning purposes. So getting into today's exercise, you have been provided certain sample scripts nstcp.tickle nstcp.tickle tcl we call it tickle and the first exercise is about going through the scripts understanding how the scripts work by looking at the code as well as running them and then answering some questions based on your understanding of the script as well as experimenting with the script basically running it. You could also see the action in this network animator that comes with NS2. So that is the first portion of the lab by the way there is a video that talks about the network simulator there is also slides associated with NS2 that have been shared in the Google drive. If you want to refresh NS2 please go through this material before you start the lab. So this is the terminal which has the scripts that I have shared with you ns simple.tcl and nstickle.tcl so let us just run one of these. So this is the way you use NS you just say ns ns.tcp.tickle in which case it ran the particular code we can also see what is inside it briefly. So basically this is how the tickle how you write the code in tickle you are basically opening some trace file once the simulation ends you are defining a procedure that specifies what to do once the simulation ends you are creating nodes. So typically any network simulation involves a topology. So in this topology there are 3 nodes n0 n1 n2 you are creating links between the nodes you are specifying how to orient this is mostly for graphical visualization for NAM otherwise it is not necessary for the simulator you are monitoring the queue and you are setting up TCP connections and you are feeding the TCP connections through some application layer protocol like FTP and you are also specifying when you should start and stop the simulation. It is a very simple script you can go through it in detail as you explore it in the lab. So if you do this ns it basically runs it so once it exited what you will see as a result of it is it has produced this NAM out.NAM which is what feeds into the network animator since you could run NAM out.NAM but right now since I am assessing SS hatching into my Linux machine this will not work but locally it will work for you and you could also see the trace file that the ns has produced called TCP.TR. So this says what happened during the simulation. The format for this you can see in the slides that I have shared with you what does plus mean what does R mean what does so here if you see there is a plus here there is an R here there is a minus what do these things mean I will let you explore them. So as you can see these are all packets that are being sent some are TCP packets some are acknowledgments there are destination sources everything is for you to figure out. So whenever you run a simulation naturally some results that such a trace file is produced and you want to go through the trace file and collect some statistics the way things are set up in the lab is I am asking you to collect some very simple statistics through the use of grep pipe word count. So let me demonstrate one very simple thing. So in this trace file which is TCP.TR as you can see lot of packets have been transmitted you will see that some packets represented by D are the dropped packets. Now suppose you want to figure out how many are the dropped packets in this simulation. So a simple way to do this is grep. So what I have typed is grep this it is called carrot D or it is the hat D what this is basically telling is print out all the lines that start with a D that is what this is telling within this particular file. So when I executed it printed out all the lines that start with a D. Now it is if you want to now figure out how many of these are there this is pipe, pipe means the output of this file you pass to this particular command W c is a command which stands for word count minus L specifies that count the number of lines in the file and pipe is basically passing the output of this grep which is this thing that you see to W count minus L. So when you do this all you get is a single number basically that has 17 drops. So this is how you can collect some statistics based on the traces you can do some things even more sophisticated I will leave it all for you as part of the lab. So the first exercise is just a warm up that will let you explore this very two simple scripts and answer some questions based on what you have seen when you go through the code as well as when you run them. So that is the first part of the exercise. So there are a few kind of I would not say they are very difficult but it is asked you to calculate the throughput at the receiver of the two flows. So let me emphasize what I mean by throughput. So when you are measuring something at a destination let us say you started at time t 1 and there is time t 2. So this is the receiver let us say at time t 1 it is when it received the first packet and it received let us say the 100th packet in time t 2. So between t 1 and t 2 it has received 100 packets. So t 2 minus t 1 is the time let me call it t seconds, within t seconds it has received 100 packets. So throughput will be 100 into whatever is the packet size this could be in bytes in which case you multiply it with 8 to convert into bits. So these many bits were received in t seconds. So that is the throughput at the receiver. So this is what I was asking you to calculate. So the second exercise is involving this topology. So you have to create a tickle file based on you can use the ns simple.tcl as well as ns tcp.tcl the one file that I have provided for you in exercise 1 as reference to create this particular topology. I mean it is very straight forward there is nothing complicated there just look at it look at some of the commands and reproduce it to create this particular topology. So in this topology there is a source there is a router and destination and they are involving two links. This link 1 has a bandwidth of 1 mbps with 50 milliseconds latency whereas link 2 has much lower bandwidth of only 100 kbps and 5 milliseconds. So what you are going to do in this exercise is you are going to send data at a rate that is going to congest this link 2. So as you can see it has only 100 kbps but you will try to send data at twice the rate or whatever is specified. So here the values are 40 kbps is less than 100 kbps that means you are not congesting it 80 kbps is also less than 100 kbps you are not congesting it. But 120 kbps and 160 kbps is greater than 100 kbps thereby you are going to congest the link. So as you push more and so each is a different experiment. In each experiment you are going to set. So basically with since I have specified 4 data rates you are basically going to run 4 different experiments. In each experiment you have to vary the rate in this particular fashion. The first experiment you will set it to 40 kbps, second experiment you will set it to 80 kbps, third experiment 120, fourth experiment 160 kbps. And in each experiment you are going to see what is going to happen. I mean what are the losses that you are going to see, what is the throughput that you are going to get. So these are the two main metrics you are going to measure. So offered load so let me get into a little bit details of what you are measuring. So offered load is the rate at which source is injecting into the network. This is what you are setting in the tickle script. How do you set it again once you go through the script you will understand. But just after you set it you do confirm in the trace as well that you need your injecting traffic at the rate of 40 kbps or 120 kbps or 160 kbps as specified. Now when you are congesting a link naturally you will expect losses. So you need to measure how many packets have been dropped that is the packet loss measurement. Similarly you also have to measure what is the throughput that you are getting when you are congesting or not congesting the network. So this throughput calculation is similar as above. So this is what you need to measure and typically whenever you use a simulator it is always good to plot certain data. So you are measuring offered load packet losses, you are measuring throughput and it is a good practice to also learn how to graph these results. So for that you are required to plot two graphs one is the offered load versus percentage packet loss. Another is offered load versus throughput. So let me again explain a little bit about it. So you have run basically experiment one where you used 40 kbps which is your offered load and let us say you experienced x1 number of losses. In your experiment two you have injected 80 kbps and you saw x2 number of losses. In your experiment three you did 120 kbps and you saw x3 number of losses and in experiment four it is 160 kbps and you saw x4 number of losses. By the way one thing I wish to emphasize is this is percentage loss that means if you have sent let us say overall t number of packets and L were lost this is L over t. It is not for example if in one experiment you send 100 packets and 20 got lost in other experiment you send 1000 packets and 20 got lost it is not that the loss rate is the same in both the cases. In this case the loss rate is much less than in the first case. So what you have to plot here is the percentage loss that is what is more relevant not the total number of packets lost because that is a function of how many packets you have actually sent. So ensure that you are measuring percentage of loss. So when you have these experiments four experiments and this is the data that you got out of the experiment when you are plotting this is basically what you are doing. So this is the x axis it will have these values 40, 80, 120, 160 and these are the values of x1, x2, x3 and whatever x4. So you may have I am randomly drawing something like this corresponding to the four points and you have to plot something like this. So this is what I expect you to plot. Now in order to plot you are free to choose whatever plotting tool you are comfortable with you can use open office which is the equivalent of excel there is something if you are familiar with windows you can plot graphs in excel there is something very similar in open office called xcalc you could use that to plot the figures. I have also GNU plot is something which we use a lot I have provided a sample script for you to use GNU plot as part of the lab files you can go through it it is kind of again a straight forward thing I am not very sure whether GNU plot is installed on your lab machines you have to confirm that if it is installed you could use GNU plot you could use whatever tool you are comfortable with and which is available at your remote center but finally I want you to plot excel is something which will very likely be there you are always free to use that. For those who are interested in doing something more there is some additional work for you but this is a little bit more complicated in that it will involve some amount of bash scripting or using C code you cannot really do it with just grep pipe and w count commands like you have done the earlier exercises so you are free to attempt this we have we will provide solutions at the end as to how to use this commands it may appear so this lab may be slightly more difficult than the other labs. But if you think carefully and just be very clear on what is it that you want to measure what are the filters you have to use for grep you can easily calculate whatever it is you want based on just grep the pipe and the word count so that is in fact a hint for you to it involves nothing more sophisticated or complicated except for exercise 3 which is an optional exercise time permitting you can do or you can do it later as well yeah. So this is with respect to the lab I can take some questions specific to the lab for the next 20 minutes. Madam I have a question whatever the trace file we are getting it in the NS2 can we analyze the trace file in the wire shot? No this is totally NS2 based trace file this is nothing to do with wire shot wire shark expects the packets to have a certain format it has it is a kernel based that p cap is what it expects them to be no this cannot be used as part of wire shark wire shark is more an implementation thing this is a simulation thing. I have one more question how do we introduce a loss monitor in the NS2? It is there in the sample script that I have given. I will look into that. Then we had done preshoot to www.google.com we got a successful response but when we tried to see the ICMP records and with lab packets in wire shark we could not see them we got only the ICMP message as host and disable why is it changed? I do not know the setup but it is very likely that maybe you are going through a proxy so when you are using wget if you are going through a proxy you need to specify the proxy settings or whatever. So if the browser has the proxy settings within it but if wget does not have it you are not using a proxy I mean if you are able to ping www.google.com at a terminal if you are not able to ping then very likely if ping works then wget should also very likely work but if ping itself is not working that means somehow you are maybe you are going through a proxy which you are not aware of so maybe that you have to understand how your network is set up there. For preshoot to www.google.com we are not getting ICMP request and reply messages in the wire shark window. Yeah that is quite obvious because some router on the way to Google is dropping your ICMP request and on end is not replying back that is very common I mean any router not all routers are going to reply back because it is a load for them some good routers or nice routers reply most routers do not reply so you will not see in wire shark those messages because the router is just dropping the packet and is not even sending ICMP reply that is why you will not see. Okay thank you. And does NS2 supports all different kinds of protocols or is there any restriction that certain kinds of protocols are allowed? So NS2 is a community effort where most of the basic protocols are there as part of NS2 in fact it has a whole lot of protocols but again it is a community effort if you are working on some very recent protocol which you may not find it as part of NS2 but that is it NS2 has quite a lot of protocols some protocols it may not have but often the way it works is if there is no protocol that is there some research group works on it develops modules for it and shares it with the community so that is how NS2 works it is a community effort it does have a fairly large number of protocols. Thank you. One to two nine regarding yesterday's lab I am having one question that is when we are trying to bring to a machine which is existing in nature okay that time what we had found is type 3 and code 3 is set even though the machine is there the machine is working absolutely fine so actually we are understood how it is because if the machine is off then it is okay or if the machine is working but still we are getting that type 3 and code 3 black set in Vaikshar. Let me clarify I am sure many other centers also have this thing about whenever you send UDP you will see this port unreachable message that send UDP.C when you are running on a particular host you are specifying some random destination that machine may very well be up but within the send UDP program you are also choosing some random port so it is not like a commonly used port that is there. So when you send all you are doing at the sending side is you are assembling a packet to the destination and specifying the port number as this random port and sending it out. Now at the destination very likely in fact we do not want anyone listening on to the port for this experiment is known as listening on that particular port thereby when this message reaches that other end host end host will say port unreachable message because there is no one listening on that particular port. The objective of that particular exercise has to do just with IP fragmentation whereby you are sending out a packet that is going to get fragmented it is not expecting a reply from the other end in fact it does not want anyone to act on that particular packet because you are just sending randomly a packet you do not want the other end to get confused about this packet. So we chose purposefully a port that no one is going to listen on and thereby send so the other host is doing the right thing in saying that the port is unreachable. I wanted to know the difference between packet delivery fraction and throughput. So packet delivery ratio is if you are sending 100 packets and about 80 packets were received right 80 over 100 is your packet delivery ratio because out of 100 you got 80 throughput takes into account the packet size as well so in other as well as time. So it is specifically telling that during this time t1 to t2 I have received these many packets of this many bits and thereby that is the calculation. So the first one packet delivery ratio then there is no concept of time or packet size it is like you are done doing an experiment where you may send the 100 packets over 100 seconds or 1000 seconds does not really matter at the end point you are just measuring how many did I receive correctly that is the packet delivery ratio throughput is little bit more informative. So throughput can be a better metric for qualification. It depends upon what is it that you are trying to measure as well. So for example if packet delivery ratio has a correlation with loss rate sometimes it is inverse of loss rate. So if 80 out of 100 were received then 20 out of 100 were lost. So depends on the context what is it that you are interested in. You may be interested in some context more in the loss rate rather than throughput. For example if you are dealing with the audio or a video kind of a thing where throughput is not that important what matters more is what is the losses I am seeing. But if you are dealing with a file transfer protocol you may worry more about throughput. Madam if you could throw some highlight on configuration of batch up to that. Yeah you need to specify within the terminal where the necessary NS2 folder is because you want to use NS2 from command line you are not going to go into the directory where it got installed. So you need to specify within the OS where the NS2 file NS2 executable is. So for all that you need to insert in all this. But there is an NS2 direct Ubuntu installation through sudo apt-get install NS2. You could just do sudo apt-get install NS2 and that will take care of all these business. So you do not have to worry about all that. Every NS2 installation involved downloading the tar zip file unloading it and doing make blah blah. But these days it is lot easier you can just do sudo apt-get install. Thank you madam. Kathir college. I have a quick question. What is the difference between trace root and TCP dump? This is my first question. The second question is if I want to add new features in the header can I or where I can see these definitions of the header. My third question is if I run the simulation result more than 5 minutes my system will automatically go hand. So is there any time limitation to show the simulation result? So coming to your first question what is the difference between TCP dump and trace root? They are very different. TCP dump is basically a monitoring tool of packets that are coming into and outside you are going out as well as coming into your host. So whatever traffic your host is handling TCP dumps tell you tells you what are the packets that you are getting as well as sending out. The trace root is again a tool that specifies how many what is the path taken by a packet between your host and some destination. So when you run trace root you could use TCP dump to measure what all packets were sent out as well as received when you are doing trace root. So trace root is mostly for finding out the path it is a command. TCP dump is basically a packet capture tool. So the second question you have asked is can we change the header fields? So typically you cannot change because these are so for example this is all standardized the IP header is standardized the link headers are standardized the transport headers are standardized and they all come with the kernel implemented as part of the kernel. You can hack the kernel and make some changes but then no one else will be able to understand the changes you have made because the others expect to follow the standard. Now coming to your third question where you ran some NS2 simulation and it hangs it depends upon the simulation how many packets are getting generated how many. So typically for every packet that is generated there is some memory allocated to it internally memeloc something if you are running for a really long time it is possible that you are exhausting the memory and specifically if you have hacked NS2 and implemented some protocol if you are doing memeloc and not clearing when you receive a packet discarding a packet you have to clear up that memory space if you are not doing it as you keep on generating packets your memory something will happen and there is a possibility of crash. You have to really debug internally to see what is happening. Saroj Mohan Institute. We want to know that about this M TPS system when students are sharing suppose they are sharing what they are missing. In the sharing system we think that obviously it is going to consume less time but in our class suppose we have 60 students. In the given time M TPS system how can we effectively and can we apply this system? That is my question. So you may have a large class but that does not mean you pick on every student and go through the particular solution of that particular pair. Let us say there are 60 students you have 30 groups you are not going to go through each and every 30 of them. You randomly pick some 3-4 people discuss it and more often than not the 3-4 is going to cover the spectrum and in the next class you pick on some other disjoint set. So you cannot spend all the time so you just sample 1 or 2 or at most 2-3 and then you tie in all the loosens saying that there are these other ways of doing it as well and this is the total conclusion. Srinagar. In NS2 how do we specify which node is a host and which host is a router? So there is no concept of the router so in NS2 everything is a node and the node has the capability of doing all the required functionalities. So there is not any segregation as such so it will any node will support feeding traffic from the application layer as well as doing some switching in terms of taking something from incoming figuring out what the node addresses and sending out on the outside interface. So there is not such a clear cut distinction between a router and a node. In other words a node implements all the required features corresponding to a host as well as a router. Just one more question ma'am. When we create a link we tell it to where to drop the packets. For example drop tail tells us to drop the packets that are at the end of the queue. Can we drop packets at some other place at the front of the queue? Yes. So you can, there are a bunch of models for packet loss in NS2. All you need to do is when you are specifying the, if you look at the NS script. Yeah if you see this there is something called drop tail here when you are establishing the link between the nodes. You could specify it to something else. I don't offhand remember what are the models that are there but it could be random drop anywhere within the queue or it could be at the head of the queue so on so forth. So you just have to change that wording drop tail to some other word and it will take care of it. Mayor, institute, university. How to rectify the losses of bits? We have any tool for that? So depends I mean you as a you cannot really at the application layer do anything about it but often in wireless networks and all where the loss rates are high you do employ this error correction mechanism where even if some bits are corrupted you add additional information such that you can potentially correct those errors. So that is feasible through error correction and there are plenty of error correction codes that you could imply over the data to correct the corruption. There is any tool for that? I mean what do you mean by tool? So all this so if you are talking about an implementation all these things happen at the link layer and these corrupted packets are not even passed up the protocol stack. If it can correct it will correct and pass the corrected packets up if it is not able to correct it will just discard the entire packet. So you will not see it at the higher layers unless you are doing research in the space and are modifying things at the physical link layer then you can see the stuff and employ some algorithms there. So for example there is lot of research in using software defined radios in getting the bit stream and employing some algorithms there to correct the bit error. So all this is handled in implementation like that but if you are talking about some simulation and you are doing yes there are libraries I mean you have to I do not have know anything offhand but I am sure there is code available online. You just need to download the code it will be in C or something integrate it as part of your simulator and it will correct the errors if there are any errors in the packet. My question is based on graphical user interface of NS2. VNS is available on internet that provides graphical interface to NS2 but exactly it is. Yeah this is integrated I think more in NS3. So it is just like you have a network animator that you are going to see thing off. You should be able to set some of the parameters like define the topology that figure that you have seen instead of manually putting it as part of the tickle you could add drop nodes create links between them even some of the setting up that this link has 1 mbps 50 milliseconds all that you could do through the GUI. Ma'am can we take the output in xgraph? Yes so yeah so NS2 whatever works for you I you can take the output in xgraph but as I said you have to run some the scripts over the trace before you get the data in the format that you want. Okay thank you ma'am. Techno India Salt Lake. I have a question regarding how NS2 can be used to cover the white spectrum of networks regarding simulation and performance evaluation and the second related question around with that can we publish papers in international journals by getting the performance evaluation results from NS2 or NS3. This is regarding the internal details of the software which we are not much ever with that if you can currently clarify. So you are basically telling about the protocols and other things that are there as part of NS2 as I said NS2 has a whole range of protocols and it is a community effort many people keep on adding protocols to it since it has a wide range of protocols you could explore through NS2 many things like at the link layer you could PSMA CD you can explore CSMA CA you can explore in the wireless space there are plenty of other protocols called Macau blah blah so all those protocols are there. So you can explore many of them as part of NS2 even at the network layer it does some basic routing lot of the contribution comes from the wireless space because that is where lot of research ideas are. So it has the entire spectrum of DSDV DSR AO DV all those protocols that are in the wireless space are there even at the TCP level it comes with various flavors of TCP TCP Renault TCP Vegas TCP new Renault. So it comes with applications also there are many things that web traffic FTP traffic all those things are there. So if you are trying to use it to run a course you could basically give labs and along different layers for the students to explore. So that way it is a pretty good tool for using for teaching purposes. Now coming to your next question whether you could use NS2 NS3 for research publications definitely I mean the most of the simulation work in this space happens through the use of NS2 NS3 because it is open source and you could write your own protocols. So for that you do not operate at the tickle level you have to get into the C++ level it is a little bit there is a bit of a learning curve for that it will take some time for you to understand the internals of NS2 maybe it may take about 3-4 months for you to even understand how the different things are organized internally but there are lot of tutorials also for that and once you write any protocol you could evaluate the details of the protocol through NS2 NS3 and publish that particular work. So in a high level yes it is used in the community for research work. In fact it is more used than any other simulator I am aware of like opnet or other things are less used than NS2. Ma'am just one related question this is regarding the simulation software that you are saying that we can develop simulation software using C++ or C whatever. So I have been working in this field over past 10-20 years. Actually I have been writing simulation codes using C and C++ as well for network simulations and all. So is the NS2 very comfortable with C++ code being added to this and evaluation getting done as an addendum process? Yes that is what the front end it is tickle the back end is C++ so it is kind of very straight forward to write modules except that as I said NS2 is organized in a certain fashion internally you need to understand what is the structure within before you can know where exactly you should make modifications that will take some time but it is in C++ itself. Information is available in the open source. NS2 website if you visit they do talk a lot about how it is in fact there is a huge documentation of NS2 about 100 page or 200 page document which talks a lot internally what is happening within NS2. Thank you very much ma'am. Middle Institute. Madam can we do some processing at particular node? Suppose that node at that node two other data from two other nodes is coming and we want to do the processing with that data like XOR operations can we do at what place we can do in NS2? See if you want to do anything that is involving at the protocol level you have to get into the C++ portion of it. It is not so tickle is just a configuration like specifying what the link capacities are or specifying whether it is a drop tail or some other so that is it is basically configuration you do via tickle. Any functionality you want to implement you have to begin at the C++ level. So you have to get in at the within the node you have to implement whatever functionality you want you have to identify where is the right place to implement this functionality and code it. Yes you can implement it but you cannot do it at the tickle level you have to do it at C++ level. When we are going for the source code so many things are there so but where I can do this processing like simple operation one XOR operation we are interested to do. So I mean it has been ages since I have looked into inside thing but this so typically within a node there is a structure to a node if you look up at that NS2 documentation it will tell you how things are organized within a node. You have to capture the right place within I mean I cannot tell off hand without looking at that particular structure but if you download the NS2 documentation there are figures on that will specify exactly how the modules are organized within a node you have to see and it will also explain what each module is doing you have to capture the point where the two packets are coming in some queue and there is where you have to implement this functionality. So madam when we are see this is open source network simulator when we are comparing any means like licensed network simulator so are we are going to get the similar results or it will be there will be any difference like quality if you are utilizing and going for same policy and same data rate and same protocols are we going to get the same results or different result between NS2 and quality or any. So it depends upon the scenario and lot of so if something is very complex I may suspect things may be different between two similar different simulators but some things that are very similar at least the nature of results will be same if not the exact value for example in some case if you got loss rate to be 2 percent another case you may get loss rate to be 2.1 percent but it would not be 10 percent. So that level of similarity I think will be there but the more and more complex setup is or the environment is the topology or the protocols that you are using then they may start to differ depends upon their implementation internally to a good extent they would have followed for example if you are using certain version of TCP both implementation should follow the same thing but sometimes they may do things a little bit different because they I mean being coded by people like you and me itself it is not that some someone is going to check the correctness of it against the TCP standard that is being followed. In that context let me also tell one very useful feature of NS2 this is just an information and I think we are also also out of time so this is the last piece of information. NS2 has a nice thing called cradle so its implementation is rather installation is a little bit tricky but it is doable many people have done it. What it does is you could feed actual implementation packets so for example you run a web browser within your host and it is generating packets and they are going down the protocol stack so if they go through TCP they go through IP and so on and you can feed these implementation in other words actual packets that are being generated by your machine into NS2 simulator and you could for example so let us say there is a host and destination so what you do is at the application level you have a server and a client running at the user space maybe using socket programming or whatever it is you want generating packets and you are routing these packets via NS2 where NS2 you could implement 10 hop network or 20 hop network or anything complex but the traffic that is being fed into NS2 is actually coming from the kernel space. So this is very useful for example if you want to capture the real implementation artifacts for example if you want to use a real TCP implementation and not the implementation that has come with NS2 you could do this. So this goes by the name network cradle so you could Google it and look into it. So with this we will close the session.