In the ugly racial undertones to the war in Vietnam the brown-skinned people were "gooks" or "slopes" or other words that conveyed a presumed inferiority.

Now, on a bewildering U.S.-Mexican border that is more heavily traveled than the Ho Chi Minh trail, the brown-skinned people are "conks" or "beaners" or "aliens." Again, the brownskins seem to be winning, and the losers don't like it.

How little some of them may like it has been revealed in a San Diego indictment of four U.S. border patrolmen for allegedly violating the civil rights of illegal Mexican immigrants by beating and kicking them when they were helpless and unarmed after arrest.

It is the first such federal indictment in the 55-year history of the U.S. Border Patrol, and some civil rights attorneys here liken it to the first indictments of southern peace officers for mistreating blacks during the civil rights revolution of the '60s.

Mexican-American activists claim that the indictments show the very small tip of a very large iceberg that long has been hidden from public view.

From the Border Patrol point of view, the indictments have opened a window on a world of repeated futility and frustration in which hundreds and sometimes thousands of Mexicans are rounded up every night, only to be turned loose again the next morning.

The indictments, which charge specific acts of mistreatment plus conspiracy to commit these acts, give hints of a larger disorder, suggestive of vigilantism, within the Border Patrol.

One of the incidents related in the indictment involved an unidentified illegal immigrant, who, after his apprehension last July 3, supposedly made an obscene gesture at a border patrolman. He allegedly was taken to a prearranged place of punishment and struck several times on the face.

Then the hand that made the offensive gesture allegedly was placed on the floorboard of a van and beaten repeatedly with a nightstick. The indictment quotes a patrolman who was transporting the Mexican to his place of punishment as explaining to a trainee:

"Sometimes we find it necessary to do things like this because the criminal justice system doesn't do anything about these a-- -."

These indictments have not set well with the Border Patrol, an embattled and underpaid force whose morale, in the words of the attorney for one of the indicted patrolmen, "already was down around the shoelaces."

Patrol trainees who are to testify for the prosecution have been given special protection after one of them said his car was vandalized and the wife of another complained of being followed by a defendant. Michael H. Walsh, the outspoken U.S. attorney who brought the indictments, has won an early trial date of Nov. 13 in an effort to ensure that his witnesses are available and unharmed.

At the rank-and-file level, sympathy is with the indicted officers, not with those who are testifying against them. As in more formal wars, the men on the line tend to believe that they have been abandoned by superiors and countrymen who neither understand nor care about their problems.

In statistical terms alone, these problems seem almost beyond comprehension. The San Ysidro border is the most direct route to the lucrative job market in Los Angeles. Last year, in a 16-mile stretch of border extending eastward from the Pacific Ocean, the Border Patrol apprehended 322,214 people, slightly more than 40 percent of the total arrests made along 2,000 miles of Mexican border. The number will be equal or greater this year. On some peak summer weekends, as many as 4,000 illegal immigrants are apprehended in a single night.

"It's just like if they gave you a teaspoon and told you to empty the Pacific Ocean," says veteran Border Patrolman Leonard D. (Butch) Kelley. "The job will never be done. There's no reward in it. I caught one man four times the same night. We just sent him back to Mexico."

In the Chula Vista sector here, the Border Patrol deploys 430 agents, soon to be increased to 630, against the flood of immigrants. But because the patrol works around the clock and the agents are used for support, investigation or air reconnaissance purposes, there are rarely more than 45 patrolmen on the line at any given time.

For these front-line troops, the San Ysidro border is a maze of fields, ditches, ramshackle homes and a broken border fence. This old fence gradually is being replaced by a new 10-foot chain-link fence the builder calls "a tennis court" that will be as easy to climb over as the old one.

In the center of the sector, overlooking one of the world's busiest legal border crossings, the homes and ditches give way to the scrub-covered Otay Mesa, a guerrilla's paradise of hills and gullies that remind Korean War veterans of the terrain around Inchon.

On a part of the Mesa known as the "loading docks," near the spot where the indicted border patrolmen supposedly punished their captives, the hills become a lunar landscape traversed by hundreds of foot trails. The trails carry a ceaseless traffic in which the humanity of the immigrants is submerged in countless numbers of brown faces.

In June the San Ysidro border became a war zone of nightly shootings and flying rocks. An undetermined number of Mexicans was killed or wounded by gunfire, some of it coming from the Mexican bandits or smugglers who were trying to divert the Border Patrol.

The situation became so explosive that U.S. officials, led by Walsh and Border Patrol sector chief Donald M. Cameron, appealed to Baja California Gov. Roberto de la Madrid for help. De la Madrid cooperated in a crackdown on smugglers and installation of an international hotline that has restored this border, at least temporarily, to a condition of tense normalcy.

It is doubtful, however, that any cooperation for any hotline can quiet the border for long. The reality of illegal Mexican immigration is expressed by Cameron, the Border Patrol officer who is charged with stopping it.

"I see no change in the number of people who are going to enter the United States from Mexico," Cameron says. "This is an escape valve for them. If all of their people stayed in Mexico with the grinding poverty they've got down there and the unemployment, Mexico would face a violent situation, maybe a revolution . . . A Mexican is faced with two choices -- commit a crime or come to the United States. Since most of them are basically honest, they come up here because we attract them. We've got the jobs."

Sharing similar assessments, some Border Patrolmen wonder, even as in Vietnam, what they are doing here in the first place. They become angry and frustrated at the unappreciated tedium of their work and even more angry when Chicano rights activists such as Herman Baca accuse patrolmen of brutally administering "the slave trade of Mexican immigration."

Baca refers to the San Ysidro border as "the Vietnam of the Southwest," and the reference is appropriate in the hopelessness of the experience, if not in casualties. Along the Mexican border, leftover technology from America's latest Asian war is being employed in a conflict that seems to fully merit the Vietnam description of "no-win."

This technology is pervasive. Helicopters. Infrared scopes that can spot a dark-jacketed man in a dark field on a pitch-black night. Sensors. A computer-controlled sensor board. Anti-smuggling teams who know the language of the enemy and infiltrate his camp.

Last week, on a quiet Tuesday night along the border, this Vietnam technology apprehended immigrants in groups of threes and fours as they moved through bean and tomato fields into San Diego County.

First, the incoming Mexicans were spotted on the infrared scope. Then a helicopter swooped in, a lighted platform sending beams of light onto the fields below. When the immigrants were bathed in light, border patrolmen in four-wheel-drive vehicles moved in to capture them. The apprehended illegals were packed into vans and taken back for overnight detention in Chula Vista.

Along with leftover technology come leftover attitudes.

Border patrolman Butch Kelley, a Texan from Odessa, is fed up. In five years on the San Ysidro border he has been shot at four times, once so close he could see the muzzle blast, and hit on the head by a rock. He says few Americans respect the Border Patrol or care whether it remains.

Like any soldier in a winless war, he is harnessed by the contradictions imposed on the men who fight it. Arrest the Mexicans, but let them go. Patrol in pairs but have one person remain with the van at all times. Treat the captives kindly, but stop them, stop them.

"You keep coming out night after night and getting run over," he said.

That is a border patrolman's side of the story. Another view emerges in a 19-month study prepared here by Federal Defenders, the attorneys who represent indigent defendants in federal courts. The study details 23 cases in which Mexican defendants arrested by the Border Patrol arrived in court severely beaten. Some had suffered such extreme injuries that they were brought to court in wheelchairs.

John Cleary, the executive director of federal defenders, observed that fewer than 1 percent of apprehended illegal immigrants are brought to court. He says it is reasonable to assume that there are dozens of cases of brutality that never come to official attention.

In the cases that do come to light, it is usually Mexicans and not border patrolmen who are the victims. A Tijuana teen-ager shot through the broken fence and a border patrolman acquitted because of uncertain identification. A Mexican supposedly running toward a patrolman who was shot in the back of the foot. A young Mexican heading for an evening party in Los Angeles flushed from a culvert with a flare and struck over the head with a flashlight. A parade of Mexicans beaten or slapped or kicked while "resisting arrest."

Whether the precedent-shattering indictments of the four border patrolmen represent a change in the familiar pattern is a matter of some dispute. Cameron is widely regarded as a gruff, honest cop who means it when he says that the allegations, if proved, are "brutality that has no place in the Border Patrol."

Walsh is considered a politically ambitious prosecutor who has been reluctant to bring charges against patrolmen for mistreating Mexican immigrants. But some of those who know the U.S. attorney say that this supposed reluctance has been based on the poor quality of evidence in past cases. There seems little doubt that Walsh is completely serious about the present prosecutions.

Whatever else happens, the indictments have had a shattering impact on the attitudes of a border police force that only rarely has come under public scrutiny.

As in Vietnam, the armed troops here are captives of their nation's policy and technology. Outnumbered and unloved, it is difficult for them to look with kindliness on those who appear to be defeating them.