Wednesday, May 23, 2007

installing zte mc315 on linux

Here are 4 steps to get the reliance aircard ZTE MC315 on linux. I got it running on ubuntu 7.04.

1. Insert the card and look at dmesg
output : 0.0: ttyS3 at I/O 0x2e8 (irq = 3) is a 16C950/954

This says that your card was detected properly.
You can also run "pccardctl info"
output =
PRODID_1="CDMA1X"
PRODID_2="CARD"
PRODID_3=""
PRODID_4=""
MANFID=0279,950b
FUNCID=2
PRODID_1=""
PRODID_2=""
PRODID_3=""
PRODID_4=""
MANFID=0000,0000
FUNCID=255


2. edit /etc/wvdial.conf

[Dialer Defaults]
Modem = /dev/ttyS3
Baud = 57600
SetVolume = 0
Dial-AT-OK ATDT Command =
Init1 = ATZ
FlowControl = Hardware (CRTSCTS)
Phone = #777
Username =
Password =
New PPPD = yes
Carrier Check = no
Stupid Mode = 1

3. Run set serial
(download and install setserial - if you dont have setserial)
"setserial /dev/ttyS3 baud_base 230400"

4. run wvdial
wvdial

So to get it running everytime you will need to create a shell script doing steps 3 & 4. Say mydial

---------------
setserial /dev/ttyS3 baud_base 230400
wvdial
---------------

PS
This method is also not perfect. I got one card working with this procedure, but could not get another card working using the same procedure.

Let me know if this helps you getting your ZTE MC 315 card running on linux.

PS 2
And to add to it, finally i have got my card running.
The trick is simple - you have to play with the UART and the baud_base.

Just run setserial on your machine and it will give the following output for UART and baud_base

* uart set UART type (none, 8250, 16450, 16550, 16550A,
16650, 16650V2, 16750, 16850, 16950, 16954)
* baud_base set base baud rate (CLOCK_FREQ / 16)


What i did was that i kept on changing my UART and kept the baud_base as 230400. I changed my UART to 16850 and then to 16750. And my card responded at 16750. And i got connected to the internet

So, My dialup script does this before doing wvdial

setserial /dev/ttyS3 uart 16750
setserial /dev/ttyS3 baud_base 230400


And this gets my card running. So to get your card running, i would suggest you try setting different UART and baud_base...

Anger Management

Having a bad day?

When you occasionally have a really bad day, and you just need to take It out
on someone, don't take it out on someone you know -- take it out on someone
you don't know. I was sitting at my desk when I remembered a phone call I had
forgotten to make. I found the number and dialed it.

A man answered, saying, "Hello."

I politely said, "Could I please speak with Robin Carter?"

Suddenly, the phone was slammed down on me. I couldn't believe that Anyone
could be so rude. I realized I had called the wrong number. I tracked down
Robin's correct number and called her. I had accidentally transposed the last
two digits of her phone number. After hanging up with her, I decided to call
the 'wrong' number again.

When the same guy answered the phone, I yelled, "You're an *******!" and hung
up.

I wrote his number down with the word '*******' next to it, and put it in my
desk drawer.

Every couple of weeks, when I was paying bills or had a really bad day, I'd
call him up and yell, "You're an *******!" It always cheered me up.


When Caller ID came to our area, I thought my therapeutic '*******' calling
would have to stop. So, I called his number and said, "Hi, this is John Smith
from the Telephone Company. I'm just calling to see if you're familiar with
the Caller ID program?"

He yelled, "NO!" and slammed the phone down.

I quickly called him back and said, "That's because you're an *******!"

One day I was at the store, getting ready to pull into a parking spot.
Some guy in a black BMW cut me off and pulled into the spot I had patiently
waited for. I hit the horn and yelled that I had been waiting for that spot.
The idiot ignored me. I noticed a "For Sale" sign in his car window . . so, I
wrote down his number.

A couple of days later, right after calling the first ******* ( I had his
number on speed dial), I thought I had better call the BMW *******, too.

I said, "Is this the man with the black BMW for sale?"

"Yes, it is."


"Can you tell me where I can see it?"


"Yes, I live at 1802 West 34th Street . It's a yellow house, and the car's
parked right out in front."

"What's your name?" I asked.

"My name is Don Hansen," he said.

"When's a good time to catch you, Don?"

"I'm home every evening after five."

"Listen, Don, can I tell you something?"

"Yes?"

"Don, you're an *******."

Then I hung up, and added his number to my speed dial, too. Now, when I had a
problem, I had two assholes to call.
But after several months of calling them, it wasn't as enjoyable as it used to
be. So, I came up with an idea. I called ******* #1.

"Hello."

"You're an *******!" (But I didn't hang up.)

"Are you still there?" he asked.

"Yeah," I said.

"Stop calling me," he screamed.

"Make me," I said.

"Who are you?" he asked.

"My name is Don Hansen."

"Yeah? Where do you live?"

"*******, I live at 1802 West 34th Street , a yellow house, with my black
Beamer parked in front."

He said, "I'm coming over right now, Don. And you had better start saying your
prayers."

I said, "Yeah, like I'm really scared, *******."

Then I called ******* #2.

"Hello?" he said.

"Hello, *******," I said.

He yelled, "If I ever find out who you are...!"

"You'll what?" I said.

"I'll kick your ass," he exclaimed.

I answered, "Well, *******, here's your chance. I'm coming over right now."

Then I hung up and immediately called the police, saying that I lived at 1802
West 34th Street, and that I was on my way over there to kill my gay lover.

Then I called Channel 13 News about the gang war going down on West
34th Street.

I quickly got into my car and headed over to 34th street .

When I got there, I saw two assholes beating the crap out of each other
in front of six squad cars, a police helicopter, and the channel 13
news crew.

NOW, I feel better - This is "Anger Management" at its very best.

Friday, May 11, 2007

mysql multi-master replication - Act II

SETUP PROCEDURE
Created 4 instances of mysql on 2 machines running on different ports. Lets call these instances A, B, C and D. So A & C are on one machine and B & D are on another machine. B is slave of A, C is slave of B, D is slave of C and A is slave of D.

(origin) A --> B --> C --> D --> A (origin)

Each instance has its own serverid. A query originating from any machine will travel through the loop replicating data on all the machines are return back to the origniating server - which in effect will identify that the query had originated from here and would not execute/replicate the query further.

To handle auto_increment field, two variables are defined in the configuraion of the server.

1. auto_increment_increment : controls the increment between successive AUTO_INCREMENT values.

2. auto_increment_offset : determines the starting point of AUTO_INCREMENT columns.

Using these two variables, the auto generated values of auto_increment columns can be controlled.

Once the replication loop is up and running, any data inserted in any node would automatically propagate to all the other nodes.

ISSUES WITH MULTI-MASTER REPLICATION & AUTOMATIC FAILOVER

1. LATENCY

There is a definite latency between the first node and the last node. The replication steps lead to the slave reading the master's binary log through the network and writing it to its own relay-bin log. It then executes the query and then writes it to its own binary log. So each node takes a small amount of time to execute and then propagate the query further.

For a 4 node multi-master replication when i replicated a single insert query containing one int and one varchar field, the time taken for data to reach the last node is 5 ms.
This latency would ofcourse depend on the following factors
a) amount of data to be relicated. Latency increases with increase in data
b) Network speed between the nodes. If the data is to replicated over internet, it will take more time as compared to that on nodes in LAN
c) Amount of indexes on the tables being replicated. As the number of indexes increase, the time taken to insert data in tables also increases. Increasig the latency.
d) The hardware of the machine and the load on the machine will also determine how fast the replication between master and slave will take place.

2. AUTOMATIC FAILOVER

Automatic failover can be accomplished using events and federated tables in mysql 5.1. Federated tables are created between master and slave and are used to check connection between master and slave. An event is used to trigger a query on the federated table which checks the connection between master and slave. If the query fails, then a stored procedure can be created which should chunk the master out of the replication loop.

So suppose in the loop shown above, A goes out, then the event on B would detect that A is out and would make D as a master of B.

This is the theoretical implementation of automatic failover. Practically there are a few issues with its implementation.

a) for failover, you need to know the position of master's master from where the slave should take over. (So B should know the position on D from where it has to start replication). One of the ways to do this is that each slave logs its master's position on a table which is replicated throughout the loop. But this again is not possible using events & stored procedures - cause there is no query which can capture the information available from "SHOW SLAVE STATUS" query in a variable and write it in a table. Another way to do this is to have an external script running at an interval of say 10 seconds which logs this information and checks the federated tables for any disruption in the master-slave connection. With this methodology, the problem is that there could be a 10 second window period during which data can be lost.

b) You could also land into an infinite replication situation. Lets look how using the 4 node example above. Suppose "A" goes down and It has a query in its binary log which has to be replicated throught the loop. So the query propagates from "B" to "C" and finally to "D". Now since "A" is down and failover has happened, "B" would be the slave of "D". So the query which originated from "A" would go from "D" to "B". Thats because if "A" would have been there, it would have identified its own query and stopped it. But since "A" is out of the loop, the query will not be stopped and it will propagate to "B" and will always be in the loop. This can result in either the query running in the loop indefinitely or an error on all the slaves and all the slaves going down.

These are the major issues with multi-master replication and automatic failover. Though one can still live with the automatic failover scenario - as it might occur once in a while. But the latency between first and last node during replication has no solution. This latency is due to physical constraints and cannot be avoided.

A work around would be distributing the queries based on tables on all the nodes. So that queries for a table would always be served from a single node. But this then would result in table locks on that node and again we would not be able to reap the benefits of multi-master replication.

Monday, May 07, 2007

Indian railways

It has been almost 27 years since I was born and since i had been traveling in the indian railways. But with increase in time the indian railways has become from bad to worse. It is actually an ordeal to travel in railways. Then why am i writing the post today and not before. Well, i actually realized it yesterday.

At indian railways, the trains are never expected to arrive on time. All trains run late. And if you are standing at one of the platforms, you will constantly hear - "train x which was supposed to come at time y is delayed by delta minutes/hours. The inconvenience caused is deeply regretted". And the announcer would never sound as if he/she was regretting anything. It is said in a matter-of-fact way - as if we are supposed to know that the delay was naturally expected - just like you expect corruption in each and every section of the government of like you expect to get ketchup free with your samosa.

Let me brief you as to what happened last night. Had been to the delhi station to put my mom on the train for baroda. First of all - it had been a long time since i had been to the railways. So i had to enquire about where the parking was. And very few people seemed to know where it was. And since there is no visible board giving directions - i had to run here and there to get the location of parking space.

Well next - get information about the platform where the train would arrive. And the only way to get this information is to stand in queue - after about 100 people and wait your turn. The uncleji at the enquiry window - does not give a shit about who is on the other side of the window. I had time to enquire - what about people who arrived late and need the info - can they wait in queue for 30 minutes to enquire about which platform they should go. It seems the situation in delhi was worse. Its better in baroda - where there is less crowd and the information is properly displayed on the general information board.

Now - since i know which platform i have to go, i will have to spend rs 3/- to get a platform ticket - so that any Ticket Checker cannot catch me and ask for a 50/- or 100/- ghoos for travelling without a ticket. They usually do. There has been so many instances with my friends where the TC simply asked for a Rs 50/- note to let them go. And the way to avoid this hassle is to get a platform ticket. And to get a platform ticket is another hassle. On new delhi station, it is really difficult first to locate the window which gives platform ticket. Officially platform ticket should be available on all windows. But it seems due to scarcity - its there only on one window. And the queue in front of the window is huge. Hmm, there are always queues at all windows on indian railway stations. It seems that the indian railways is very low on manpower. Well actually thats how Laalu prasad yadav - our respected railway minister brought the operating cost of Indian railways to 78% - the best in the world.

And after getting the platform ticket, we proceeded to the platform. Wow, what a place. It seems that people like to live on the platform. Everywhere - there are people sitting, chatting, boozing, gambling. You have to look for space to put your foot to move forward. I think, this is what they mean by population explosion.

What happens in baroda station is that there is a display on the platform which says where each coach will come for the train. So it becomes easy to move and get placed right in front of the coach. But in Delhi - the capital of india, the numbers on the boards are misplaced so that you have to drag your luggage and run in between the crowded platform to your bogie.

And then the trains are always crowded. It is difficult to get a ticket in a train in indian railways. There is always a waiting list and extra people on the train for whom it is important to reach their destination, but were unable to get a reservation. There are people sleeping on the floor, outside the loo and sitting on your berths.

60 years of independence, and indian railways - it seems - stays where it was.

Friday, May 04, 2007

ctrl C & ctrl V

Your Colleague: Hey!! Kya yahan baitha mail forward karta rahta hai yaar!! Naye packages dekh.... Naye language seekh, Night out Maar....Fundoo programming kar like me....! Do something cool man!!

You: Achha! To usse Kya hoga...

You 're Colleague: Impression!! ! Appraisal!!! Har appraisal main tu No 1! Hike in salary!! Extra Stocks

You: Phir kya hoga...

Your Colleague: Project Leader ban jaayega..Phir Project Manager!!! Phir Business Manager! One day U will be a Director of the Company man !!

You: Acchha to phir kya hoga...

Your Colleague: Abe phir tu aish karega! Koi kaam nahin karna padega! Araam se office aayega aur MAIL check karega.

You: To ab main kya kar raha hoon????


"Dikhawe pe na jao, apni akal lagao.

Programming hai waste, trust only copy-paste "


Powered by ctrl C


Driven by ctrl V