Friday, 3 October 2014

How to create a patch using diff

Use

Patch file maily used for distributing your software as source code is an excellent idea because it allows a people easily understand how you have implemented things and how you used feature.And also allows people to check and mainly to reuse the source code.

Syntax :


patch - apply a diff file to an original


Synopsis:

       patch [options] [originalfile [patchfile]]

       but usually just

       patch -pnum <patchfile


patch : Solves  probably only a small percentage of source code has changed between each release.

It was written by Larry Wall, who also written the Perl programming language.

The patch allows you to distribute just the difference between two version

for example this version1 named as file1.c

This is file1
line 2
line 3
there is no line 4, this is line 5
line 6
and then version2 named as file2.c


 for example this version1 named as file2.c

This is file2
line 2
line 3
line 4
line 5
line 6
a new line 8


create a difference listing with diff command

$diff file1.c file2.c > diffs

The diff file contains

1c1
< This is file1
---
> This is file2
4c4,5
< there is no line 4, this is line 5
---
> line 4
> line 5
5a7
> a new line 8

you can update your file using patch as follws

$patch file1.c diffs


The patch command has now changed file1.c to be same as file2.c

to unpatch

$Patch -R file1.c diffs

Now the file1.c contains it's original

That's all you need to get started with diff and patch. For more information use:

man diff
man patch
 
If you like this post Leave the comment here....
Thanks







Thursday, 18 September 2014

How to know the current network usage in linux



nload - Displays The Current Network Usage

nload is a console application which monitors network traffic and bandwidth usage in real time. It visualizes the in- and outgoing traffic using two graphs and provides additional info like
the total amount of transfered data and min/max network usage.

When running nload, you can switch between the devices (which you gave nload either on the command line or which were auto-detected) by pressing the left and right arrow keys. If the -m
command line parameter is given, the arrow keys switch as many devices back and forth as there are shown on the screen.

OPTIONS
A summary of the options supported by nload is included below.

-a period
Sets the length in seconds of the time window for average calculation. The default is
300.

-i max_scaling
Specifies the 100% mark in kBit/s of the graph indicating the incoming bandwidth usage.
Ignored if max_scaling is 0 or the switch -m is given. The default value for max_scaling
is 10240.

-m Show multiple devices at a time; do not show the traffic graphs.
-o max_scaling
Same as -i but for the graph indicating the outgoing bandwidth usage.

-t interval
Determines the refresh interval of the display in milliseconds. The default value of
interval is 500.

How to Install nload
Just open terminal /(Ctrl + Alt + t) and run the following command

$ sudo apt-get install nload

How to use it

Step 1: You can use nload by simply typing nload in the terminal, if you haven't provided any interface then it will display information for all network interfaces starting with eth0 (which is default). To Toggle between different network interfaces, use arrows keys or retrun key.
$ nload

1.

use arrow keys /return key. it goes.........

Decoding nload Output

Incoming: Data for incoming traffic:press return key
Curr: 23.53 kBit/s current, speed right now
Avg: 11.28 kBit/s average
Min: 33.67 kBit/s Minimum, in the observed period
Max: 0.28 kBit/s Maximum, in the observe period
Ttl: 14.34 GByte total volume transferred

Outgoing: Data outgoing traffic:
Curr: 56.29 kBit/s (same as above)
Avg: 56.24 kBit/s
Min: 44.77 kBit/s
Max: 79.67 kBit/s
Ttl: 982.78 MByte



Step 2: You can check specific network interface by specifying its name.

$ nload lo

Note: lo is a loopback network interface.
Step 3: You can check different network interfaces in same window by typing following command
$ nload -m lo ppp0




Step 4: nload uses bits/s as default unit to show traffic numbers, you can change it by specifying -u h|k|m. h - bits/s (Defualt) , k - kBits/s, m- Mbits/s.
$ nload -u k ppp0
 
Note: As you can see in the output, the total data field(Ttl) is still in Mbytes, You can change that field by using -U(capital) option.
$ nload -U k ppp0


Step 5: To know more about nload refer man page or use help command
$ man nload
$ nload --help
That's it.
I hope that you will enjoy it.
Try it some other command.
Comment it for you like.

Thursday, 28 August 2014

A QoS-Oriented Distributed Routing Protocol for Hybrid Wireless Networks

  As wireless communication gains popularity, significant research has been devoted to supporting real-time transmission with stringent Quality of Service (QoS) requirements for wireless applications. At the same time, a wireless hybrid network that integrates a mobile wireless ad hoc network (MANET) and a wireless infrastructure network has been proven to be a better alternative for the next generation wireless networks. By directly adopting resource reservation-based QoS routing for MANETs, hybrids networks inherit invalid reservation and race condition problems in MANETs. How to guarantee the QoS in hybrid networks remains an open problem. In this paper, we propose a QoS-Oriented Distributed routing protocol (QOD) to enhance the QoS support capability of hybrid networks. Taking advantage of fewer transmission hops and anycast transmission features of the hybrid networks, QOD transforms the packet routing problem to a resource scheduling problem. QOD incorporates five algorithms: 1) a QoS-guaranteed neighbor selection algorithm to meet the transmission delay requirement, 2) a distributed packet scheduling algorithm to further reduce transmission delay, 3) a mobility-based segment resizing algorithm that adaptively adjusts segment size according to node mobility in order to reduce transmission time, 4) a traffic redundant elimination algorithm to increase the transmission throughput, and 5) a data redundancy elimination-based transmission algorithm to eliminate the redundant data to further improve the transmission QoS. Analytical and simulation results based on the random way-point model and the real human mobility model show that QOD can provide high QoS performance in terms of overhead, transmission delay, mobility-resilience, and scalability.

STARS: A Statistical Traffic Pattern Discovery System for MANETs



            Many anonymity enhancing techniques have been proposed based on packet encryption to protect the communication anonymity of mobile ad hoc networks (MANETs). However, in this paper, we show that MANETs are still vulnerable under passive statistical traffic analysis attacks. To demonstrate how to discover the communication patterns without decrypting the captured packets, we present a novel statistical traffic pattern discovery system (STARS). STARS works passively to perform traffic analysis based on statistical characteristics of captured raw traffic. STARS is capable of discovering the sources, the destinations, and the end-to-end communication relations. Empirical studies demonstrate that STARS achieves good accuracy in disclosing the hidden traffic patterns.




Defending Against Collaborative Attacks by Malicious Nodes in MANETs: A Cooperative Bait Detection Approach



                In mobile ad hoc networks (MANETs), a primary requirement for the establishment of communication among nodes is that nodes should cooperate with each other. In the presence of malevolent nodes, this requirement may lead to serious security concerns; for instance, such nodes may disrupt the routing process. In this context, preventing or detecting malicious nodes launching grayhole or collaborative blackhole attacks is a challenge. This paper attempts to resolve this issue by designing a dynamic source routing (DSR)-based routing mechanism, which is referred to as the cooperative bait detection scheme (CBDS), that integrates the advantages of both proactive and reactive defense architectures. Our CBDS method implements a reverse tracing technique to help in achieving the stated goal. Simulation results are provided, showing that in the presence of malicious-node attacks, the CBDS outperforms the DSR, 2ACK, and best-effort fault-tolerant routing (BFTR) protocols (chosen as benchmarks) in terms of packet delivery ratio and routing overhead (chosen as performance metrics).

VSPN: VANET-Based Secure and Privacy-Preserving Navigation



               

            In this paper, we propose a navigation scheme that utilizes the online road information collected by a vehicular ad hoc network (VANET) to guide the drivers to desired destinations in a real-time and distributed manner. The proposed scheme has the advantage of using real-time road conditions to compute a better route and at the same time, the information source can be properly authenticated. To protect the privacy of the drivers, the query (destination) and the driver who issues the query are guaranteed to be unlinkable to any party including the trusted authority. We make use of the idea of anonymous credential to achieve this goal. In addition to authentication and privacy preserving, our scheme fulfills all other necessary security requirements. Using the real maps of New York and California, we conducted a simulation study on our scheme showing that it is effective in terms of processing delay and providing routes of much shorter traveling time.

PSR: A Lightweight Proactive Source Routing Protocol For Mobile Ad Hoc Networks



                Opportunistic data forwarding has drawn much attention in the research community of multihop wireless networking, with most research conducted for stationary wireless networks. One of the reasons why opportunistic data forwarding has not been widely utilized in mobile ad hoc networks (MANETs) is the lack of an efficient lightweight proactive routing scheme with strong source routing capability. In this paper, we propose a lightweight proactive source routing (PSR) protocol. PSR can maintain more network topology information than distance vector (DV) routing to facilitate source routing, although it has much smaller overhead than traditional DV-based protocols [e.g., destination-sequenced DV (DSDV)], link state (LS)-based routing [e.g., optimized link state routing (OLSR)], and reactive source routing [e.g., dynamic source routing (DSR)]. Our tests using computer simulation in Network Simulator 2 (ns-2) indicate that the overhead in PSR is only a fraction of the overhead of these baseline protocols, and PSR yields similar or better data transportation performance than these baseline protocols.